Exemplo n.º 1
0
    def on_menu_change(self, params):
        value = params['value']
        if value < params['min']:
            value = params['min']
        if value > params['max']:
            value = params['max']
        menu_item = self.parent.param_editor_item
        self.parent.set_param(menu_item, 'value', value)
        if menu_item == 'Vertical zoom':
            self.vertical_zoom = value
            libseq.setVerticalZoom(value)
            self.assert_and_redraw()
        elif menu_item == 'Horizontal zoom':
            self.horizontal_zoom = value
            libseq.setHorizontalZoom(value)
            self.assert_and_redraw()
        elif menu_item == 'MIDI channel':
            libseq.setChannel(self.parent.bank, self.sequence, self.track,
                              value - 1)
            self.redraw_pending = 2
            try:
                return "MIDI channel: %d (%s)" % (
                    value, self.parent.layers[value - 1].preset_name)
            except:
                pass  # No layer so just show MIDI channel
        elif menu_item == "Group":
            libseq.setGroup(self.parent.bank, self.sequence, value)
            self.redraw_pending = 2
            return "Group: %s" % (chr(65 + value))
        elif menu_item == "Mode":
            libseq.setPlayMode(self.parent.bank, self.sequence, value)
            self.redraw_pending = 2
            return "Mode: %s" % (self.play_modes[value])
        elif menu_item == 'Grid size':
            return "Grid size: %dx%d" % (value, value)
        elif menu_item == 'Trigger channel':
            libseq.setTriggerChannel(value - 1)
        elif menu_item == "Trigger note":
            libseq.setTriggerNote(self.parent.bank, self.sequence, value)
            self.redraw_pending = 2
            if value > 127:
                return "Trigger: None"
            else:
                return "Trigger: %s" % self.get_note(value)
        elif menu_item == "Pattern":
            self.set_pattern(value)
        elif menu_item == 'Clear bank':
            return "Clear bank %d?" % (self.parent.bank)
        elif menu_item == 'Clear sequence':
            return "Clear sequence %d?" % (self.sequence + 1)

        return "%s: %d" % (menu_item, value)
 def show(self, params=None):
     try:
         self.channel = params['channel']
         self.load_pattern(params['pattern'])
         self.title = "Pattern %d" % (params['pattern'])
         self.title = "Pattern %d (Seq: %s)" % (params['pattern'],
                                                params['name'])
     except:
         pass  # Probably already populated and just returning from menu action or similar
     libseq.setGroup(self.bank, self.sequence, 0xFF)
     self.copy_source = self.pattern
     self.setup_encoders()
     self.main_frame.tkraise()
     self.parent.set_title(self.title)
     libseq.setPlayMode(self.bank, self.sequence,
                        zynthian_gui_stepsequencer.SEQ_LOOP)
     libseq.enableMidiInput(True)
     self.shown = True
Exemplo n.º 3
0
 def on_menu_change(self, params):
     menu_item = self.parent.param_editor_item
     value = params['value']
     try:
         if value < params['min']:
             value = params['min']
         if value > params['max']:
             value = params['max']
     except:
         pass  # min and max values may not be set
     if menu_item == 'Play mode':
         libseq.setPlayMode(self.parent.bank, self.selected_pad, value)
         return "Play mode: %s" % (
             zynthian_gui_stepsequencer.PLAY_MODES[value])
     elif menu_item == 'MIDI channel':
         libseq.setChannel(self.parent.bank, self.selected_pad, 0,
                           value - 1)
         libseq.setGroup(self.parent.bank, self.selected_pad, value - 1)
         try:
             return "MIDI channel: %d (%s)" % (
                 value, self.parent.layers[value - 1].preset_name)
         except:
             pass  # No layer so just show MIDI channel
     elif menu_item == 'Trigger channel':
         if value:
             libseq.setTriggerChannel(value - 1)
         else:
             libseq.setTriggerChannel(0xFF)
             return "Trigger channel: None"
     elif menu_item == 'Trigger note':
         if value > 128 or value < 0:
             value = 128
         libseq.setTriggerNote(self.parent.bank, self.selected_pad, value)
         libseq.enableMidiLearn(self.parent.bank, self.selected_pad)
         if value > 127:
             return "Trigger note: None"
         return "Trigger note: %s%d(%d)" % ([
             'C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B'
         ][value % 12], int(value / 12) - 1, value)
     elif menu_item == 'Grid size':
         return "Grid size: %dx%d" % (value, value)
     return "%s: %d" % (menu_item, value)
Exemplo n.º 4
0
 def test_af01_sequence_mode(self):
     self.assertEqual(libseq.getPlayMode(0, 0), play_mode["LOOPALL"])
     libseq.setPlayMode(0, 0, play_mode["LOOPSYNC"])
     self.assertEqual(libseq.getPlayMode(0, 0), play_mode["LOOPSYNC"])