def on_switch(self, switch, type): if self.parent.lst_menu.winfo_viewable(): return False if self.parent.param_editor_item: return False if switch == ENC_SELECT: if self.edit_mode: self.enable_edit(False) return True if type == "S": note = self.toggle_event(self.selected_cell[0], self.selected_cell[1]) if note: self.play_note(note) else: self.enable_edit(True) return True elif switch == ENC_SNAPSHOT: if type == "B": libseq.setTransportToStartOfBar() return True if libseq.getPlayState( self.bank, self.sequence) == zynthian_gui_stepsequencer.SEQ_STOPPED: libseq.setPlayState(self.bank, self.sequence, zynthian_gui_stepsequencer.SEQ_STARTING) else: libseq.setPlayState(self.bank, self.sequence, zynthian_gui_stepsequencer.SEQ_STOPPED) return True elif switch == ENC_BACK: self.enable_edit(False) return True return False
def refresh_pad(self, pad, force=False): if pad >= libseq.getSequencesInBank(self.parent.bank): return cell = self.grid_canvas.find_withtag("pad:%d" % (pad)) if cell: if force or libseq.hasSequenceChanged(self.parent.bank, pad): mode = libseq.getPlayMode(self.parent.bank, pad) state = libseq.getPlayState(self.parent.bank, pad) if state == zynthian_gui_stepsequencer.SEQ_RESTARTING: state = zynthian_gui_stepsequencer.SEQ_PLAYING group = libseq.getGroup(self.parent.bank, pad) foreground = "white" if libseq.getSequenceLength( self.parent.bank, pad ) == 0 or mode == zynthian_gui_stepsequencer.SEQ_DISABLED: self.grid_canvas.itemconfig( cell, fill=zynthian_gui_stepsequencer.PAD_COLOUR_DISABLED) else: self.grid_canvas.itemconfig( cell, fill=zynthian_gui_stepsequencer.PAD_COLOUR_STOPPED[ group % 16]) pad_x = (pad % self.columns) * self.column_width pad_y = int(pad / self.columns) * self.row_height if libseq.getSequenceLength(self.parent.bank, pad) == 0: mode = 0 self.grid_canvas.itemconfig("lbl_pad:%d" % (pad), text="%s%d" % (chr(65 + group), pad + 1), fill=foreground) self.grid_canvas.itemconfig("mode:%d" % pad, image=self.mode_icon[mode]) self.grid_canvas.itemconfig("state:%d" % pad, image=self.state_icon[state])
def do_clear_pattern(self, params=None): libseq.clear() self.redraw_pending = 2 self.select_cell() if libseq.getPlayState(self.bank, self.sequence, 0) != zynthian_gui_stepsequencer.SEQ_STOPPED: libseq.sendMidiCommand(0xB0 | self.channel, 123, 0) # All notes off
def play_note(self, note): if libseq.getPlayState( self.bank, self.sequence) == zynthian_gui_stepsequencer.SEQ_STOPPED: libseq.playNote(note, 100, self.channel, 200)