def processMuteSolo(track, command): if command.value == 0: return if mixer.isTrackSolo(track): mixer.soloTrack(track) command.actions.appendAction("Unsolo track " + str(track)) return mixer.muteTrack(track) if command.is_double_click: mixer.soloTrack(track) command.actions.appendAction("Solo track " + str(track)) else: if mixer.isTrackMuted(track): command.actions.appendAction("Mute track " + str(track)) else: command.actions.appendAction("Unmute track " + str(track))
def mixerMuteSoloHandler(action: str, targetTrack: int, selectedTrack: int): """ Handles the way mixer and solo commands are sent from S-Series keyboards. ### Parameters - action: MUTE or SOLO. - targetTrack: From 0 to 7, the track that the user is trying to mute or solo from the ones showing on the device's mixer. - selectedTrack: The currently selected track that is used to calculate the track group. """ # Uses the function to know which track group the current track belongs to and truncates the value to get the exact number trackGroup = math.trunc(1 / 8 * selectedTrack) # Multiplies the trackGroup to 8 to get the index of the first track that has to be shown trackFirst = trackGroup * 8 # Adjusts the correct property of the right track if action == "MUTE": mixer.muteTrack(trackFirst + targetTrack) if action == "SOLO": mixer.soloTrack(trackFirst + targetTrack)
def actionButton(self, event, FoundButton): #Action to Button (wiht my Index FoundButton[2]) global goTo global Tog_TP global Tog_Steps global StepsPerTick global lsSPT_Values global SPT_IDX snapVal = 7 def goRight(steps): #Selection go steps to the rigeht sight of Mixer sEnd = " " global goTo #Warum hier global und in goSteps nicht? lastgoTo = goTo if goTo + NK_NrOf_ControlGr + steps < FL_TR_COUNT_MAX: goTo = goTo + steps #print("right") else: goTo = FL_TR_COUNT_MAX - NK_NrOf_ControlGr sEnd = "END of Mixer (right)! - " #wird mir goTo nie überschritten sHi_MixTR_Range = sEnd + "Mix-Tracks " + str(goTo) + "-" + str( NK_NrOf_ControlGr + goTo - 1) #activ HintMsg Track area ui.setHintMsg(sHi_MixTR_Range) if lastgoTo != goTo: resetTrackName(event, lastgoTo) selectActivArea(goTo) event.handled = True def goLeft(steps): #Selection go steps to the left sight of Mixer sEnd = " " global goTo lastgoTo = goTo if goTo > steps - 1: goTo = goTo - steps #print("left") else: goTo = 0 sEnd = "END of Mixer (left)! - " sHi_MixTR_Range = sEnd + "Mix-Tracks " + str(goTo) + "-" + str( NK_NrOf_ControlGr + goTo - 1) #activ HintMsg Track area ui.setHintMsg(sHi_MixTR_Range) if lastgoTo != goTo: resetTrackName(event, lastgoTo) selectActivArea(goTo) if FoundButton[2] == 2: #8 to left goLeft(NK_NrOf_ControlGr) elif FoundButton[2] == 3: #8 to right goRight(NK_NrOf_ControlGr) elif FoundButton[2] == 4: #reset ui.showWindow(midi.widMixer) resetAllName() event.handled = True #sonst knallt es elif FoundButton[2] == 5: #set stepswide ### Könnte ich dazu verwenden um einen Track fest zu zu ordnen if Tog_Steps and SPT_IDX < len(lsSPT_Values): SPT_IDX += 1 if SPT_IDX == (len(lsSPT_Values) - 1): Tog_Steps = not Tog_Steps #max 7 per Ticker, Toggel betwenn Up/down elif SPT_IDX > 0: SPT_IDX -= 1 if SPT_IDX == 0: Tog_Steps = not Tog_Steps #max 7 per Ticker else: print("Error: Step-Counter") StepsPerTick = lsSPT_Values[SPT_IDX] ui.setHintMsg("set " + str(lsSPT_Values[SPT_IDX]) + " steps") event.handled = True time.sleep(ST_HintMsg) elif FoundButton[2] == 6: #StepsPerTick) to left goLeft(StepsPerTick) elif FoundButton[2] == 7: #StepsPerTick) to right goRight(StepsPerTick) elif FoundButton[2] == 8: #TP Rew if Tog_TP: transport.rewind(2) else: transport.rewind(0) Tog_TP = not Tog_TP event.handled = True elif FoundButton[2] == 9: #TP FF if Tog_TP: transport.fastForward(2) else: transport.fastForward(0) Tog_TP = not Tog_TP event.handled = True elif FoundButton[2] == 10: #TP stop if Tog_TP: transport.fastForward(2) transport.stop() event.handled = True elif FoundButton[2] == 11: #TP play transport.start() event.handled = True elif FoundButton[2] == 12: #TP rec if bPrintAction: print("TP rec ", FoundButton[1], " Wert: ", FoundButton[4]) transport.record() event.handled = True elif FoundButton[2] in lsKnob: #Paning nMixTrIndex = FoundButton[3] - (NK_CC_Knob_First ) #36to43-35=MixTrackIdx in FL nMixTrPan = (1 / 64) * (FoundButton[4] - 63 ) # max Pan. FL=-1.0 - 1.0 (0-127 steps) FL_Pan = int(mixer.getTrackPan(nMixTrIndex + goTo) * 64) #Only change the value if the position of the controller matches the FL value. To avoid jumps if FoundButton[4] - 63 in range(FL_Pan - snapVal, FL_Pan + snapVal) and Reg_Snap: mixer.setTrackPan(nMixTrIndex + goTo, nMixTrPan) #Set Paning if Reg_Snap == False: mixer.setTrackPan(nMixTrIndex + goTo, nMixTrPan) #Set Paning selectActivMixTrack(nMixTrIndex + goTo) event.handled = True elif FoundButton[2] in lsSld: #Volume nMixTrIndex = FoundButton[3] - (NK_CC_SLider_First ) #36to43-35=MixTrackIdx in FL nMixTrVolu = (1 / 127) * FoundButton[ 4] # max Vol. FL=1.0 / max Vol. nK2=127, event.data2=Value from nK2-Slider FL_Vol = int(mixer.getTrackVolume(nMixTrIndex + goTo) * 127) #Only change the value if the position of the controller matches the FL value. To avoid jumps if FoundButton[4] in range(FL_Vol - snapVal, FL_Vol + snapVal) and Reg_Snap: mixer.setTrackVolume(nMixTrIndex + goTo, nMixTrVolu) #Set Vol if Reg_Snap == False: mixer.setTrackVolume(nMixTrIndex + goTo, nMixTrVolu) #Set Vol selectActivMixTrack(nMixTrIndex + goTo) event.handled = True elif FoundButton[2] in lsSoloB: #Solo-Button nMixTrIndex = FoundButton[3] + NK_Solo_But_First selectActivMixTrack(nMixTrIndex + goTo) mixer.soloTrack(nMixTrIndex + goTo) # event.handled = True elif FoundButton[2] in lsMuteB: #Mute-Button nMixTrIndex = FoundButton[3] - (NK_Mute_But_First ) #36to43-35=MixTrackIdx in FL mixer.muteTrack(nMixTrIndex + goTo) # selectActivMixTrack(nMixTrIndex + goTo) event.handled = True elif FoundButton[2] in lsRecB: #Rec-Button nMixTrIndex = FoundButton[3] - (NK_Rec_But_First ) #72to73-71=MixTrackIdx in FL mixer.armTrack(nMixTrIndex + goTo) # selectActivMixTrack(nMixTrIndex + goTo) event.handled = True
def mixerToggleMute(selectedTrackNum): mixer.muteTrack(selectedTrackNum) if mixer.isTrackMuted(selectedTrackNum) == 1: return "Mixer: Mute track: " + getMixerTrackName(selectedTrackNum) else: return "Mixer: Unmute track: " + getMixerTrackName(selectedTrackNum)
def OnMidiIn(event): """ Wrapper for the OnMidiIn thread. """ # Play button if event.data1 == nihia.buttons.get("PLAY"): event.handled = True transport.start() # Restart button elif event.data1 == nihia.buttons.get("RESTART"): event.handled = True transport.setLoopMode() # Record button elif event.data1 == nihia.buttons.get("REC"): event.handled = True transport.record() # Count-In button elif event.data1 == nihia.buttons.get("COUNT_IN"): event.handled = True # Defines the standard behaviour (just to toggle "Countdown before recording" on/off) if COUNT_IN_BEHAVIOUR == 0: transport.globalTransport(midi.FPT_CountDown, 1) # Defines behaviour of the button if the user chooses the Maschine-alike behaviour if COUNT_IN_BEHAVIOUR == 1: # Toggles recording on if it isn't enabled already if transport.isRecording() == 0: transport.record() # Toggles countdown before recording on if it isn't enabled already if ui.isPrecountEnabled() == 0: transport.globalTransport(midi.FPT_CountDown, 1) # Stops playback if FL Studio is playing if transport.isPlaying() == True: transport.stop() # Then turns playback on again. This time record and countdown before recording will be activated transport.start() # Stop button elif event.data1 == nihia.buttons.get("STOP"): event.handled = True transport.stop() # Clear button # This one in other DAWs (in Maschine, specifically) this button is meant to clear the MIDI clip you're # on so you can record again on it without having to use a mouse to delete all of the notes on the clip before # recording again # # However, since the MIDI API on FL Studio doesn't allow control over the piano roll specifically, for now it will only just # emulate the delete button (which does the same) elif event.data1 == nihia.buttons.get("CLEAR"): event.handled = True ui.delete() # Loop button (toggles loop recording on/off) elif event.data1 == nihia.buttons.get("LOOP"): event.handled = True transport.globalTransport(midi.FPT_LoopRecord, 1) # Metronome button elif event.data1 == nihia.buttons.get("METRO"): event.handled = True transport.globalTransport(midi.FPT_Metronome, 1) # Tempo button elif event.data1 == nihia.buttons.get("TEMPO"): event.handled = True transport.globalTransport(midi.FPT_TapTempo, 1) # Undo button elif event.data1 == nihia.buttons.get("UNDO"): event.handled = True general.undoUp() # Redo button elif event.data1 == nihia.buttons.get("REDO"): event.handled = True general.undo() # Quantize button # TODO: Not imlpemented yet in FL Studio MIDI API # # Instead, it changes between FL windows # TODO: The code is correctly written, but the ui.showWindow() method has a bug that causes the Piano roll and Browser windows not to # appear when invoked. It has been said it should be fixed in a future update. # ----------------------------------------------------------------------------------------------------------------------------------- # if event.data1 == nihia.buttons.get("QUANTIZE"): # global window # window += 1 # if window <= 4: # ui.showWindow(window) # print("if reached") # elif window > 4: # window = 0 # ui.showWindow(window) # ----------------------------------------------------------------------------------------------------------------------------------- # # Alternative implementation: Emulate the Fn buttons elif event.data1 == nihia.buttons.get("QUANTIZE"): event.handled = True global window2 window2 += 1 # Normal behaviour if the action ID is between the desired range if window2 <= 68 and window2 != 67: transport.globalTransport(window2, 1) # Skips the 67 value which calls the full screen plugin picker and calls the mixer instead elif window2 == 67: window2 += 1 transport.globalTransport(window2, 1) # Once window value is out of range, it sets it again to the first value in range elif window2 > 68: window2 = 64 transport.globalTransport(window2, 1) # Automation button # Enables and disables the recording automation events # TODO: Not implemented yet in FL Studio MIDI API # # Instead, it shows the full-screen plugin browser elif event.data1 == nihia.buttons.get("AUTO"): event.handled = True transport.globalTransport(midi.FPT_F8, 1) # Mute button - A-Series elif event.data1 == nihia.buttons.get("MUTE_SELECTED"): event.handled = True mixer.muteTrack(mixer.trackNumber()) # Solo button - A-Series elif event.data1 == nihia.buttons.get("SOLO_SELECTED"): event.handled = True mixer.soloTrack(mixer.trackNumber()) # Mute button - S-Series elif event.data1 == nihia.buttons.get("MUTE"): event.handled = True mixerMuteSoloHandler("MUTE", event.data2, mixer.trackNumber()) # Solo button - S-Series elif event.data1 == nihia.buttons.get("SOLO"): event.handled = True mixerMuteSoloHandler("SOLO", event.data2, mixer.trackNumber()) # 4D Encoder + elif event.data1 == nihia.buttons.get( "ENCODER_GENERAL") and event.data2 == nihia.buttons.get("PLUS"): event.handled = True # Mixer navigation (right) if ui.getFocused(midi.widMixer) == True: ui.right() # Playback jogging elif (ui.getFocused(midi.widPianoRoll) == True) or (ui.getFocused( midi.widPlaylist) == True): transport.setSongPos( transport.getSongPos(midi.SONGLENGTH_S) + 1, midi.SONGLENGTH_S) # General navigation else: ui.down() # 4D Encoder - elif event.data1 == nihia.buttons.get( "ENCODER_GENERAL") and event.data2 == nihia.buttons.get("MINUS"): event.handled = True # Mixer navigation if ui.getFocused(midi.widMixer) == True: ui.left() elif (ui.getFocused(midi.widPianoRoll) == True) or (ui.getFocused( midi.widPlaylist) == True): transport.setSongPos( transport.getSongPos(midi.SONGLENGTH_S) - 1, midi.SONGLENGTH_S) # General navigation else: ui.up() # 4D Encoder + (selected track volume) elif event.data1 == nihia.buttons.get( "ENCODER_VOLUME_SELECTED") and event.data2 == nihia.buttons.get( "PLUS"): event.handled = True mixer.setTrackVolume(mixer.trackNumber(), mixer.getTrackVolume(mixer.trackNumber()) + 0.01) # 4D Encoder - (selected track volume) elif event.data1 == nihia.buttons.get( "ENCODER_VOLUME_SELECTED") and event.data2 == nihia.buttons.get( "MINUS"): event.handled = True mixer.setTrackVolume(mixer.trackNumber(), mixer.getTrackVolume(mixer.trackNumber()) - 0.01) # 4D Encoder + (selected track pan) elif event.data1 == nihia.buttons.get( "ENCODER_PAN_SELECTED") and event.data2 == nihia.buttons.get( "PLUS"): event.handled = True mixer.setTrackPan(mixer.trackNumber(), mixer.getTrackPan(mixer.trackNumber()) + 0.01) # 4D Encoder + (selected track pan) elif event.data1 == nihia.buttons.get( "ENCODER_PAN_SELECTED") and event.data2 == nihia.buttons.get( "MINUS"): event.handled = True mixer.setTrackPan(mixer.trackNumber(), mixer.getTrackPan(mixer.trackNumber()) - 0.01) # 4D Encoder up elif event.data1 == encoderHandler( "Y") and event.data2 == nihia.buttons.get("UP"): event.handled = True ui.up() # 4D Encoder down elif event.data1 == encoderHandler( "Y") and event.data2 == nihia.buttons.get("DOWN"): event.handled = True ui.down() # 4D Encoder (using FPT because ui.left doesn't work on the playlist) elif event.data1 == encoderHandler( "X") and event.data2 == nihia.buttons.get("LEFT"): event.handled = True if ui.getFocused(midi.widMixer) == True: # This one doesn't move the mixer view as you get to the border # ---------------------------------------------------- # mixer.setTrackNumber(mixer.trackNumber() - 1) # ---------------------------------------------------- ui.left() else: ui.left() # 4D Encoder (using FPT because ui.right doesn't work on the playlist) elif event.data1 == encoderHandler( "X") and event.data2 == nihia.buttons.get("RIGHT"): event.handled = True if ui.getFocused(midi.widMixer) == True: # This one doesn't move the mixer view as you get to the border # ---------------------------------------------------- # mixer.setTrackNumber(mixer.trackNumber() + 1) # ---------------------------------------------------- ui.right() else: ui.right() # 4D Encoder button elif event.data1 == nihia.buttons.get("ENCODER_BUTTON"): event.handled = True ui.enter() # 4D Encoder button (shifted) elif event.data1 == nihia.buttons.get("ENCODER_BUTTON_SHIFTED"): event.handled = True transport.globalTransport(midi.FPT_Menu, 1) # Knobs # Normal knobs - increase values elif event.data1 == nihia.knobs.get( "KNOB_1A") and event.data2 == nihia.knobs.get("INCREASE"): event.handled = True adjustMixer(0, "VOLUME", "INCREASE", mixer.trackNumber()) elif event.data1 == nihia.knobs.get( "KNOB_2A") and event.data2 == nihia.knobs.get("INCREASE"): event.handled = True adjustMixer(1, "VOLUME", "INCREASE", mixer.trackNumber()) elif event.data1 == nihia.knobs.get( "KNOB_3A") and event.data2 == nihia.knobs.get("INCREASE"): event.handled = True adjustMixer(2, "VOLUME", "INCREASE", mixer.trackNumber()) elif event.data1 == nihia.knobs.get( "KNOB_4A") and event.data2 == nihia.knobs.get("INCREASE"): event.handled = True adjustMixer(3, "VOLUME", "INCREASE", mixer.trackNumber()) elif event.data1 == nihia.knobs.get( "KNOB_5A") and event.data2 == nihia.knobs.get("INCREASE"): event.handled = True adjustMixer(4, "VOLUME", "INCREASE", mixer.trackNumber()) elif event.data1 == nihia.knobs.get( "KNOB_6A") and event.data2 == nihia.knobs.get("INCREASE"): event.handled = True adjustMixer(5, "VOLUME", "INCREASE", mixer.trackNumber()) elif event.data1 == nihia.knobs.get( "KNOB_7A") and event.data2 == nihia.knobs.get("INCREASE"): event.handled = True # Handles track group 15 exception if math.trunc(1 / 8 * mixer.trackNumber()) == 15: return else: adjustMixer(6, "VOLUME", "INCREASE", mixer.trackNumber()) elif event.data1 == nihia.knobs.get( "KNOB_8A") and event.data2 == nihia.knobs.get("INCREASE"): event.handled = True # Handles track group 15 exception if math.trunc(1 / 8 * mixer.trackNumber()) == 15: return else: adjustMixer(7, "VOLUME", "INCREASE", mixer.trackNumber()) # Normal knobs - decrease values elif event.data1 == nihia.knobs.get( "KNOB_1A") and event.data2 == nihia.knobs.get("DECREASE"): event.handled = True adjustMixer(0, "VOLUME", "DECREASE", mixer.trackNumber()) elif event.data1 == nihia.knobs.get( "KNOB_2A") and event.data2 == nihia.knobs.get("DECREASE"): event.handled = True adjustMixer(1, "VOLUME", "DECREASE", mixer.trackNumber()) elif event.data1 == nihia.knobs.get( "KNOB_3A") and event.data2 == nihia.knobs.get("DECREASE"): event.handled = True adjustMixer(2, "VOLUME", "DECREASE", mixer.trackNumber()) elif event.data1 == nihia.knobs.get( "KNOB_4A") and event.data2 == nihia.knobs.get("DECREASE"): event.handled = True adjustMixer(3, "VOLUME", "DECREASE", mixer.trackNumber()) elif event.data1 == nihia.knobs.get( "KNOB_5A") and event.data2 == nihia.knobs.get("DECREASE"): event.handled = True adjustMixer(4, "VOLUME", "DECREASE", mixer.trackNumber()) elif event.data1 == nihia.knobs.get( "KNOB_6A") and event.data2 == nihia.knobs.get("DECREASE"): event.handled = True adjustMixer(5, "VOLUME", "DECREASE", mixer.trackNumber()) elif event.data1 == nihia.knobs.get( "KNOB_7A") and event.data2 == nihia.knobs.get("DECREASE"): event.handled = True # Handles track group 15 exception if math.trunc(1 / 8 * mixer.trackNumber()) == 15: return else: adjustMixer(6, "VOLUME", "DECREASE", mixer.trackNumber()) elif event.data1 == nihia.knobs.get( "KNOB_8A") and event.data2 == nihia.knobs.get("DECREASE"): event.handled = True # Handles track group 15 exception if math.trunc(1 / 8 * mixer.trackNumber()) == 15: return else: adjustMixer(7, "VOLUME", "DECREASE", mixer.trackNumber()) # Shifted knobs - increase values elif event.data1 == nihia.knobs.get( "KNOB_1B") and event.data2 == nihia.knobs.get("INCREASE"): event.handled = True adjustMixer(0, "PAN", "INCREASE", mixer.trackNumber()) elif event.data1 == nihia.knobs.get( "KNOB_2B") and event.data2 == nihia.knobs.get("INCREASE"): event.handled = True adjustMixer(1, "PAN", "INCREASE", mixer.trackNumber()) elif event.data1 == nihia.knobs.get( "KNOB_3B") and event.data2 == nihia.knobs.get("INCREASE"): event.handled = True adjustMixer(2, "PAN", "INCREASE", mixer.trackNumber()) elif event.data1 == nihia.knobs.get( "KNOB_4B") and event.data2 == nihia.knobs.get("INCREASE"): event.handled = True adjustMixer(3, "PAN", "INCREASE", mixer.trackNumber()) elif event.data1 == nihia.knobs.get( "KNOB_5B") and event.data2 == nihia.knobs.get("INCREASE"): event.handled = True adjustMixer(4, "PAN", "INCREASE", mixer.trackNumber()) elif event.data1 == nihia.knobs.get( "KNOB_6B") and event.data2 == nihia.knobs.get("INCREASE"): event.handled = True adjustMixer(5, "PAN", "INCREASE", mixer.trackNumber()) elif event.data1 == nihia.knobs.get( "KNOB_7B") and event.data2 == nihia.knobs.get("INCREASE"): event.handled = True # Handles track group 15 exception if math.trunc(1 / 8 * mixer.trackNumber()) == 15: return else: adjustMixer(6, "PAN", "INCREASE", mixer.trackNumber()) elif event.data1 == nihia.knobs.get( "KNOB_8B") and event.data2 == nihia.knobs.get("INCREASE"): event.handled = True # Handles track group 15 exception if math.trunc(1 / 8 * mixer.trackNumber()) == 15: return else: adjustMixer(7, "PAN", "INCREASE", mixer.trackNumber()) # Shifted knobs - decrease values elif event.data1 == nihia.knobs.get( "KNOB_1B") and event.data2 == nihia.knobs.get("DECREASE"): event.handled = True adjustMixer(0, "PAN", "DECREASE", mixer.trackNumber()) elif event.data1 == nihia.knobs.get( "KNOB_2B") and event.data2 == nihia.knobs.get("DECREASE"): event.handled = True adjustMixer(1, "PAN", "DECREASE", mixer.trackNumber()) elif event.data1 == nihia.knobs.get( "KNOB_3B") and event.data2 == nihia.knobs.get("DECREASE"): event.handled = True adjustMixer(2, "PAN", "DECREASE", mixer.trackNumber()) elif event.data1 == nihia.knobs.get( "KNOB_4B") and event.data2 == nihia.knobs.get("DECREASE"): event.handled = True adjustMixer(3, "PAN", "DECREASE", mixer.trackNumber()) elif event.data1 == nihia.knobs.get( "KNOB_5B") and event.data2 == nihia.knobs.get("DECREASE"): event.handled = True adjustMixer(4, "PAN", "DECREASE", mixer.trackNumber()) elif event.data1 == nihia.knobs.get( "KNOB_6B") and event.data2 == nihia.knobs.get("DECREASE"): event.handled = True adjustMixer(5, "PAN", "DECREASE", mixer.trackNumber()) elif event.data1 == nihia.knobs.get( "KNOB_7B") and event.data2 == nihia.knobs.get("DECREASE"): event.handled = True # Handles track group 15 exception if math.trunc(1 / 8 * mixer.trackNumber()) == 15: return else: adjustMixer(6, "PAN", "DECREASE", mixer.trackNumber()) elif event.data1 == nihia.knobs.get( "KNOB_8B") and event.data2 == nihia.knobs.get("DECREASE"): event.handled = True # Handles track group 15 exception if math.trunc(1 / 8 * mixer.trackNumber()) == 15: return else: adjustMixer(7, "PAN", "DECREASE", mixer.trackNumber())
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 mute(self, value=-1): mixer.muteTrack(self.index, value)
def OnMidiMsg(event): global trackOffset, soloStates event.handled = False #print(event.midiId, event.data1, event.data2, event.status, event.note, event.progNum, event.controlNum, event.controlVal) if event.midiId == potInput: if event.data1 in faderInputs: trackNum = faderInputs.index(event.data1) + trackOffset if trackNum <= realTrackCount: mixer.setTrackVolume(trackNum, constrain(event.data2, 0.8, 127)) #print("fader input") event.handled = True elif event.data1 == masterFader: mixer.setTrackVolume(0, constrain(event.data2, 0.8, 127)) #print("master input") event.handled = True elif event.data1 in panInputs: trackNum = panInputs.index(event.data1) + trackOffset if trackNum <= realTrackCount: mixer.setTrackPan(trackNum, constrainPan(event.data2)) #print("pan input") event.handled = True elif event.data1 == LEDknob: if event.data2 in LED1s: print("LEDmode 1") LED1() elif event.data2 in LED2s: print("LEDmode 2") LED2() elif event.data2 in LED3s: print("LEDmode 3") LED3() elif event.data2 in LED4s: print("LEDmode 4") LED4() elif event.midiId == buttonPress: # process input if event.data1 == bankLeft: device.midiOutMsg(midi.MIDI_NOTEON + (25 << 8) + (0 << 16)) event.handled = True if trackOffset > 1: trackOffset = trackOffset - 8 setTrackData() #print("left", trackOffset) elif event.data1 == bankRight: device.midiOutMsg(midi.MIDI_NOTEON + (26 << 8) + (0 << 16)) event.handled = True if trackOffset < (realTrackCount - (realTrackCount % 8) + 1): trackOffset = trackOffset + 8 setTrackData() #print("right", trackOffset) elif event.data1 in muteButtons: trackNum = muteButtons.index(event.data1) + trackOffset if trackNum <= realTrackCount: mixer.muteTrack(trackNum) #print("mute") event.handled = True elif event.data1 in soloButtons: if useNormalSolo: trackNum = soloButtons.index(event.data1) + trackOffset if trackNum <= realTrackCount: mixer.soloTrack(trackNum) #print("solo") event.handled = True else: index = soloButtons.index(event.data1) if soloStates[index] == 1: event.midiId = potInput event.status = potInput event.velocity = 0 event.controlVal = 0 soloStates[index] = 0 else: event.midiId = potInput event.status = potInput event.velocity = 127 event.controlVal = 127 soloStates[index] = 1 event.handled = False updateLEDs() elif event.data1 in armButtons: trackNum = armButtons.index(event.data1) + trackOffset if trackNum <= realTrackCount: mixer.armTrack(trackNum) #print("arm") event.handled = True elif event.data1 == soloSwitch: event.handled = True # visual feedback elif event.midiId == buttonPress: event.handled = True if event.data1 == bankLeft: device.midiOutMsg(midi.MIDI_NOTEON + (25 << 8) + (127 << 16)) elif event.data1 == bankRight: device.midiOutMsg(midi.MIDI_NOTEON + (26 << 8) + (127 << 16))