Closed DBraun closed 8 months ago
I am a bit confused here: does this PR is a more general version of https://github.com/grame-cncm/faustlibraries/pull/159 and so replace it ?
I think it's a more general version, and I would choose it over the other. The other has a different bias curve, but it also only biases in one direction. I have also implemented legato. So for those reasons I will probably find myself using adsr_bias and not adsrfqqq. If both sets of functions get added we can think harder about what the best names would be to distinguish them. Also, in the adsr_bias
functions you can see how the bias
parameter has a very smooth effect on the envelope. The colored lines in the graphs are nicely spaced from each other. But in the adsrfqqq functions the lines are more clumped together for low and high q
values.
Then better keep a single version, OK for you @marchingband ?
Oh wow this is awesome! It's ok with me 100%.
Legato is a great option.
Are you considering adding final
?
I’ll try that tonight. I will probably want a shortcut for a version without final however.
The functions are now
adsr_bias_final
adsr_bias
(same as previous but without final parameter)ahdsr_bias_final
ahdsr_bias
(same as previous but without final parameter)FaustIDE Demo
I kept finding issues with the initial values due to the final
feature. I think it's ok now.
I also changed it to these names:
adsrf_bias
adsr_bias
ahdsrf_bias
ahdsr_bias
Here's a demo.
"Error: URI Too Long" on the demo link
Ah ok we'll have to copy paste from https://gist.github.com/DBraun/6b73b9b69300775f4eb68d2c5551d944
Is the PR considered ready to be merged ?
The only thing I'm unsure about is the usage of it.remap.
pct = it.remap(from1, from2, 0, 1, y), 0.5 : select2(from1==from2) : bias_curve_inverse(b);
Is this sufficient to prevent a divide by zero? Or is more necessary such as
pct = it.remap(from1, from2+ba.if(from1==from2,1,0), 0, 1, y), 0.5 : select2(from1==from2) : bias_curve_inverse(b);
Thanks, merged.
This adds two new functions
adsr_bias
andahdsr_bias
.Each function has three arguments to control the "bias" of the attack, decay, and release segments. This is implemented by using the derivative of a specific bias function: For every new sample of audio, we calculate a desired slope and add it to the state. Because this is a discrete method, the curves don't hit their target at the exact target time, but it's quite good. For example there are high errors if the bias is high in the decay or release (see graphs below).
This method is advantageous over https://github.com/grame-cncm/faustlibraries/pull/159 because the bias can bend the curve either up or down whereas that PR just allows pulling it up.
There is also a toggle for legato. If legato is on, then on re-trigger, the envelope is resumed wherever it left off. If legato is off, then the envelope always starts at zero.
Here are some images demonstrating usage of the functions. In the
adsr_bias
graphs, the settings are: attack: 1 decay: .5 sustain: varies release: 0.5 note length: variesIn the
![Unknown-5](https://github.com/grame-cncm/faustlibraries/assets/2096055/2baad99e-9812-44db-9b6d-cc4f69ddbb5e)
ahdsr_bias
graphs, the settings are: attack: 0.5 decay: .5 sustain: varies release: 0.5 note length: varies