def getParamIndexByName(name, plugin_index=-1, expected_param_index=-1):
    """Returns the index of a parameter in a plugin given the name of the parameter.

    Args:
        name (str): Name of the parameter to find.
        
        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.
        
        expected_param_index (optional, int): index where the parameter is expected to be.
            it is searched first to increase efficiency
        

    Returns:
        int: Index of parameter. -1 if not found.
    """

    plugin_index = _getPluginIndexTuple(plugin_index)
    
    if plugins.getParamName(expected_param_index, plugin_index[1], plugin_index[0]) == name:
        return expected_param_index

    for i in range(plugins.getParamCount(plugin_index[1], plugin_index[0])):
        if plugins.getParamName(i, plugin_index[1], plugin_index[0]) == name:
            return i
    
    return -1
Exemplo n.º 2
0
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 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)) + "%"
                    )
Exemplo n.º 4
0
def _get_param_names(plugin_idx):
    return [plugins.getParamName(i, plugin_idx).lower() for i in range(plugins.getParamCount(plugin_idx))]
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="")