only if you actually have to compute the exp (directly). the best optimization of exp is of course to avoid calling exp() completely and replace it by something cheaper like a multiplication
The best method of create custom envelopes
-
Music Engineer Music Engineer https://www.kvraudio.com/forum/memberlist.php?mode=viewprofile&u=15959
- KVRAF
- 4292 posts since 8 Mar, 2004 from Berlin, Germany
- KVRAF
- 7896 posts since 12 Feb, 2006 from Helsinki, Finland
It might be worth observing here that Gaussians can be approximated by uniform B-spline basis functions. Since they converge reasonably fast (at least as far as the main "bump" goes) and can be formulated in terms of repeated convolution with a boxcar, they are one of the faster ways to approximate a Gaussian-blur (well, other than multi-resolution approaches)... but they can also be used for envelope purposes, for example to get brickwall limiters (ie. use a max-window convering support, then smooth it out by repeated boxcar and you get a smooth envelope that is guaranteed to never let anything over the limit).
-
- KVRAF
- 7402 posts since 17 Feb, 2005
The formula is supposed to be "normalized" on the x axis to define end points to an envelope for instance. So when the s variable is set larger, the function is more accurate near Y zero. This should help realize a longer decay that fits the function before it tapers off to 0.Music Engineer wrote: ↑Wed Jul 14, 2021 12:12 pm seems like the approximation gets better for narrower gaussians, so it would seem to be advisable, to use a large s and pre-scale the input accordingly. but i think, the range of shapes produced by the formula is quite interesting in it's own right.
I haven't been experimenting as much recently, it would help to refresh my memory what the specific formula is to analytically create a "second order" decay curve. Gaussian is not what I had in mind, but now I see that's exactly what I did
-
Music Engineer Music Engineer https://www.kvraudio.com/forum/memberlist.php?mode=viewprofile&u=15959
- KVRAF
- 4292 posts since 8 Mar, 2004 from Berlin, Germany
yes! that does indeed work! i have now figured out a recursion that uses just 3 complex multiplications per sample and can synthesize signals like this one:Music Engineer wrote: ↑Wed Jul 14, 2021 12:12 pm i think, it may be worthwhile to explore this stuff further. maybe we can create sinusoids with gaussian envelopes aka "gaborets" by using a complex version of the recursion and/or compute things like y(x) = exp(i*p(x)) where p(x) is a polynomial and i the imaginary unit...i guess that may be useful to recursively create sinusoids with a polynomial frequency envelope ...as are needed in additive synthesis and sinusoidal modeling (typically cubic) ....more stuff to explore....
a sine/cosine sweep with a gaussian(ish) envelope. the instantaneous phase and log of instantaneous amplitude can both be defined as cubic polynomials, so simpler exponential envelopes are possible too (and constant ones of course also). here is the math*:
https://github.com/RobinSchmidt/RS-MET/ ... ursion.txt
and here is the code (class rsSineSweepIterator):
https://github.com/RobinSchmidt/RS-MET/ ... terators.h
https://github.com/RobinSchmidt/RS-MET/ ... rators.cpp
i think, this may be useful for an additive synthesis engine. i think, i'll do one soon...
(*) yesyesyes - i know - i have just rediscovered incremental polynomial evaluation by forward differences. it's basically this idea here:
https://www.google.de/books/edition/Cur ... frontcover
with an exponential function thrown on top of it which turns the additions into multiplications. vadim mentioned it on page one, too. and the numerical stability of the method is a bit ...hmm...well...care has to be taken. we'll see...
You do not have the required permissions to view the files attached to this post.
Last edited by Music Engineer on Sun Jul 18, 2021 9:11 pm, edited 3 times in total.
-
Music Engineer Music Engineer https://www.kvraudio.com/forum/memberlist.php?mode=viewprofile&u=15959
- KVRAF
- 4292 posts since 8 Mar, 2004 from Berlin, Germany
now i'm getting curious. what else could "2nd order decay" mean if not gaussian? i mean (exp(a*t))^2 is just exp(2*a*t) so that would not be a new shape but merely another exp-decay just with a shorter decay time
Last edited by Music Engineer on Sun Jul 18, 2021 8:33 pm, edited 1 time in total.
- KVRAF
- 40265 posts since 11 Aug, 2008 from clown world
http://www.youtube.com/watch?v=Zv5YRAg5z-Y
How to make paper Envelope -No glue or tape, very easy DIY
How to make paper Envelope -No glue or tape, very easy DIY
Anyone who can make you believe absurdities can make you commit atrocities.
-
- KVRAF
- 7402 posts since 17 Feb, 2005
Just the step response of a critically damped second order lowpass, analytically. That is not the gaussian curve, is it??Music Engineer wrote: ↑Sun Jul 18, 2021 7:26 pm now i'm getting curious. what else could "2nd order decay" mean if not gaussian?
- KVRAF
- 7896 posts since 12 Feb, 2006 from Helsinki, Finland
2nd order term would be something like a*t*exp(a*t).Music Engineer wrote: ↑Sun Jul 18, 2021 7:26 pmnow i'm getting curious. what else could "2nd order decay" mean if not gaussian? i mean (exp(a*t))^2 is just exp(2*a*t) so that would not be a new shape but merely another exp-decay just with a shorter decay time
edit: ...and to answer the question as to why would this be "2nd order" I suggest you take the Laplace transform and it should become rather obvious.
-
Music Engineer Music Engineer https://www.kvraudio.com/forum/memberlist.php?mode=viewprofile&u=15959
- KVRAF
- 4292 posts since 8 Mar, 2004 from Berlin, Germany
ah - ok - i see. we are talking about a 2nd order filter here. i guess, i was thinking too much about polynomials recently. ...and no, it's not a gaussian shape. see here:
https://lpsa.swarthmore.edu/Transient/T ... tml#Case_2
y(t) = 1 - exp(-w0*t) - w0*t*exp(-w0*t)
btw. - i tend to think, tacking a half-wing of a gaussian to a flat sustain may actually be quite nice. if i'm not mistaken, the transition should be infinitely smooth (all derivatives of the gaussian are zero at t=0). of course, whether that matters or not from a musical point of view is a different question. but i think, it's somehow mathematically satisfying
edit: wait - no - that was wrong. not all derivatives are zero
https://lpsa.swarthmore.edu/Transient/T ... tml#Case_2
y(t) = 1 - exp(-w0*t) - w0*t*exp(-w0*t)
btw. - i tend to think, tacking a half-wing of a gaussian to a flat sustain may actually be quite nice. if i'm not mistaken, the transition should be infinitely smooth (all derivatives of the gaussian are zero at t=0). of course, whether that matters or not from a musical point of view is a different question. but i think, it's somehow mathematically satisfying
edit: wait - no - that was wrong. not all derivatives are zero
Last edited by Music Engineer on Mon Jul 19, 2021 11:31 am, edited 1 time in total.
-
- KVRAF
- 7402 posts since 17 Feb, 2005
Thank you, that is the function I was looking for.mystran wrote: ↑Sun Jul 18, 2021 11:15 pmMusic Engineer wrote: ↑Sun Jul 18, 2021 7:26 pmnow i'm getting curious. what else could "2nd order decay" mean if not gaussian? i mean (exp(a*t))^2 is just exp(2*a*t) so that would not be a new shape but merely another exp-decay just with a shorter decay time
2nd order term would be something like a*t*exp(a*t).
edit: ...and to answer the question as to why would this be "2nd order" I suggest you take the Laplace transform and it should become rather obvious.
-
- KVRAF
- 7402 posts since 17 Feb, 2005
It's always useful to have another envelope variety. I think mixing them is where the challenge is. Sometimes for example I have wanted to smooth out a rough breakpoint and the only option is to add another breakpoint and wiggle them around. The worst thing that could happen there is one audible discontinuity becomes two of them. Smooth breakpoints are good sometimes, other times they aren't useful at all, so YMMV.Music Engineer wrote: ↑Sun Jul 18, 2021 11:48 pm btw. - i tend to think, tacking a half-wing of a gaussian to a flat sustain may actually be quite nice. if i'm not mistaken, the transition should be infinitely smooth (all derivatives of the gaussian are zero at t=0). of course, whether that matters or not from a musical point of view is a different question. but i think, it's somehow mathematically satisfying
-
- KVRAF
- 1607 posts since 12 Apr, 2002
Actually 2nd order filter's response is more like a sum (or rather a difference, I guess) of two exponents of different speeds. Like a difference of two 1-pole filters. The term t*exp(-t) appears as a limiting case of such difference when the poles (1 pole cutoffs) become identical. If there is a resonance then we have a decaying sinusoidal term instead (with the same t*exp(-t) limit as the resonance becomes small).Music Engineer wrote: ↑Sun Jul 18, 2021 11:48 pm ah - ok - i see. we are talking about a 2nd order filter here. i guess, i was thinking too much about polynomials recently. ...and no, it's not a gaussian shape. see here:
https://lpsa.swarthmore.edu/Transient/T ... tml#Case_2
y(t) = 1 - exp(-w0*t) - w0*t*exp(-w0*t)
btw. - i tend to think, tacking a half-wing of a gaussian to a flat sustain may actually be quite nice. if i'm not mistaken, the transition should be infinitely smooth (all derivatives of the gaussian are zero at t=0). of course, whether that matters or not from a musical point of view is a different question. but i think, it's somehow mathematically satisfying
The Art of VA Filter Design 4.8 and p.129 in particular.
- KVRist
- Topic Starter
- 338 posts since 17 Feb, 2013 from Sayan Mountains, Siberia
By the way, I'm testing this exponent function to calculate the envelope slope. Maybe someone will come in handy.Music Engineer wrote: ↑Wed Jul 14, 2021 1:33 pm only if you actually have to compute the exp (directly). the best optimization of exp is of course to avoid calling exp() completely and replace it by something cheaper like a multiplication
Code: Select all
inline double fastexp(double x) noexcept
{
return (1680 + x * (840 + x * (180 + x * (20 + x)))) / (1680 + x * (-840 + x * (180 + x * (-20 + x))));
}
¤ stone-voices.ru ¤
- KVRist
- Topic Starter
- 338 posts since 17 Feb, 2013 from Sayan Mountains, Siberia
Finally, I deigned to take the time to implement a complex envelope generator for the synthesizer being developed.
The book Daniel R. Mitchell "BasicSynth" helped me a lot in this, section Envelopes: Curved Segments.
I designed the freeform envelope generator and its accompanying visual control for editing the envelopes:
The book Daniel R. Mitchell "BasicSynth" helped me a lot in this, section Envelopes: Curved Segments.
I designed the freeform envelope generator and its accompanying visual control for editing the envelopes:
¤ stone-voices.ru ¤