def OnUpdateVolume(self, delta): channel = channels.selectedChannel() volume = self.clip( 0., 1., channels.getChannelVolume(channels.selectedChannel()) + (delta / 100.0)) channels.setChannelVolume(channel, volume)
def OnEncoderDecreased(self, control, event): control_type, control_name, control_id, control_note_or_color = control.split( ".") control_number = int(control_name) if ui.getFocused(midi.widMixer): index = mixer.trackNumber() + control_number - 1 if self.mixer.encodersTarget == ENCODERS_NUM_TARGETS.MIXER.TRACK_VOL: mixer.setTrackVolume(index, mixer.getTrackVolume(index) - VOL_INC) elif self.mixer.encodersTarget == ENCODERS_NUM_TARGETS.MIXER.TRACK_PAN: mixer.setTrackPan(index, mixer.getTrackPan(index) - PAN_INC) elif ui.getFocused(midi.widChannelRack ) and control_number <= channels.channelCount(): index = channels.channelNumber() + control_number - 1 if self.channels.encodersTarget == ENCODERS_NUM_TARGETS.CHANNELS.CHANNEL_VOL: channels.setChannelVolume( index, channels.getChannelVolume(index) - VOL_INC) elif self.channels.encodersTarget == ENCODERS_NUM_TARGETS.CHANNELS.CHANNEL_PAN: channels.setChannelPan(index, channels.getChannelPan(index) - PAN_INC) elif ui.getFocused(midi.widPlaylist): index = playlist.trackNumber() + control_number - 1 if self.playlist.encodersTarget == ENCODERS_NUM_TARGETS.TRACK_VOL: pass
def channelAdjustVolume(selectedChannelNum, data): parameter = float(data)/127.0 hasSnapped = False if(ENABLE_SNAPPING is True): if(parameter >= (CHANNEL_VOLUME_SNAP_TO - SNAP_RANGE) and parameter <= (CHANNEL_VOLUME_SNAP_TO + SNAP_RANGE)): parameter = CHANNEL_VOLUME_SNAP_TO hasSnapped = True channels.setChannelVolume(selectedChannelNum, parameter) ret = "Channel rack: Adjust " + getChannelName(selectedChannelNum) + " volume to " + str(round(parameter * 100, 0)) + "%" if(hasSnapped is True): ret += " [Snapped]" return ret
def setVolume(command, channel, value): if channels.channelCount() <= channel: command.handle("Channel out of range. Couldn't set volume", silent=True) return volume = getVolumeSend(value) channels.setChannelVolume(channel, volume) action = "Set " + channels.getChannelName( channel) + " volume to " + getVolumeValue(value) if processorhelpers.didSnap(processorhelpers.toFloat(value), internal.consts.CHANNEL_VOLUME_SNAP_TO): action += " [Snapped]" command.handle(action)
def knob_turn(self): global proceed if proceed == True and temp_chan == self.data_one: print("proceeding") if ui.getFocused(0) and Switch.mixer_num == 0: if mixer.trackNumber() == 0 and self.data_one == 20: mixer.setTrackVolume(0, self.data_two/127) else: mixer.setTrackVolume(self.data_one-19, self.data_two/127) elif ui.getFocused(0) and Switch.mixer_num == 1: mixer.setTrackPan(self.data_one-19, mapvalues(self.data_two, -1, 1, 0, 127)) # print(f'panning: {mapvalues(self.data_two, -1, 1, 0, 127)}') elif ui.getFocused(1) and self.data_one-20 < channels.channelCount() and Switch.shift_status == False: # print(f'volume: {mapvalues(self.data_two, -1, 1, 0, 127)}') channels.setChannelVolume(self.data_one-20, mapvalues(self.data_two, 0, 1, 0, 127)) elif proceed == True and temp_chan != self.data_one: print("proceed no more") proceed = False
def process(command): # Process master fader changing selected channel volume. if command.id == eventconsts.BASIC_FADER_9: current_channel = channels.selectedChannel() volume = processorhelpers.snap(processorhelpers.toFloat(command.value), internal.consts.CHANNEL_VOLUME_SNAP_TO) channels.setChannelVolume(current_channel, volume) action = "Set " + channels.getChannelName( current_channel) + " volume to " + str(round(volume * 100)) + "%" if processorhelpers.didSnap(processorhelpers.toFloat(command.value), internal.consts.CHANNEL_VOLUME_SNAP_TO): action += " [Snapped]" command.handle(action) # Process master fader button to mute/unmute. if command.id == eventconsts.BASIC_FADER_BUTTON_9: global mute_toggle_channel, previous_channel_volume if command.is_lift: if type(mute_toggle_channel) is int and type( previous_channel_volume) is float: if 0 == channels.getChannelVolume(mute_toggle_channel): channels.setChannelVolume(mute_toggle_channel, previous_channel_volume) command.handle( "Unmuted " + channels.getChannelName(mute_toggle_channel)) mute_toggle_channel = None previous_channel_volume = None else: mute_toggle_channel = channels.selectedChannel() previous_channel_volume = channels.getChannelVolume( mute_toggle_channel) channels.setChannelVolume(mute_toggle_channel, 0) command.handle("Muted " + channels.getChannelName(mute_toggle_channel)) for x in imports: object_to_call = getattr(pluginprocessors, x) if canHandle(object_to_call): object_to_call.process(command) if command.ignored: return # Only process mod-wheel and pitch-bend if they weren't already handled by plugin processors # Mod-wheel if command.id == eventconsts.MOD_WHEEL: pluginswrapper.setCCParam(command.note, command.value) command.handle("Mod-wheel", 1) # Pitch-bend wheel if command.id == eventconsts.PITCH_BEND: #pluginswrapper.setCCParam(command.note, command.value) current_channel = channels.selectedChannel() channels.setChannelPitch( current_channel, processorhelpers.snap( processorhelpers.toFloat(command.value, -1, 1), 0.0)) command.handle("Pitch Bend", 1)
def process(command): # REQUIRES SCRIPTING VERSION 8 #if general.getVersion() >= 8: # Process pitch bend wheel if command.id == eventconsts.PITCH_BEND: current_channel = channels.selectedChannel() channels.setChannelPitch( current_channel, processorhelpers.toFloat(command.value, -1, 1)) # Process master fader changing selected channel volume. if command.id == eventconsts.BASIC_FADER_9: current_channel = channels.selectedChannel() volume = processorhelpers.snap(processorhelpers.toFloat(command.value), internal.consts.CHANNEL_VOLUME_SNAP_TO) channels.setChannelVolume(current_channel, volume) action = "Set " + channels.getChannelName( current_channel) + " volume to " + str(round(volume * 100)) + "%" if processorhelpers.didSnap(processorhelpers.toFloat(command.value), internal.consts.CHANNEL_VOLUME_SNAP_TO): action += " [Snapped]" command.handle(action) # Process master fader button to mute/unmute. if command.id == eventconsts.BASIC_FADER_BUTTON_9: global mute_toggle_channel, previous_channel_volume if command.is_lift: if type(mute_toggle_channel) is int and type( previous_channel_volume) is float: if 0 == channels.getChannelVolume(mute_toggle_channel): channels.setChannelVolume(mute_toggle_channel, previous_channel_volume) command.handle( "Unmuted " + channels.getChannelName(mute_toggle_channel)) mute_toggle_channel = None previous_channel_volume = None else: mute_toggle_channel = channels.selectedChannel() previous_channel_volume = channels.getChannelVolume( mute_toggle_channel) channels.setChannelVolume(mute_toggle_channel, 0) command.handle("Muted " + channels.getChannelName(mute_toggle_channel)) for x in imports: object_to_call = getattr(pluginprocessors, x) if canHandle(object_to_call): object_to_call.process(command) if command.ignored: return
def OnMidiIn(self, event): #tbuttons if (event.data1 == playb): transport.start() #play self.UpdateLEDs() if (event.data1 == recb): transport.record() #record self.UpdateLEDs() if (event.data1 == stopb): transport.stop() #stop self.UpdateLEDs() if (event.data1 == loopb): transport.setLoopMode() #loop/pattern mode self.UpdateLEDs() if (event.data1 == metrob): # metronome/button transport.globalTransport(midi.FPT_Metronome, 110) self.UpdateLEDs() if (event.data1 == tempob): transport.stop() #tap tempo if (event.data1 == quantizeb): transport.globalTransport(midi.FPT_Snap, 48) #snap toggle if (event.data1 == squantizeb): ui.snapMode(1) #snap toggle if (event.data1 == srecb): transport.globalTransport(midi.FPT_CountDown, 115) #countdown before recordin #if (event.data1 == sstopb): # transport.globalTransport(midi.FPT_F12, 71) #clear all windows if (event.data1 == undob): general.undoUp() #undo if (event.data1 == sundob): general.undo() #redo if (event.data1 == squantizeb): transport.globalTransport(midi.FPT_SnapMode, 49, event.pmeFlags) #snap toggle self.UpdateLEDs() if (event.data1 == tempob): transport.globalTransport(midi.FPT_TapTempo, 106) #tap tempo #4D controller if (event.data1 == knobe): transport.globalTransport(midi.FPT_Enter, 80) #enter if (event.data1 == knobsp) & (event.data2 == right): #4d encoder spin right ui.jog(1) elif (event.data1 == knobsp) & (event.data2 == left): #4d encoder spin left ui.jog(-1) if (event.data1 == knoblr) & (event.data2 == right): #4d encoder push right transport.globalTransport(midi.FPT_Right, 1) elif (event.data1 == knoblr) & (event.data2 == left): #4d encoder push left transport.globalTransport(midi.FPT_Left, 1) if (event.data1 == knobud) & (event.data2 == up): #4d encoder push up transport.globalTransport(midi.FPT_Up, 1) elif (event.data1 == knobud) & (event.data2 == down): #4d encoder push down transport.globalTransport(midi.FPT_Down, 1) #8 volume knobs for mixer & channel rack, 8 tracks at a time volinc = .005 #volume increments paninc = .01 # pan increments if ui.getFocused(0) == 1: #mixer volume control if (event.data1 == muteb): mixer.enableTrack(mixer.trackNumber()) #mute if (event.data1 == solob): mixer.soloTrack(mixer.trackNumber()) #solo # VOLUME CONTROL #knob 1 if (event.data1 == knob1): if event.data2 == 127: mixer.setTrackVolume( mixer.trackNumber() + 0, mixer.getTrackVolume(mixer.trackNumber()) + 0 - volinc) # volume values go down elif event.data2 == 1: mixer.setTrackVolume( mixer.trackNumber() + 0, mixer.getTrackVolume(mixer.trackNumber()) + 0 + volinc) # volume values go up #knob 2 if (event.data1 == knob2): if event.data2 == 127: mixer.setTrackVolume( mixer.trackNumber() + 1, mixer.getTrackVolume(mixer.trackNumber() + 1) - volinc) # volume values go down elif event.data2 == 1: mixer.setTrackVolume( mixer.trackNumber() + 1, mixer.getTrackVolume(mixer.trackNumber() + 1) + volinc) # volume values go up #knob 3 if (event.data1 == knob3): if event.data2 == 127: mixer.setTrackVolume( mixer.trackNumber() + 2, mixer.getTrackVolume(mixer.trackNumber() + 2) - volinc) # volume values go down elif event.data2 == 1: mixer.setTrackVolume( mixer.trackNumber() + 2, mixer.getTrackVolume(mixer.trackNumber() + 2) + volinc) # volume values go up #knob 4 if (event.data1 == knob4): if event.data2 == 127: mixer.setTrackVolume( mixer.trackNumber() + 3, mixer.getTrackVolume(mixer.trackNumber() + 3) - volinc) # volume values go down elif event.data2 == 1: mixer.setTrackVolume( mixer.trackNumber() + 3, mixer.getTrackVolume(mixer.trackNumber() + 3) + volinc) # volume values go up #knob5 if (event.data1 == knob5): if event.data2 == 127: mixer.setTrackVolume( mixer.trackNumber() + 4, mixer.getTrackVolume(mixer.trackNumber() + 4) - volinc) # volume values go down elif event.data2 == 1: mixer.setTrackVolume( mixer.trackNumber() + 4, mixer.getTrackVolume(mixer.trackNumber() + 4) + volinc) # volume values go up #knob 6 if (event.data1 == knob6): if event.data2 == 127: mixer.setTrackVolume( mixer.trackNumber() + 5, mixer.getTrackVolume(mixer.trackNumber() + 5) - volinc) # volume values go down elif event.data2 == 1: mixer.setTrackVolume( mixer.trackNumber() + 5, mixer.getTrackVolume(mixer.trackNumber() + 5) + volinc) # volume values go up #knob 7 if (event.data1 == knob7): if event.data2 == 127: mixer.setTrackVolume( mixer.trackNumber() + 6, mixer.getTrackVolume(mixer.trackNumber() + 6) - volinc) # volume values go down elif event.data2 == 1: mixer.setTrackVolume( mixer.trackNumber() + 6, mixer.getTrackVolume(mixer.trackNumber() + 6) + volinc) # volume values go up #knob 8 if (event.data1 == knob8): if event.data2 == 127: mixer.setTrackVolume( mixer.trackNumber() + 7, mixer.getTrackVolume(mixer.trackNumber() + 7) - volinc) # volume values go down elif event.data2 == 1: mixer.setTrackVolume( mixer.trackNumber() + 7, mixer.getTrackVolume(mixer.trackNumber() + 7) + volinc) # volume values go up # PAN CONTROL #sknob 1 if (event.data1 == sknob1): if event.data2 == 127: mixer.setTrackPan(mixer.trackNumber() + 0, mixer.getTrackPan(mixer.trackNumber()) + 0 - paninc) # volume values go down elif event.data2 == 1: mixer.setTrackPan(mixer.trackNumber() + 0, mixer.getTrackPan(mixer.trackNumber()) + 0 + paninc) # volume values go up #sknob 2 if (event.data1 == sknob2): if event.data2 == 127: mixer.setTrackPan( mixer.trackNumber() + 1, mixer.getTrackPan(mixer.trackNumber() + 1) - paninc) # volume values go down elif event.data2 == 1: mixer.setTrackPan( mixer.trackNumber() + 1, mixer.getTrackPan(mixer.trackNumber() + 1) + paninc) # volume values go up #sknob 3 if (event.data1 == sknob3): if event.data2 == 127: mixer.setTrackPan( mixer.trackNumber() + 2, mixer.getTrackPan(mixer.trackNumber() + 2) - paninc) # volume values go down elif event.data2 == 1: mixer.setTrackPan( mixer.trackNumber() + 2, mixer.getTrackPan(mixer.trackNumber() + 2) + paninc) # volume values go up #sknob 4 if (event.data1 == sknob4): if event.data2 == 127: mixer.setTrackPan( mixer.trackNumber() + 3, mixer.getTrackPan(mixer.trackNumber() + 3) - paninc) # volume values go down elif event.data2 == 1: mixer.setTrackPan( mixer.trackNumber() + 3, mixer.getTrackPan(mixer.trackNumber() + 3) + paninc) # volume values go up #sknob5 if (event.data1 == sknob5): if event.data2 == 127: mixer.setTrackPan( mixer.trackNumber() + 4, mixer.getTrackPan(mixer.trackNumber() + 4) - paninc) # volume values go down elif event.data2 == 1: mixer.setTrackPan( mixer.trackNumber() + 4, mixer.getTrackPan(mixer.trackNumber() + 4) + paninc) # volume values go up #sknob 6 if (event.data1 == sknob6): if event.data2 == 127: mixer.setTrackPan( mixer.trackNumber() + 5, mixer.getTrackPan(mixer.trackNumber() + 5) - paninc) # volume values go down elif event.data2 == 1: mixer.setTrackPan( mixer.trackNumber() + 5, mixer.getTrackPan(mixer.trackNumber() + 5) + paninc) # volume values go up #sknob 7 if (event.data1 == sknob7): if event.data2 == 127: mixer.setTrackPan( mixer.trackNumber() + 6, mixer.getTrackPan(mixer.trackNumber() + 6) - paninc) # volume values go down elif event.data2 == 1: mixer.setTrackPan( mixer.trackNumber() + 6, mixer.getTrackPan(mixer.trackNumber() + 6) + paninc) # volume values go up #sknob 8 if (event.data1 == sknob8): if event.data2 == 127: mixer.setTrackPan( mixer.trackNumber() + 7, mixer.getTrackPan(mixer.trackNumber() + 7) - paninc) # volume values go down elif event.data2 == 1: mixer.setTrackPan( mixer.trackNumber() + 7, mixer.getTrackPan(mixer.trackNumber() + 7) + paninc) # volume values go up elif ui.getFocused(0) == 0: # channel rack if (event.data1 == muteb): channels.muteChannel(channels.channelNumber()) #mute if (event.data1 == solob): channels.soloChannel(channels.channelNumber()) #solo # VOLUME CONTROL #knob 1 if (event.data1 == knob1): if event.data2 == 127: channels.setChannelVolume( channels.channelNumber() + 0, channels.getChannelVolume(channels.channelNumber() + 0) - volinc) # volume values go down elif event.data2 == 1: channels.setChannelVolume( channels.channelNumber() + 0, channels.getChannelVolume(channels.channelNumber() + 0) + volinc) # volume values go up #knob 2 if (event.data1 == knob2): if event.data2 == 127: channels.setChannelVolume( channels.channelNumber() + 1, channels.getChannelVolume(channels.channelNumber() + 1) - volinc) # volume values go down elif event.data2 == 1: channels.setChannelVolume( channels.channelNumber() + 1, channels.getChannelVolume(channels.channelNumber() + 1) + volinc) # volume values go up #knob 3 if (event.data1 == knob3): if event.data2 == 127: channels.setChannelVolume( channels.channelNumber() + 2, channels.getChannelVolume(channels.channelNumber() + 2) - volinc) # volume values go down elif event.data2 == 1: channels.setChannelVolume( channels.channelNumber() + 2, channels.getChannelVolume(channels.channelNumber() + 2) + volinc) # volume values go up #knob 4 if (event.data1 == knob4): if event.data2 == 127: channels.setChannelVolume( channels.channelNumber() + 3, channels.getChannelVolume(channels.channelNumber() + 3) - volinc) # volume values go down elif event.data2 == 1: channels.setChannelVolume( channels.channelNumber() + 3, channels.getChannelVolume(channels.channelNumber() + 3) + volinc) # volume values go up #knob 5 if (event.data1 == knob5): if event.data2 == 127: channels.setChannelVolume( channels.channelNumber() + 4, channels.getChannelVolume(channels.channelNumber() + 4) - volinc) # volume values go down elif event.data2 == 1: channels.setChannelVolume( channels.channelNumber() + 4, channels.getChannelVolume(channels.channelNumber() + 4) + volinc) # volume values go up #knob 6 if (event.data1 == knob6): if event.data2 == 127: channels.setChannelVolume( channels.channelNumber() + 5, channels.getChannelVolume(channels.channelNumber() + 5) - volinc) # volume values go down elif event.data2 == 1: channels.setChannelVolume( channels.channelNumber() + 5, channels.getChannelVolume(channels.channelNumber() + 5) + volinc) # volume values go up #knob 7 if (event.data1 == knob7): if event.data2 == 127: channels.setChannelVolume( channels.channelNumber() + 6, channels.getChannelVolume(channels.channelNumber() + 6) - volinc) # volume values go down elif event.data2 == 1: channels.setChannelVolume( channels.channelNumber() + 6, channels.getChannelVolume(channels.channelNumber() + 6) + volinc) # volume values go up #knob 8 if (event.data1 == knob8): if event.data2 == 127: channels.setChannelVolume( channels.channelNumber() + 7, channels.getChannelVolume(channels.channelNumber() + 7) - volinc) # volume values go down elif event.data2 == 1: channels.setChannelVolume( channels.channelNumber() + 7, channels.getChannelVolume(channels.channelNumber() + 7) + volinc) # volume values go up # PAN CONTROL #sknob 1 if (event.data1 == sknob1): if event.data2 == 127: channels.setChannelPan( channels.channelNumber() + 0, channels.getChannelPan(channels.channelNumber() + 0) - volinc) # volume values go down elif event.data2 == 1: channels.setChannelPan( channels.channelNumber() + 0, channels.getChannelPan(channels.channelNumber() + 0) + volinc) # volume values go up #sknob 2 if (event.data1 == sknob2): if event.data2 == 127: channels.setChannelPan( channels.channelNumber() + 1, channels.getChannelPan(channels.channelNumber() + 1) - volinc) # volume values go down elif event.data2 == 1: channels.setChannelPan( channels.channelNumber() + 1, channels.getChannelPan(channels.channelNumber() + 1) + volinc) # volume values go up #sknob 3 if (event.data1 == sknob3): if event.data2 == 127: channels.setChannelPan( channels.channelNumber() + 2, channels.getChannelPan(channels.channelNumber() + 2) - volinc) # volume values go down elif event.data2 == 1: channels.setChannelPan( channels.channelNumber() + 2, channels.getChannelPan(channels.channelNumber() + 2) + volinc) # volume values go up #sknob 4 if (event.data1 == sknob4): if event.data2 == 127: channels.setChannelPan( channels.channelNumber() + 3, channels.getChannelPan(channels.channelNumber() + 3) - volinc) # volume values go down elif event.data2 == 1: channels.setChannelPan( channels.channelNumber() + 3, channels.getChannelPan(channels.channelNumber() + 3) + volinc) # volume values go up #sknob 5 if (event.data1 == sknob5): if event.data2 == 127: channels.setChannelPan( channels.channelNumber() + 4, channels.getChannelPan(channels.channelNumber() + 4) - volinc) # volume values go down elif event.data2 == 1: channels.setChannelPan( channels.channelNumber() + 4, channels.getChannelPan(channels.channelNumber() + 4) + volinc) # volume values go up #sknob 6 if (event.data1 == sknob6): if event.data2 == 127: channels.setChannelPan( channels.channelNumber() + 5, channels.getChannelPan(channels.channelNumber() + 5) - volinc) # volume values go down elif event.data2 == 1: channels.setChannelPan( channels.channelNumber() + 5, channels.getChannelPan(channels.channelNumber() + 5) + volinc) # volume values go up #sknob 7 if (event.data1 == sknob7): if event.data2 == 127: channels.setChannelPan( channels.channelNumber() + 6, channels.getChannelPan(channels.channelNumber() + 6) - volinc) # volume values go down elif event.data2 == 1: channels.setChannelPan( channels.channelNumber() + 6, channels.getChannelPan(channels.channelNumber() + 6) + volinc) # volume values go up #sknob 8 if (event.data1 == sknob8): if event.data2 == 127: channels.setChannelPan( channels.channelNumber() + 7, channels.getChannelPan(channels.channelNumber() + 7) - volinc) # volume values go down elif event.data2 == 1: channels.setChannelPan( channels.channelNumber() + 7, channels.getChannelPan(channels.channelNumber() + 7) + volinc) # volume values go up
def OnVolumeKnobPress(self): selected = channels.selectedChannel() if selected < 0: return channels.setChannelVolume(selected, 0.78125)