grame-cncm / faust

Functional programming language for signal processing and sound synthesis
http://faust.grame.fr
Other
2.58k stars 322 forks source link

Setting voice params in faust2api DSP engine works counter intuitive #695

Closed goofy2k closed 2 years ago

goofy2k commented 2 years ago

(excuse me for the lengthy description, I took this from a discussion thread, with minimal effort to re-phrase)

I use the Wavesynth FX generated with faust2api for ESP32 in polyphonic mode.

First some background on the API.

It contains several ways to start a sound/note:

  1. One can feed Midi data into the propagateMidi command. For playing a note this has to be called 2 times. First with a noteon status (9n), then with a noteoff (8n).
  2. By feeding a pitch and velocity to a keyOn command, followed by feeding the same pitch to keyOff
  3. By creating a voice with newVoice, setting the frequency (and other parameters) for this voice with setVoiceParamValue commands, using the voice address returned by newVoice. The last parameter set in this sequence is gate -> 1 to start the sound. Switching the sound off is done by setting gate to 0. If I am correct, the voice instance must be deleted with deleteVoice.

I use methods 1 and 2 in the same app.

The issue relates to setting sound parameters with setParamValue or setVoiceParamValue. When I do this with setParamValue and propagateMidi notes respond accordingly. When I do this for a specific voice created with keyOn, I use setVoiceParamValue with the acquired voice address and this notes plays with the selected parameters for that voice. All allready playing notes do not change their characteristics, which is fine. However, when I start a note with propagateMidi after that this also plays with the last characteristics set for the specific voice. Is this intended behavior by design? I would think it would be useful to let voices where characteristics are not set with setVoiceParamValue always play with those set with setParamValue ?

So current behaviour of setParamValue and setVoiceParamValue is:

A more "intuitive" way of operation would be:


Just another way to describe the current counter-intuitive way of operation:

ALL future notes respond to the last setting made by either setParamValue OR setVoiceParamValue. With setParamValue also still playing PAST notes are affected.

sletz commented 2 years ago
goofy2k commented 2 years ago

OK. I will check this again with keeping in mind your recommendations. It will take me some time !

goofy2k commented 2 years ago

I have a solution for what I wanted to achieve: using channel-specific DSP parameters for notes. I now use only keyOn/keyOff and setVoiceParamValue. I described my method in a discussion that quite accidentally was started today: https://github.com/grame-cncm/faust/discussions/696