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)
Beispiel #2
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
def process(command):
    """Called when processing commands. 

    Args:
        command (ParsedEvent): contains useful information about the event. 
            Use this to determing what actions your processor will take.
    """
    global selected_mapping

    # Add event processor to actions list (useful for debugging)
    command.actions.addProcessor("FLEX Processor")

    value = processorhelpers.toFloat(command.value)

    if command.type is eventconsts.TYPE_BASIC_FADER:
        if command.coord_X < 8:
            pluginswrapper.setParamByIndex(command.coord_X + CONTROL_START,
                                           command.value, -1, command)

    if command.type is eventconsts.TYPE_BASIC_KNOB:
        if KNOB_MAPPINGS[selected_mapping][0][command.coord_X] != -1:
            pluginswrapper.setParamByIndex(
                KNOB_MAPPINGS[selected_mapping][0][command.coord_X],
                command.value, -1, command)

    if command.type is eventconsts.TYPE_BASIC_PAD:
        if command.coord_X < len(KNOB_MAPPINGS) and command.coord_Y == 0:
            selected_mapping = command.coord_X
            command.handle("Mapped knobs to " +
                           KNOB_MAPPINGS[selected_mapping][1])

    return
Beispiel #4
0
def setPan(command, track, value):
    volume = getPanSend(value)
    mixer.setTrackPan(track, volume)
    action = "Set " + mixer.getTrackName(track) + " pan to " + getPanValue(
        value)
    if processorhelpers.didSnap(processorhelpers.toFloat(value, -1),
                                internal.consts.MIXER_PAN_SNAP_TO):
        action += " [Snapped]"
    command.handle(action)
Beispiel #5
0
def setVolume(command, track, value):
    volume = getVolumeSend(value)
    mixer.setTrackVolume(track, volume)
    action = "Set " + mixer.getTrackName(
        track) + " volume to " + getVolumeValue(value)
    if processorhelpers.didSnap(processorhelpers.toFloat(value),
                                internal.consts.MIXER_VOLUME_SNAP_TO):
        action += " [Snapped]"
    command.handle(action)
Beispiel #6
0
def setPan(command, channel, value):
    if channels.channelCount() <= channel:
        command.handle("Channel out of range. Couldn't set pan", silent=True)
        return

    volume = getPanSend(value)
    channels.setChannelPan(channel, volume)
    action = "Set " + channels.getChannelName(
        channel) + " pan to " + getPanValue(value)
    if processorhelpers.didSnap(processorhelpers.toFloat(value, -1),
                                internal.consts.CHANNEL_PAN_SNAP_TO):
        action = "[Snapped]"
    command.handle(action)
Beispiel #7
0
def process(command):
    command.actions.addProcessor("BBCSO Processor")

    if command.type is eventconsts.TYPE_BASIC_PAD:

        if config.USE_FULL_KEYSWITCHES or command.coord_Y == 1:

            keyswitch_num = processorhelpers.keyswitches.getNum(
                command.coord_X, command.coord_Y, 4, 2)

            command.edit(
                processorhelpers.RawEvent(0x90, keyswitch_num, command.value),
                "Remap keyswitches")

    #
    # Map parameters
    #

    value = processorhelpers.toFloat(command.value)

    if command.type is eventconsts.TYPE_BASIC_FADER:
        if command.coord_X == 0:
            spitfire_generic.setExpression(command)
        elif command.coord_X == 1:
            spitfire_generic.setDynamics(command)

    if command.type is eventconsts.TYPE_BASIC_KNOB:
        if command.coord_X == 0:
            spitfire_generic.setReverb(command)
        elif command.coord_X == 1:
            spitfire_generic.setRelease(command)
        elif command.coord_X == 2:
            spitfire_generic.setTightness(command)

        elif command.coord_X == 3:
            pluginswrapper.setParamByName("Variation", command.value, -1,
                                          VARIATION, command)

        elif command.coord_X == 4:
            spitfire_generic.setVibrato(command)

    return
def setParamByIndex(param_index, value,  plugin_index=-1, command=None):
    """Sets a parameter in a plugin given the name of the parameter.

    Args:
        param_index (int): index where the parameter is.
        
        value:
         *  (float):    Value to set the parameter to.
         *  (int):      MIDI value to set the parameter to (will be converted to a float between
                0 and 1).
        
        plugin_index (optional)
         *  (int):              Plugin index to search. Use -1 for currently-selected
                                    plugin's index.
         *  (tuple: 2 ints):    Respectively, mixer track and plugin index to search.
        
        command (ParsedEvent, optional): Command to add handling message to        
    """
    
    if type(value) is int:
        value = processorhelpers.toFloat(value)
    
    plugin_index = _getPluginIndexTuple(plugin_index)
    
    # No plugin selected
    if plugin_index[1] == -1:
        return
    
    plugins.setParamValue(value, param_index, plugin_index[1], plugin_index[0])
    
    if command is not None:
        # For generators, use name on channel rack
        if plugin_index[0] == -1:
            plug_name = channels.getChannelName(plugin_index[1])
        else:
            plug_name = plugins.getPluginName(plugin_index[1], plugin_index[0])
        command.handle(plug_name
                       + ": Set "
                       + plugins.getParamName(param_index, plugin_index[1], plugin_index[0])
                       + " to " + str(round(value * 100)) + "%"
                    )
Beispiel #9
0
def getPanSend(inVal):
    if config.ENABLE_SNAPPING:
        return processorhelpers.snap(processorhelpers.toFloat(inVal, -1),
                                     internal.consts.CHANNEL_PAN_SNAP_TO)
    else:
        return processorhelpers.toFloat(inVal, -1)
Beispiel #10
0
def getVolumeSend(inVal):
    if config.ENABLE_SNAPPING:
        return processorhelpers.snap(processorhelpers.toFloat(inVal),
                                     internal.consts.CHANNEL_VOLUME_SNAP_TO)
    else:
        return processorhelpers.toFloat(inVal)