adding velocity to synth but keep envelope release



I'm building a synthesizer, with no midi input, but where I use a SoftPot Membrane Potentiometer to determine the frequency.

I want to use a force sensitive resistor to trigger the sound, and at the same time use it for adding some velocity.

But I'm stuck on how to do that...

I've got it going where I map the FSR to the waveform.amplitude, so it plays higher as I press harder.
And the envelope trigger note on when the FSR > 5 and note off when FSR<5
This works, but then I don't hear the envelopes release time, - because I turn the waveform.amplitude down..

I like that I'm able to add my own "vibrato" to the sound.
Anyone with a good idea on how I can do what I want, without loosing the release??

Best regards

Don't "turn the waveform.amplitude down" until the envelope release has finished? Use envelope.isActive() to detect this.

With the current audio library DO NOT set the waveform amplitude to zero and then look for isActive() to become false - there's a bug in the envelope code whereby it stops the DAHDSR sequence if its source goes silent. The PR for this is now just over a year old...
I have made quite a few synths with velocity.
First, I do my own FSRs using velostat. It is very cheap, and much more sensitive.

Here is my overall process. Use envelopes, don't use amplitude.

Trigering notes :
if FSR output > threshold + debounce -> envelope.noteOn()
if FSR output < threshold - debounce -> envelope.noteOff()

getting velocity :
The idea : once a note is trigger, you wait a few milliseconds (3 to 10) then mesure FSR output. Use a elapsedMillis(), not delay() !
Depending how hard you hit your key, the mesure will give you a good estimation of the velocity. Map the result to the velocity range you target. Then, use an amp object to adjust oscillator output volume.
This is the best method I have found. You don't have to wait for a peak, which reduces latency. A few ms is unnoticeable.

Modulating amplitude :
Use dc + multiply


dc.amplitude(FSR output, smoothTime)
You have to condition FSR output to (0,1) range. smootTime (milliseconds) helps a lot to smooth the effect.

Hope it helps !