示例#1
0
	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 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)
示例#3
0
 def OnUpdatePitch(self, delta):
     if SCRIPT_VERSION < 8:
         # This isn't supported in older versions
         return
     channel = channels.selectedChannel()
     pan = self.clip(-1., 1.,
                     channels.getChannelPitch(channel) + (delta / 100.0))
     channels.setChannelPitch(channel, pan)
示例#4
0
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
示例#5
0
 def OnPitchKnobPress(self):
     selected = channels.selectedChannel()
     if selected < 0:
         return
     if SCRIPT_VERSION >= 8:
         channels.setChannelPitch(selected, 0)
 def OnUpdatePitch(self, delta):
     channel = channels.selectedChannel()
     pan = self.clip(-1., 1., channels.getChannelPitch(channel) + (delta / 100.0))
     channels.setChannelPitch(channel, pan)