def OnPadPressed(self, control, event): idx = CONTROLS.PADS_64.index(control) if ui.getFocused(midi.widMixer): idx += 1 # do not include the master track (0) if self.controls.isButtonMutePressed: mixer.enableTrack(idx) elif self.controls.isButtonSelectPressed: mixer.selectTrack(idx) else: mixer.deselectAll() mixer.selectTrack(idx) elif ui.getFocused(midi.widChannelRack): if self.controls.isButtonMutePressed: channels.muteChannel(idx) elif self.controls.isButtonSelectPressed: channels.selectChannel(idx) else: channels.deselectAll() channels.selectChannel(idx) elif ui.getFocused(midi.widPlaylist): idx += 1 # TODO figure out why patternNumber starts at one instead of zero! if self.controls.isButtonMutePressed: pass else: patterns.jumpToPattern(idx) else: pass self.updateLEDs()
def _select_pattern_named(name): for i in range(1, patterns.patternCount() + 1): if strip_pattern_name(patterns.getPatternName(i)) == name: patterns.jumpToPattern(i) return # No pattern found patterns.deselectAll()
def OnTrackWrite(self, event): debug.log('OnTrackWrite', 'Dispatched', event=event) # Move to next pattern (move down pattern list) next = patterns.patternNumber() + 1 if next > patterns.patternCount(): return patterns.jumpToPattern(next)
def OnTrackRead(self, event): debug.log('OnTrackRead', 'Dispatched', event=event) # Move to previous pattern (move up pattern list) prev = patterns.patternNumber() - 1 if prev <= 0: return patterns.jumpToPattern(prev)
def _new_empty_pattern(self, linked=True): pattern_id = patterns.patternCount() + 1 if linked: pattern_name = arturia_playlist.next_pattern_name() color = channels.getChannelColor(channels.selectedChannel()) patterns.setPatternName(pattern_id, pattern_name) patterns.setPatternColor(pattern_id, color) patterns.jumpToPattern(pattern_id) patterns.selectPattern(pattern_id, 1) return pattern_id
def OnEncoderTempoDecreased(self, control, event): if self.controls.isButtonShiftPressed: transport.globalTransport(midi.FPT_TempoJog, -10) elif ui.getFocused(midi.widChannelRack): idx = channels.channelNumber(1) print(idx) if idx == -1: channels.selectChannel(channels.channelCount() - 1, 1) elif idx > 0: channels.deselectAll() channels.selectChannel(idx - 1, 1) elif ui.getFocused(midi.widPlaylist): idx = patterns.patternNumber() if idx > 1: # TODO figure out why patternNumber starts at one instead of zero! patterns.jumpToPattern(idx - 1) elif ui.getFocused(midi.widMixer): idx = mixer.trackNumber() if idx > 1: # do not include the master track (0) mixer.setTrackNumber(idx - 1)
def handleJog(self, encoder, event): display_message = '' display_value = None i = encoder.index jogmap = self.encoderJogs[controls.shift.value] if i in jogmap: target, display_message = jogmap[i] fpt.callFPT(target, encoder.value, event) direction = '>' if encoder.value > 0 else '<' display_message += ' ' + direction elif i == 4: selected_track = self.moveSelectedMixerTrack(encoder.value) display_message = mixer.getTrackName(selected_track) display_value = selected_track elif i == 5: selected_pattern = (patterns.patternNumber() + encoder.value) % patterns.patternMax() patterns.jumpToPattern(selected_pattern) display_message = patterns.getPatternName(selected_pattern) display_value = selected_pattern elif i == 6: group_channel_count = channels.channelCount(0) current_channel = channels.channelNumber(0) selected_group_index = self.cycleChannels( current=0, count=group_channel_count, condition_func=lambda c: channels.getChannelIndex( c) == current_channel) or 0 selected_index = (selected_group_index + encoder.value) % group_channel_count channels.deselectAll() channels.selectChannel(selected_index) display_message = channels.getChannelName(selected_index) display_value = selected_index self.lcdText(display_message) if display_value: self.lcdValueText(display_value)
def select_playlist_track_from_pattern(pattern_index): """Select the specified pattern""" name = get_playlist_track_name(pattern_index) _select_channel_from_name(name) _select_playlist_track_named(name) patterns.jumpToPattern(pattern_index)
def switch_moment(event): """handles momentary witch midi events""" if event.data1 == button["pad_mode_toggle"]: # This Rotates through pad modes - standard, step sequencer, pad to channel Switch.mode_toggle += 1 if Switch.mode_toggle == 4: Switch.mode_toggle = 0 print('Pad Mode: ' + mode[Switch.mode_toggle]) ui.setHintMsg(mode[Switch.mode_toggle]) elif event.midiId == 224: # pitch wheel Switch.pitch_num = event.data2 if Switch.shift_status == True: print(data.notes_list[int(mapvalues(Switch.pitch_num, 0, 11, 0, 244))]) elif event.data1 == button["play"]: transport.start() event.handled = True elif event.data1 == button["offset_range"]: Switch.offset_iter += 1 if Switch.offset_iter == 2: # 2 here will limit to 32 steps, knobs. Changing to 4 will allow up to 64 steps, knobs. Switch.offset_iter = 0 ui.setHintMsg("Offset Range: " + str(Switch.offset_iter)) elif event.data1 == button["stop"]: print('Stop') transport.stop() event.handled = True elif event.data1 == button["record"]: print('Record') transport.record() event.handled = True elif event.data1 == button["pattern_down"]: if ui.getFocused(5): print("Previous Preset") ui.previous() else: print('Pattern Down') transport.globalTransport(midi.FPT_PatternJog, -1) event.handled = True elif event.data1 == button["pattern_up"]: if ui.getFocused(5): print("Next Preset") ui.next() else: print('Pattern Up') transport.globalTransport(midi.FPT_PatternJog, 1) event.handled = True # Set mod wheel to control channels when channels focused and tracks when mixer elif event.data1 == button["mod_wheel"]: if ui.getFocused(0): mixer.setTrackNumber(int(mapvalues(event.data2, 0, 64, 0, 127))) ui.scrollWindow(midi.widMixer, mixer.trackNumber()) elif ui.getFocused(1): print("Channel Number: " + str(channels.selectedChannel())) channels.selectOneChannel(int(round(mapvalues(event.data2, channels.channelCount()-1, 0, 0, 127), 0))) elif event.data1 == 72: print(channels.getChannelColor(channels.selectedChannel())) Switch.color_num += 1 if Switch.color_num == len(colors): Switch.color_num = 0 if ui.getFocused(1): channels.setChannelColor(channels.selectedChannel(), colors[Switch.color_num]) elif ui.getFocused(0): mixer.setTrackColor(mixer.trackNumber(), colors[Switch.color_num]) event.handled = True elif event.data1 == button["enter"]: if ui.getFocused(4): print("Select Browser Item") ui.selectBrowserMenuItem() event.handled = True elif ui.getFocused(1): print("Mute Channel") channels.muteChannel(channels.selectedChannel()) elif ui.getFocused(0): print("Mute Track") mixer.muteTrack(mixer.trackNumber()) else: print('enter') ui.enter() event.handled = True elif event.data1 in range(59, 64) and config.PATTERN_JUMP_ON: # Sets jump to pattern patterns.jumpToPattern(event.data1 - 58) event.handled = True elif event.data1 in range(75, 80) and config.PATTERN_JUMP_ON: patterns.jumpToPattern(event.data1 - 69) event.handled = True elif event.data1 == button["solo"]: print('Solo') if ui.getFocused(0): mixer.soloTrack(mixer.trackNumber()) elif ui.getFocused(1): channels.soloChannel(channels.selectedChannel()) elif event.data1 == button["view_plugin_picker"]: print('View Plugin Picker') transport.globalTransport(midi.FPT_F8, 67) event.handled = True elif event.data1 == button["song_mode_toggle"]: print('Toggle Song and Pattern Mode') transport.setLoopMode() event.handled = True elif event.data1 == button["view_playlist"]: print('View Playlist') transport.globalTransport(midi.FPT_F5, 65) event.handled = True elif event.data1 == button["view_piano_roll"]: print('View Piano Roll') transport.globalTransport(midi.FPT_F7, 66) event.handled = True elif event.data1 == button["view_channel_rack"]: print('View Channel Rack') transport.globalTransport(midi.FPT_F6, 65) event.handled = True elif event.data1 == button["view_mixer"]: print('View Mixer') transport.globalTransport(midi.FPT_F9, 68) event.handled = True # Toggle through step parameter options - pitch, pan etc. No Shift control right now. elif event.data1 == button["step_parameter"]: if ui.getFocused(1) and Switch.mode_toggle == 1: print('Toggle Step Parameter') Switch.parameter += 1 if Switch.parameter == 7: Switch.parameter = 0 print(Switch.parameter) ui.setHintMsg(parameters[Switch.parameter]) elif ui.getFocused(0): Switch.mixer_num += 1 if Switch.mixer_num == 2: Switch.mixer_num = 0 print('Mixer Mode: ' + str(Switch.mixer_num)) ui.setHintMsg(mixer_choice[Switch.mixer_num]) event.handled = True elif event.data1 == button["open_channel_sampler"]: print('Open Sampler Channel') channels.showCSForm(channels.channelNumber(), -1) event.handled = True elif event.data1 == button["left"]: print('Left') ui.left() event.handled = True elif event.data1 == button["down"]: print('Down') ui.down() event.handled = True elif event.data1 == button["right"]: print('Right') ui.right() event.handled = True elif event.data1 == button["save"]: print('Save') transport.globalTransport(midi.FPT_Save, 92) # If mixer is open and mute mode selected, top row will mute respective track elif event.data1 == button["undo"]: print('Undo') transport.globalTransport(midi.FPT_Undo, 20) device.midiOutMsg(144, 1, 63, 80) event.handled = True elif event.data1 == button["escape"]: print('Escape') ui.escape() event.handled = True elif event.data1 == button["up"]: print('Up') ui.up() event.handled = True elif event.data1 == button["rotate_window"]: print('Rotate Window') ui.nextWindow() event.handled = True elif event.data1 == button["browser"]: print('Browser') if Switch.shift_status == False: if ui.getFocused(4): ui.hideWindow(4) event.handled = True else: ui.showWindow(4) ui.setFocused(4) event.handled = True elif event.data1 == button["step_rec"]: if ui.getFocused(0): mixer.armTrack(mixer.trackNumber()) print("Toggle Track Rec") else: transport.globalTransport(midi.FPT_StepEdit, 114) print('Step Record') event.handled = True elif event.data1 == button["quantize"]: print('quantize') channels.quickQuantize(channels.channelNumber()) event.handled = True elif event.data1 == button["link_chan"]: print('link channel') mixer.linkTrackToChannel(0) elif event.data1 == button["rand_steps"]: print("Random") print(f'Pitch Bend: {event.pitchBend}') for i in range(patterns.getPatternLength(patterns.patternNumber())): channels.setGridBit(channels.channelNumber(), i, 0) for z in range (patterns.getPatternLength(patterns.patternNumber())): y = num_gen() if y > ( Switch.pitch_num * 516): channels.setGridBit(channels.channelNumber(), z, 1) else: pass event.handled = True elif event.data1 == button["rand_notes"]: print("Randomize Notes") Switch.note_gen() event.handled = True
def _new_empty_pattern(self): pattern_id = patterns.patternCount() + 1 patterns.setPatternName(pattern_id, 'Pattern %d' % pattern_id) patterns.jumpToPattern(pattern_id) patterns.selectPattern(pattern_id, 1) return pattern_id
def OnUpdatePattern(self, delta): index = self.clip(1, patterns.patternCount(), patterns.patternNumber() + delta) patterns.jumpToPattern(index)
def set_pattern(n): if type(n) is str and n.isdigit(): n = int(n) if type(n) is int: patterns.jumpToPattern(n) print("set_pattern:", n)