Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python API supports setting individual CtrlCoef values #172

Merged
merged 5 commits into from
Aug 19, 2024
Merged

Conversation

dpwe
Copy link
Collaborator

@dpwe dpwe commented Aug 19, 2024

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 the filter_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 the COEF_EG1 of the filter_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 within amy.py.

@dpwe dpwe merged commit 2f042d0 into main Aug 19, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant