Closed emuell closed 2 months ago
This is now done with the following changes (compared to the original specs):
---@class InputParameter
is an opaque userdata type without any public functions.
It can only be constructed with a set of helper functions, which are grouped together in a new parameters
"namespace":
---Functions to create InputParameters.
parameter = {
---Creates an InputParameter with "boolean" Lua type with the given default value
---and other optional properties.
---@param id InputParameterId
---@param default InputParameterBooleanDefault
---@param name InputParameterName?
---@param description InputParameterDescription?
---@return InputParameter
boolean = function(id, default, name, description) end,
---Creates an InputParameter with "integer" Lua type with the given default value
---and other optional properties.
---@param id InputParameterId
---@param default InputParameterIntegerDefault
---@param range InputParameterIntegerRange?
---@param name InputParameterName?
---@param description InputParameterDescription?
---@return InputParameter
integer = function(id, default, range, name, description) end,
---Creates an InputParameter with "number" Lua type with the given default value
---and other optional properties.
---@param id InputParameterId
---@param default InputParameterNumberDefault
---@param range InputParameterNumberRange?
---@param name InputParameterName?
---@param description InputParameterDescription?
---@return InputParameter
number = function(id, default, range, name, description) end,
---Creates an InputParameter with a "string" Lua type with the given default value,
---set of valid values to choose from and other optional properties.
---@param id InputParameterId
---@param default InputParameterEnumDefault
---@param values string[]
---@param name InputParameterName?
---@param description InputParameterDescription?
---@return InputParameter
enum = function(id, default, values, name, description) end,
}
Motivation
It should be possible to automate, change "things" in rhythms from outside - dynamically. So you can change a running note pattern with a macro or MIDI controller, or can create more generic script presets which then can act as templates, e.g. select a scale, pattern variations, or volume, panning values in scripts.
API Additions
Right now, the only way to control a rhythm's output from the outside is to use the
TriggerContext's
trigger_note / volume / offset parameters. In order to configure a rhythms behaviour more freely, we could introduce something like a custom input parameter layer for rhythms there too:InputParameter is defined as:
To inject/define the set of inputs, the rhythm constructor will then get a new optional
inputs
table property:Input parameter definitions are quite complex & verbose. To make it easier to construct them, there should be helper functions to quickly create common parameters, such as:
Examples
Template which allows creating euclidean patterns with custom step, pulse settings:
Arp pattern with custom scale settings, direction and length:
Random bass note pattern generator with 100 variations (seeds)
Limitations
context
is passed: so e.g.unit
andresolution
can not be changed.