-
Notifications
You must be signed in to change notification settings - Fork 4
DEVICES: blepsynth/blepsynth.cc: introduce flexible ADSR model #6
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
Conversation
As discussed previously, to support this:
commit 9b0dd6a now calls a |
Thank you, that sounds very interesting.
Ok, I'm working on finishing up a branch that supports headless and possibly offline rendering.
As previously discussed, it would probably make sense to clean such design scripts up and put them into a dedicated "research" repo. |
|
||
double level_ = 0; | ||
a_ = slope * ( 1.0135809670870777f + slope * (-1.2970447050283254f + slope * 7.2390617313972063f)); | ||
b_ = slope * (-5.8998946320566281f + slope * ( 5.7282487210570903f + slope * -15.525953208626062f)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be interested to see some performance numbers if it really helps to make the calculations here carried out on floats instead of doubles...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a benchmark here:
https://github.com/tim-janik/dsp-research/blob/trunk/flexadsr/perffloat.cc
Results on my Ryzen 7:
ryzen7$ time perffloat float
real 0m0,555s
user 0m0,555s
sys 0m0,000s
ryzen7$ time perffloat double
real 0m0,657s
user 0m0,656s
sys 0m0,001s
My experience is that floats are not faster than doubles, but on modern systems conversion between floats and doubles has a performance cost. So since we in the inner loop of the ADSR we need floats for a_, b_ and c_, and since if we were modulating these parameters we would likely have a source buffer of floats, it is best to avoid converting to doubles and back for evaluating the polynomials.
Of course it could well be that for modulation we would evaluate the polynomials only every 16 samples (or so) then the conversion cost would not be too bad
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For reference, on a 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz:
$ time ./perffloat "float"
real 0m0,364s
user 0m0,364s
$ time ./perffloat "double"
real 0m0,455s
user 0m0,455s
Please update/rebase the patch. |
9b0dd6a
to
21a6413
Compare
I've rebased the patch. |
Btw, I did some performance tests in SpectMorph and in the dsp-research repo. I also found a few opportunities to optimize the code. The result is that I wouldn't worry about the FlexADSR cpu usage at all, it is a lot cheaper than the other parts of the bleposc (namely the filters and the osc code). |
Please rebase |
- volume envelope can now be analog (exponential) or flexible - flexible envelope has adjustable attack/decay/release slope - support changing volume/filter envelope params while note is playing Signed-off-by: Stefan Westerfeld <[email protected]>
21a6413
to
f9525e2
Compare
Signed-off-by: Stefan Westerfeld <[email protected]>
f9525e2
to
372c5d3
Compare
Done. Great to see that you found some time to merge the other BlepSynth PR. |
From the commit message:
To be honest, the difference between analog and flexible envelope is not that big in practice. I could add a digital ADSR, but I guess since analog vs. flexible is not too different, it is probably not that important, flexible should cover configurable slope cases quite well.
Comments:
I've put the tools here: https://space.twc.de/~stefan/download/nadsr/ - if you want to I can clean these up a bit.