def pad_hit(event): if event.midiId == 144: temp_step.clear() temp_step.append(event.data1 + offset[Switch.offset_iter]) if ui.getFocused(5) and plugins.isValid(channels.selectedChannel()): if event.midiId == 128 and event.data2 != 0: print('skip') elif plugins.getPluginName(channels.selectedChannel()) == 'FPC' and event.data1 in alesis_pads: print('FPC') channels.midiNoteOn(channels.selectedChannel(), FPC_pads[alesis_pads.index(event.data1 + offset[Switch.offset_iter])], event.data2) event.handled = True elif Switch.mode_toggle == 1 and event.midiId == 144: if channels.getGridBit(channels.selectedChannel(), event.data1 - 60 + offset[Switch.offset_iter]) == 0: channels.setGridBit(channels.selectedChannel(), event.data1 - 60 + offset[Switch.offset_iter], 1) event.handled = True else: channels.setGridBit(channels.selectedChannel(), event.data1 - 60 + offset[Switch.offset_iter], 0) event.handled = True elif Switch.mode_toggle == 2 and 60 <= event.data1 < (channels.channelCount() + 60): channels.setChannelPitch(event.data1-60, mapvalues(Switch.pitch_num, -1, 1, 0, 127)) channels.selectOneChannel(event.data1-60) channels.midiNoteOn(event.data1-60, 60, event.data2, Switch.pitch_num) print('a pad has been hit') event.handled = True
def _num_effects(mixer_track_index): if SCRIPT_VERSION < 8: return 0 cnt = 0 for i in range(10): try: if plugins.isValid(mixer_track_index, i): cnt += 1 except: pass return cnt
def getTrackArmID(): #loop over all plugins (we take the channelCount because we can't know for sure how much plugin are initialized #but we can be sure that it's not more than the number of channel) for y in range(0,channels.channelCount()): #necessary check (or it display an error) if plugins.isValid(y): #if the name of the plugin is Plume if plugins.getPluginName(y) == "Plume": #loop over all the parameter of Plume for x in range(0,plugins.getParamCount(y)): #if the parameter is call track_arm return it if plugins.getParamName(x,y) == "track_arm": return x
def OnChannelKnobPress(self): selected = channels.selectedChannel() if selected < 0: return if SCRIPT_VERSION > 9: channels.showCSForm(selected, -1) elif SCRIPT_VERSION >= 8: if plugins.isValid(selected): # If valid plugin, then toggle channels.showEditor(selected) else: # For audio, no ability to close window settings channels.showCSForm(selected) else: # Older versions, don't bother with toggle since no support for determining whether plugin or audio channels.showCSForm(selected)
def Sync(self): """ Syncs up all visual indicators on keyboard with changes from FL Studio. """ # Update buttons active_index = channels.selectedChannel() led_map = { ArturiaLights.ID_TRANSPORTS_RECORD: ArturiaLights.AsOnOffByte(transport.isRecording()), ArturiaLights.ID_TRANSPORTS_LOOP: ArturiaLights.AsOnOffByte(ui.isLoopRecEnabled()), ArturiaLights.ID_GLOBAL_METRO: ArturiaLights.AsOnOffByte(ui.isMetronomeEnabled()), ArturiaLights.ID_GLOBAL_SAVE: ArturiaLights.AsOnOffByte(transport.getLoopMode() == 1), ArturiaLights.ID_GLOBAL_UNDO: ArturiaLights.AsOnOffByte(general.getUndoHistoryLast() == 0), ArturiaLights.ID_TRACK_SOLO: ArturiaLights.AsOnOffByte(channels.isChannelSolo(active_index)), ArturiaLights.ID_TRACK_MUTE: ArturiaLights.AsOnOffByte(channels.isChannelMuted(active_index)), ArturiaLights.ID_TRANSPORTS_STOP: ArturiaLights.AsOnOffByte(not transport.isPlaying()), ArturiaLights.ID_TRANSPORTS_PLAY: ArturiaLights.AsOnOffByte(transport.getSongPos() > 0), ArturiaLights.ID_GLOBAL_OUT: ArturiaLights.AsOnOffByte( arrangement.selectionEnd() > arrangement.selectionStart()), } self._lights.SetLights(led_map) # Update selected channel bank_lights = [ArturiaLights.LED_OFF] * 9 if active_index < len(bank_lights): bank_lights[active_index] = ArturiaLights.LED_ON self._lights.SetBankLights(bank_lights) # Update display channel_name = channels.getChannelName(active_index) pattern_number = patterns.patternNumber() pattern_name = patterns.getPatternName(pattern_number) # Update knob mode if self._encoders.GetCurrentMode() == ArturiaInputControls.INPUT_MODE_CHANNEL_PLUGINS: plugin_name = plugins.getPluginName(active_index) if plugins.isValid(active_index) else '' self._encoders.SetKnobMode(plugin_name) self._encoders.SetSliderMode(plugin_name) if channel_name.startswith('Analog Lab'): channel_name='Analog Lab' self._paged_display.SetPageLines( 'main', line1='[%d:%d] %s' % (active_index + 1, pattern_number, channel_name), line2='%s' % pattern_name) self._encoders.Refresh()
def TOnRefresh(HW_Dirty_LEDs): """ Wrapper for the OnRefresh thread. """ # PLAY button if transport.isPlaying() == True: nihia.buttonSetLight("PLAY", 1) elif transport.isPlaying() == False: nihia.buttonSetLight("PLAY", 0) # STOP button if transport.isPlaying() == True: nihia.buttonSetLight("STOP", 0) elif transport.isPlaying() == False: nihia.buttonSetLight("STOP", 1) # REC button if transport.isRecording() == True: nihia.buttonSetLight("REC", 1) elif transport.isRecording() == False: nihia.buttonSetLight("REC", 0) # COUNT-IN button if ui.isPrecountEnabled() == True: nihia.buttonSetLight("COUNT_IN", 1) elif ui.isPrecountEnabled() == False: nihia.buttonSetLight("COUNT_IN", 0) # CLEAR button (moved to OnIdle, since OnRefresh isn't called when focused window changes) # LOOP button if ui.isLoopRecEnabled() == True: nihia.buttonSetLight("LOOP", 1) elif ui.isLoopRecEnabled() == False: nihia.buttonSetLight("LOOP", 0) # METRO button if ui.isMetronomeEnabled() == True: nihia.buttonSetLight("METRO", 1) elif ui.isMetronomeEnabled() == False: nihia.buttonSetLight("METRO", 0) # MUTE button if mixer.isTrackMuted(mixer.trackNumber()) == True: nihia.buttonSetLight("MUTE_SELECTED", 1) elif mixer.isTrackMuted(mixer.trackNumber()) == False: nihia.buttonSetLight("MUTE_SELECTED", 0) # SOLO button if mixer.isTrackSolo(mixer.trackNumber()) == True: nihia.buttonSetLight("SOLO_SELECTED", 1) elif mixer.isTrackSolo(mixer.trackNumber()) == False: nihia.buttonSetLight("SOLO_SELECTED", 0) # Update mixer but peak meters updateMixer() # Tell the device if a mixer track is selected or not # It enables the ability to control mixer tracks using the 4D Encoder on S-Series keyboards # Disabled due to lack of awareness on how it is enabled and disabled correctly # if ui.getFocused(midi.widMixer) == True: # nihia.mixerSendInfoSelected("SELECTED", "GENERIC") # # if ui.getFocused(midi.widMixer) == False: # nihia.mixerSendInfoSelected("SELECTED", "EMPTY") # Check if the selected plugin is a Komplete Kontrol instance if (plugins.isValid( channels.channelNumber()) == True): # Checks if plugin exists # If it does, sends the instance ID if plugins.getPluginName( channels.channelNumber()) == "Komplete Kontrol": nihia.mixerSendInfo("KOMPLETE_INSTANCE", 0, info=plugins.getParamName( 0, channels.channelNumber())) # If it doesn't, tells the keyboard about it else: nihia.mixerSendInfo("KOMPLETE_INSTANCE", 0, info="") else: nihia.mixerSendInfo("KOMPLETE_INSTANCE", 0, info="")
def __init__(self, event): global proceed self.event = event global temp_chan proceed = False self.mode_toggle = Switch.mode_toggle # self.mixer_num = mixer.trackNumber() self.channel = channels.channelNumber() self.round_offset = 0.16 self.get_track_value = 0 self.data_one = event.data1 + offset[switch.Switch.offset_iter] self.data_two = event.data2 self.two_rounded = round(self.data_two/127, 2) self.plugin = 0 self.event_one = event.data1 print('knob class') if ui.getFocused(1) and Switch.shift_status == True: print('enter step param edit in turning') if event.data1 == knob['knob_one']: Switch.root_note = int(mapvalues(self.data_two, 0, 11, 0, 127)) ui.setHintMsg(data.notes_list [int(mapvalues(self.data_two, 0, 11, 0, 127)) ] ) print(Switch.root_note) event.handled = True if event.data1 == knob['knob_two']: Switch.scale_choice = int(mapvalues(self.data_two, 0, len(data.scale_names)-1, 0, 127)) ui.setHintMsg(data.scale_names[int(mapvalues(self.data_two, 0, len(data.scale_names)-1, 0, 127))]) print(Switch.scale_choice) event.handled = True if event.data1 == knob['knob_three']: Switch.lower_limit = int(mapvalues(self.data_two, 0, 25, 0, 127)) ui.setHintMsg("Setting Lower Limit") print(Switch.lower_limit) event.handled = True if event.data1 == knob['knob_four']: Switch.upper_limit = int(mapvalues(self.data_two, 50, 0, 0, 127)) ui.setHintMsg("Setting Upper Limit") print(Switch.upper_limit) event.handled = True elif ui.getFocused(5) and plugins.isValid(self.channel): print('plugin control') self.plugin_control() elif ui.getFocused(0) and proceed == False: # This stores the current value at the destination of the knob # print('proceed false mixer focused') if Switch.mixer_num == 0: if mixer.trackNumber() == 0: # Check if master is selected self.get_track_value = mixer.getTrackVolume(0) else: self.get_track_value = mixer.getTrackVolume(self.data_one - 19) elif Switch.mixer_num == 1: # print('store panning info') self.get_track_value = mixer.getTrackPan(self.data_one-19) print(self.get_track_value) self.two_rounded = mapvalues(self.data_two, -1.0, 1.0, 0, 127) print(self.two_rounded) elif ui.getFocused(1) and Switch.shift_status == False: # print('stored channel') if self.mode_toggle != 1 and self.mode_toggle != 3: if self.data_one-20 < channels.channelCount(): self.get_track_value = channels.getChannelVolume(self.data_one-20) else: # print('go to step parameter function') self.step_param() # Knob must match current value before it engages. if self.two_rounded <= (self.get_track_value + self.round_offset) and self.two_rounded >= (self.get_track_value - self.round_offset): print("matched") proceed = True temp_chan = self.data_one # print(f'temp chan: {temp_chan}') if switch.Switch.mode_toggle != 1 and Switch.mode_toggle != 3 or ui.getFocused(1)==False: # print('enter knob turn function') self.knob_turn()