def handle_knob_change(self, event, knob, value): """ Put knob change code here. """ self.selected_channel = channels.selectedChannel() # Mixer Focused if (ui.getFocused(midi.widMixer) == 1): if knob.number != 1: offset = knob.number - 2 trackNum = helpers.getMixerTrackNum() helpers.mixerAdjustPan(trackNum + offset, event.data2) else: helpers.mixerAdjustPan(0, event.data2) event.handled = True # Everything else else: if knob.number == 1: ui.showWindow(midi.widChannelRack) ui.setFocused(midi.widChannelRack) helpers.channelAdjustPan(self.selected_channel, event.data2) elif knob.number == 2: ui.showWindow(midi.widChannelRack) ui.setFocused(midi.widChannelRack) helpers.channelAdjustVolume(self.selected_channel, event.data2) print("Changed knob " + str(knob.number) + " to " + str(value) + ".")
def _toggle_visibility(self, window): if not ui.getVisible(window): ui.showWindow(window) ui.setFocused(window) return True else: ui.hideWindow(window) return False
def toggle_browser_visibility(unused_param_value): """Toggle browser""" if PYKEYS_ENABLED: Actions.fl_windows_shortcut('f8', alt=1) else: if ui.getVisible(midi.widBrowser): ui.hideWindow(midi.widBrowser) else: ui.showWindow(midi.widBrowser) ui.setFocused(midi.widBrowser)
def add_time_marker(unused_param_value): """Add time marker""" window_active = ui.getVisible(midi.widPianoRoll) and ui.getFocused( midi.widPianoRoll) window_active |= ui.getVisible(midi.widPlaylist) and ui.getFocused( midi.widPlaylist) if not window_active: window = midi.widPlaylist if transport.getLoopMode( ) else midi.widPianoRoll ui.showWindow(window) ui.setFocused(window) Actions.fl_windows_shortcut('t', ctrl=1)
def _open_app_menu(): # FPT_Menu needs to be triggered when channel rack in focus in order to bring up the app menu. # Save the visibility state of the channel rack and restore at the end. ui.closeActivePopupMenu() channel_rack_visible = ui.getVisible(midi.widChannelRack) # Need to reset focus state of channel rack to ensure menu brought up ui.hideWindow(midi.widChannelRack) ui.showWindow(midi.widChannelRack) ui.setFocused(midi.widChannelRack) transport.globalTransport(midi.FPT_Menu, 1) if not channel_rack_visible: ui.hideWindow(midi.widChannelRack) # Give some time for popup to appear time.sleep(0.2) timeout_time = time.monotonic() + 1 # Avoid exceed waiting more than 1 second while not ui.isInPopupMenu() and time.monotonic() < timeout_time: time.sleep(0.05)
def handle_slider_change(self, event, slider, value): """ Put slider change code here. """ # Sliders 2-6 ui.showWindow(midi.widMixer) ui.setFocused(midi.widMixer) if slider.number != 1: offset = slider.number - 2 trackNum = helpers.getMixerTrackNum() helpers.mixerAdjustFader(trackNum + offset, event.data2) # Slider 1 always controls the master mixer volume else: helpers.mixerAdjustFader(0, event.data2) print("Changed slider " + str(slider.number) + " to " + str(value) + ".") #self.set_hint_message(self.output) event.handled = True
def _show_and_focus(self, window): ui.showWindow(window) ui.setFocused(window)
def _toggle_window_visibility(self, window): if ui.getVisible(window): ui.hideWindow(window) else: ui.showWindow(window) ui.setFocused(window)
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 handle_pad_press(self, event, pad): """ Put pad press code here. """ # CHANNEL RACK OMNI MODE if pad.bank == 'a': ui.showWindow(midi.widChannelRack) ui.setFocused(midi.widChannelRack) helpers.channelMidiNoteOn((pad.number - 1), 60, event) helpers.channelSelect(pad.number - 1) event.handled = True # FPC MODE elif pad.bank == 'b': # Check if there is an FPC instance pad_note = self.pads_fpc_note_map[pad.number] event.data1 = pad_note event.handled = False # Chromatic Mode elif pad.bank == 'c': if pad.number == 15: if self.octave >= 0: self.octave -= 1 self.output = 'Octave Shift: ' + str(self.octave) event.handled = True elif pad.number == 16: if self.octave <= 8: self.octave += 1 self.output = 'Octave Shift: ' + str(self.octave) event.handled = True else: pad_note = self.pads_chromatic_note_map[pad.number] pad_note_shifted_on = (12 * self.octave) + (12 + pad_note) event.data1 = pad_note_shifted_on event.handled = False # Function Mode (use pads to control the ui functions) elif pad.bank == 'd': if pad.number == 1: # enter button transport.globalTransport(midi.FPT_Enter, 80, event.pmeFlags - 1) self.output = 'Enter' elif pad.number == 2: # escape button transport.globalTransport(midi.FPT_Escape, 81, event.pmeFlags - 1) self.output = 'Escape' elif pad.number == 3: # cut button transport.globalTransport(midi.FPT_Cut, 2, event.pmeFlags - 1) self.output = 'Cut' elif pad.number == 4: print('menu') transport.globalTransport(midi.FPT_ItemMenu, 91) # Edison is focused if ui.getFocusedPluginName() == 'Edison': transport.globalTransport(midi.FPT_AddMarker, 33, event.pmeFlags - 1) self.output = 'Set Marker' # Default else: self.output = 'unasigned' elif pad.number == 5: # song/pattern transport.globalTransport(midi.FPT_Loop, 15, event.pmeFlags - 1) self.output = 'Toggle: Song/Pattern' elif pad.number == 6: # metronome transport.globalTransport(midi.FPT_Metronome, 112, event.pmeFlags - 1) self.output = 'Toggle: Metronome' elif pad.number == 7: # overdub transport.globalTransport(midi.FPT_Overdub, 112, event.pmeFlags - 1) self.output = 'Toggle: Overdub' elif pad.number == 8: # loop record transport.globalTransport(midi.FPT_LoopRecord, 113, event.pmeFlags - 1) self.output = 'Toggle: Loop Record' elif pad.number == 9: # open mixer ui.showWindow(midi.widMixer) ui.setFocused(midi.widMixer) self.output = 'Open: Mixer' elif pad.number == 10: # plugin picker transport.globalTransport(midi.FPT_F8, 67, event.pmeFlags - 1) elif pad.number == 11: # Browser - there is a bug and this doesn't work ui.setFocused(midi.widBrowser) self.output = 'Open: File Browser' elif pad.number == 12: # down ui.down() self.output = 'Down' elif pad.number == 13: # playlist view transport.globalTransport(midi.FPT_F5, 64, event.pmeFlags - 1) self.output = 'Open: Playlist' elif pad.number == 14: # open piano roll transport.globalTransport(midi.FPT_F7, 66, event.pmeFlags - 1) self.output = 'Open: Piano Roll' elif pad.number == 15: # open channel rack # transport.globalTransport(midi.FPT_F6, 65, event.pmeFlags-1) ui.showWindow(midi.widChannelRack) ui.setFocused(midi.widChannelRack) self.output = 'Open: Channel Rack' elif pad.number == 16: # up button ui.up() self.output = 'Up' event.handled = True print("Pressed pad " + str(pad.number) + ".") self.set_hint_message(self.output)
def _show_and_focus(self, window): if not ui.getVisible(window): ui.showWindow(window) if not ui.getFocused(window): ui.setFocused(window)
def clone_channel(unused_param_value): """Clone channel""" ui.showWindow(midi.widChannelRack) ui.setFocused(midi.widChannelRack) Actions.fl_windows_shortcut('c', alt=1)