Python API supports setting individual CtrlCoef values #172
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Several parameters (
freq, amp, filter_freq, duty, pan
) are set via "Control Coefficient" vectors, sets of 7 coefficients that are applied to a fixed set of input signals (const, note, vel, eg0, eg1, mod, bend
). These are set via the C API by setting 7-element vectors associated with each parameter, e.g.event_obj.filter_freq_coefs[COEF_EG1] = 0.5
; when this event is executed, only that one coefficient within thefilter_freq
vector is changed.Prior to this change, the Python API was different. Following the wire protocol, changing any coefficient required specifying the entire set, e.g.
amy.send(osc=0, filter_freq='500,0,0,0,1,0,0')
. For convenience, if fewer than 7 values were specified, the remainder were taken as zero. Thus, to change a single coefficient, the user had to provide the existing values of all the other coefficients to avoid changing them also.This change allows the Python API to indicate "unspecified" coefficients in several ways. Most simply, a value can simply be omitted, with bare commas used to get to the right place:
filter_freq=',,,,1'
changes just theCOEF_EG1
of thefilter_freq_coefs
vector. (As part of this, trailing unspecified coefficients are no longer taken as zero).Because counting commas is error prone, we also add an alternative syntax in which the coefficients are specified in a Python dict, for instance
filter_freq={'eg1': 1}
. Any subset of the coefficients can be set. This is translated into the bare-comma list syntax required for the wire protocol withinamy.py
.