shorepine / amy

AMY - A high-performance fixed-point Music synthesizer librarY for microcontrollers
https://shorepine.github.io/amy/
MIT License
224 stars 14 forks source link

src/amy.c: Naming an oscillator as a mod_source clears its amp[VEL]. #171

Closed dpwe closed 3 months ago

dpwe commented 3 months ago

We hit a problem where setting up an oscillator as an LFO using C led to a zero-amplitude modulator unless you explicitly cleared amp_coef[COEF_VEL], the incorporation of the oscillator note velocity into its overall amplitude, which is set to 1.0 by default.

However, modulation oscillators never have a nonzero velocity (that would lead to them being audible), so this dependence is unwanted.

With this change, amp_coef[COEF_VEL] is automatically cleared for a modulator oscillator when it is set as the mod_source for another oscillator. This increases the undesirable magic side effects of amy:play_event(), but I am comfortable with this solution.

If you really wanted the modulating oscillator to depend on velocity, you could rewrite its amp coefficients after naming it as the mod_source for the dependent oscillator.