Example #1
0
 def set_grid_size(self):
     self.columns = self.parent.get_param("Grid size", "value")
     libseq.setSequencesInBank(self.parent.bank, self.columns**2)
     for col in range(self.columns):
         for row in range(self.columns):
             channel = col
             sequence = col * self.columns + row
             if col == self.columns - 1:
                 channel = 9
             libseq.setChannel(self.parent.bank, sequence, 0, channel)
             libseq.setGroup(self.parent.bank, sequence, channel)
     self.refresh_pending = 1
    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
Example #4
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)
Example #5
0
 def select_bank(self, bank):
     if bank > 0:
         if libseq.getSequencesInBank(bank) == 0:
             libseq.setSequencesInBank(bank, 16)
             for column in range(4):
                 if column == 3:
                     channel = 9
                 else:
                     channel = column
                 for row in range(4):
                     pad = row + 4 * column
                     zynseq.set_sequence_name(
                         bank, pad,
                         "%d" % (libseq.getPatternAt(bank, pad, 0, 0)))
                     libseq.setGroup(bank, pad, channel)
                     libseq.setChannel(bank, pad, 0, channel)
         self.bank = bank
         self.set_title("Bank %d" % bank)
         try:
             self.child.select_bank(bank)
         except:
             pass
Example #6
0
 def do_grid_size(self, params=None):
     # To avoid odd behaviour we stop all sequences from playing before changing grid size (blunt but effective!)
     bank = self.parent.bank
     for seq in range(libseq.getSequencesInBank(bank)):
         libseq.setPlayState(bank, seq,
                             zynthian_gui_stepsequencer.SEQ_STOPPED)
     channels = []
     groups = []
     for column in range(self.columns):
         channels.append(libseq.getChannel(bank, column * self.columns, 0))
         groups.append(libseq.getGroup(bank, column * self.columns))
     new_size = self.parent.get_param("Grid size", "value")
     delta = new_size - self.columns
     if delta > 0:
         # Growing grid so add extra sequences
         for column in range(self.columns):
             for row in range(self.columns, self.columns + delta):
                 pad = row + column * new_size
                 libseq.insertSequence(bank, pad)
                 libseq.setChannel(bank, pad, channels[column])
                 libseq.setGroup(bank, pad, groups[column])
                 zynseq.set_sequence_name(bank, pad, "%s" % (pad + 1))
         for column in range(self.columns, new_size):
             for row in range(new_size):
                 pad = row + column * new_size
                 libseq.insertSequence(bank, pad)
                 libseq.setChannel(bank, pad, column)
                 libseq.setGroup(bank, pad, column)
                 zynseq.set_sequence_name(bank, pad, "%s" % (pad + 1))
     if delta < 0:
         # Shrinking grid so remove excess sequences
         libseq.setSequencesInBank(bank, new_size *
                                   self.columns)  # Lose excess columns
         for offset in range(new_size, new_size * new_size + 1, new_size):
             logging.warning("offset: %d", offset)
             for pad in range(-delta):
                 libseq.removeSequence(bank, offset)
     self.columns = new_size
     self.refresh_pending = 1
Example #7
0
 def select_bank(self, bank):
     if bank > 0:
         if libseq.getSequencesInBank(bank) == 0:
             libseq.setSequencesInBank(bank, 16)
             for pad in range(4, 8):
                 libseq.setChannel(bank, pad, 0, 1)
                 libseq.setGroup(bank, pad, 1)
             for pad in range(8, 12):
                 libseq.setChannel(bank, pad, 0, 2)
                 libseq.setGroup(bank, pad, 2)
             for pad in range(12, 16):
                 libseq.setChannel(bank, pad, 0, 9)
                 libseq.setGroup(bank, pad, 9)
         self.bank = bank
         self.set_title("Bank %d" % bank)
         try:
             self.child.select_bank(bank)
         except:
             pass