예제 #1
0
    def activate_profile(self, i):
        v = self.model.get_value(i, 1)

        # ignore state changes while activating the profile
        self.track_changes = False
        # sending and receiving all OSC messages takes, uhm... so we need to wait at least... oh well...
        gobject.timeout_add(500, lambda: setattr(self, 'track_changes', True))

        klick.send('/simple/set_tempo', v.tempo)
        widgets['spin_tempo_increment'].set_value(v.tempo_increment)
        widgets['check_speedtrainer_enable'].set_active(v.speedtrainer)
        klick.send('/simple/set_tempo_increment', v.tempo_increment if v.speedtrainer else 0.0)
        klick.send('/simple/set_tempo_start', v.tempo_start)

        if v.denom:
            misc.do_quietly(lambda: widgets['radio_meter_other'].set_active(True))
        else:
            # focus any radio button other than "other"
            misc.do_quietly(lambda: widgets['radio_meter_44'].set_active(True))
        klick.send('/simple/set_meter', v.beats, v.denom if v.denom else 4)

        klick.send('/simple/set_pattern', v.pattern)

        # show all relevant frames
        if v.speedtrainer:
            widgets['item_view_speedtrainer'].set_active(True)
        if (v.beats, v.denom) != (0, 4):
            widgets['item_view_meter'].set_active(True)
        if v.pattern != '':
            widgets['item_view_pattern'].set_active(True)
예제 #2
0
    def activate_profile(self, i):
        v = self.model.get_value(i, 1)

        # ignore state changes while activating the profile
        self.track_changes = False
        # sending and receiving all OSC messages takes, uhm... so we need to wait at least... oh well...
        gobject.timeout_add(500, lambda: setattr(self, 'track_changes', True))

        klick.send('/simple/set_tempo', v.tempo)
        widgets['spin_tempo_increment'].set_value(v.tempo_increment)
        widgets['check_speedtrainer_enable'].set_active(v.speedtrainer)
        klick.send('/simple/set_tempo_increment',
                   v.tempo_increment if v.speedtrainer else 0.0)
        klick.send('/simple/set_tempo_start', v.tempo_start)

        if v.denom:
            misc.do_quietly(
                lambda: widgets['radio_meter_other'].set_active(True))
        else:
            # focus any radio button other than "other"
            misc.do_quietly(lambda: widgets['radio_meter_44'].set_active(True))
        klick.send('/simple/set_meter', v.beats, v.denom if v.denom else 4)

        klick.send('/simple/set_pattern', v.pattern)

        # show all relevant frames
        if v.speedtrainer:
            widgets['item_view_speedtrainer'].set_active(True)
        if (v.beats, v.denom) != (0, 4):
            widgets['item_view_meter'].set_active(True)
        if v.pattern != '':
            widgets['item_view_pattern'].set_active(True)
예제 #3
0
    def restore_config(self):
        # port connections
        if len(self.config.prefs_connect_ports):
            ports = self.config.prefs_connect_ports.split('\0')
            for p in ports:
                self.prefs.model_ports.append([p])
        else:
            ports = []

        if self.config.prefs_autoconnect:
            misc.do_quietly(
                lambda: self.widgets['radio_connect_auto'].set_active(True))
            self.klick.send('/config/autoconnect')
        else:
            misc.do_quietly(
                lambda: self.widgets['radio_connect_manual'].set_active(True))
            self.klick.send('/config/connect', *ports)

        # sound / volume
        if self.config.prefs_sound >= 0:
            self.klick.send('/config/set_sound', self.config.prefs_sound)
        else:
            self.klick.send('/config/set_sound',
                            self.config.prefs_sound_accented,
                            self.config.prefs_sound_normal)

        self.klick.send('/config/set_sound_pitch',
                        2**(self.config.prefs_pitch_accented / 12.0),
                        2**(self.config.prefs_pitch_normal / 12.0))
        self.klick.send('/config/set_volume', self.config.volume)

        # metronome state
        misc.do_quietly(lambda: (
            self.widgets['check_speedtrainer_enable'].set_active(
                self.config.speedtrainer), self.widgets['spin_tempo_increment']
            .set_value(self.config.tempo_increment), self.widgets[
                'radio_meter_other'].set_active(self.config.denom != 0)))
        self.widgets['spin_tempo_increment'].set_sensitive(
            self.config.speedtrainer)
        self.widgets['spin_tempo_start'].set_sensitive(
            self.config.speedtrainer)

        self.klick.send('/simple/set_tempo', self.config.tempo)
        self.klick.send(
            '/simple/set_tempo_increment',
            self.config.tempo_increment if self.config.speedtrainer else 0.0)
        self.klick.send('/simple/set_tempo_start', self.config.tempo_start)
        self.klick.send('/simple/set_meter', self.config.beats,
                        self.config.denom if self.config.denom else 4)
        self.klick.send('/simple/set_pattern', self.config.pattern)
예제 #4
0
    def restore_config(self):
        # port connections
        if len(self.config.prefs_connect_ports):
            ports = self.config.prefs_connect_ports.split('\0')
            for p in ports:
                self.prefs.model_ports.append([p])
        else:
            ports = []

        if self.config.prefs_autoconnect:
            misc.do_quietly(lambda: self.widgets['radio_connect_auto'].set_active(True))
            self.klick.send('/config/autoconnect')
        else:
            misc.do_quietly(lambda: self.widgets['radio_connect_manual'].set_active(True))
            self.klick.send('/config/connect', *ports)

        # sound / volume
        if self.config.prefs_sound >= 0:
            self.klick.send('/config/set_sound', self.config.prefs_sound)
        else:
            self.klick.send('/config/set_sound', self.config.prefs_sound_accented, self.config.prefs_sound_normal)

        self.klick.send('/config/set_sound_pitch',
            2 ** (self.config.prefs_pitch_accented / 12.0),
            2 ** (self.config.prefs_pitch_normal / 12.0)
        )
        self.klick.send('/config/set_volume', self.config.volume)

        # metronome state
        misc.do_quietly(lambda: (
            self.widgets['check_speedtrainer_enable'].set_active(self.config.speedtrainer),
            self.widgets['spin_tempo_increment'].set_value(self.config.tempo_increment),
            self.widgets['radio_meter_other'].set_active(self.config.denom != 0)
        ))
        self.widgets['spin_tempo_increment'].set_sensitive(self.config.speedtrainer)
        self.widgets['spin_tempo_start'].set_sensitive(self.config.speedtrainer)

        self.klick.send('/simple/set_tempo', self.config.tempo)
        self.klick.send('/simple/set_tempo_increment', self.config.tempo_increment if self.config.speedtrainer else 0.0)
        self.klick.send('/simple/set_tempo_start', self.config.tempo_start)
        self.klick.send('/simple/set_meter', self.config.beats, self.config.denom if self.config.denom else 4)
        self.klick.send('/simple/set_pattern', self.config.pattern)