-
Notifications
You must be signed in to change notification settings - Fork 6
Processor Helpers
The processorhelpers module contains useful classes and functions for processing events.
This class can be used to manage menu layers. You can use it if your processor has multiple menu modes that can be toggled and switched through. This function doesn't manage the implementation of those modes or control how the modes are switched between, so much of the implementation has been left up to the person using it.
Requires the parameter num_modes which is the number of different menus to be contained in the object.
To create a new ui mode handler with 5 modes, use the following code:
ui_mode = processorhelpers.UiModeHandler(5)To toggle to the next mode, use UiModeHandler.nextMode(). After the last mode, the object will automatically wrap back to the first.
Accessing the previous mode is done using UiModeHandler.prevMode().
To reset the mode to the first, use UiModeHandler.resetMode().
To get the current mode, use UiModeHandler.getMode()
In some scenarios, you may wish to snap values from faders or knobs to a default value. In these cases, the following functions will be of use.
This function converts a midi value (between 0 and 127) to a float value between a minimum and maximum value. By default, the minimum and maximum values are assumed to be 0 and 1 respectively.
Example usage:
# Get a float between 0 and 1 for the midi value 72.
float_val = processorhelpers.toFloat(72)# Get a float between -1 and 1 for the midi value of an event.
float_val = processorhelpers.toFloat(command.value, -1, 1)This function snaps a float value to a provided snap value if it is within the snap range defined in config.py. Otherwise, it returns the original value.
Example usage:
# Snap a float value to 50% if it's within snapping range and snapping is enabled.
snapped_value = processorhelpers.snap(0.53, 0.5)
# For the default settings, this will return 0.5# Take a MIDI value, convert it to a float and snap it to 50% if it's within range.
send_value = processorhelpers.snap(processorhelpers.toFloat(command.value), 0.5)
# Since the snap function returns the unsnapped value if a snapping didn't occur,
# we can use this value in most FL Studio functions directly.Returns true if an value would snap. This is mostly useful for logging event actions.
Example usage:
# Determine if an event snapped, and modify the string to log as its action if it has.
action_str = "Some action"
if processorhelpers.didSnap(processorhelpers.toFloat(command.value), 0.5):
action_str += " [Snapped]"
command.handle(action_str)This object allows you to create a note with several other "linked" notes attached to it. These can be used to trigger multiple notes using a single one, which is especially useful in some note handlers.
Arguments:
- Root note (RawEvent, ParsedEvent, or FLMidiMsg): The note which triggered the set of notes.
- Extended notes (list of RawEvents): The set of notes that were triggered.
For example usage, please refer to the development reference for creating note processors.
This object allows for the quick inclusion of keyswitches in processor modules. It provides functions for redrawing keyswitches to the drum pads, and for getting a keyswitch number for any pressed drum pads.
Draws a layout of keyswitches onto the drum pads.
Arguments:
- lights: the LightMap object
- colour_palette: A colour or list of colours to use while drawing the drum pads. You can use the colour shades defined in
lightingconsts.pyhere. - x_len (int): the width of one page of keyswitches
- y_len (int): the height of one page of keyswitches
- full_keyswitches (int): whether to draw keyswitches on both rows of drums (1), only the bottom row (0), or whether to determine it based on the settings in
config.py(-1).
Gets the keyswitch number of a drum pad given its coordinates.
Arguments:
- x: the drum pad's x coordinate
- y: the drum pad's y coordinate
- x_len: the width of one page of keyswitches
- y_len: the height of one page of keyswitches
- full_keyswitches: whether keyswitches are being drawn on bot rows of drums (1), only the bottom row (0), or whether to determine it based on the settings in
config.py(-1).
An example implementation of keyswitches can be found in pluginprocessors > bbcso.py.