## mass-springs 2

addendum to the previous post 🙂

following a discussion at kvraudio with practiced persons such as mr. dsp himself (duncan s. parsons), further examination of this algorithm has been made.

calibration of decay time is achieved via mr. parsons keen observation that

gain at sample n = gain ^ n

go figure 🙂 as a “do things with numbers guy” (sort of the INT version of a more erudite developer) i have avoided even the simplest use of decibels. i managed to deduce that the decay time to a peak of 1/10th the initial can be calculated by:

gain = pow(0.01, 1 / samples);

lacking the methods to make observations at keener precision, i found more elementary ways to adapt this to a more serviceable decay amplitude, availing the exponential curve of the decay.

it was also posed that the oscillator form would also be useful if initialised at zero instead of in cosine form. investigation prompted me to conclude that a gain conforming sine can be derived by using an initial velocity instead of an initial position, and a cursory observation of the relation of angular frequency and peak amplitude. thereafter, arbitrary phase is trivial. i will leave the derivation to the gentle reader 🙂

..if that reader is as gentle as i (not more and not less) they will observe that the most straightforward way of modifying the initial position and initial velocity to produce arbitrary phase once more affects the amplitude of the oscillation:

0, 90, 180, 270° seem to adhere to strict unity gain.

45° offsets slightly increase gain, and the intermittent multiples of 30° i tried slightly decreased gain. in both cases by less than 1/10th, so suitability for audio applications may not be strongly affected. without further analysis i of course expect that this modulation of gain between the 90° cardinal points has some kind of continuous response, which, for the time being, escapes my procedural consideration.

If you want to offer the standard T60 decay time, change your equation to

gain = pow(0.001, 1/samples);

0.001 is 1/1000th of the original amplitude, which corresponds to -60 dB. Hence the “60” in T60.

I know that some other time constant is often used in filter decays, but I can’t remember it offhand. I am using the above equation in some of my filter smoothing code, with the name “CalculateTau,” but I don’t know if it corresponds to the standard EE definition of tau. I’m not a double e, and my code seems to work just fine for smoothing things internally, so there you go.

Congratulations on the new blog, BTW. It looks like it will have some useful info.

seancostelloJune 1, 2011 at 12:17 am

🙂 *indicates the valhalladsp blog to dsp readers*

RT60 doesn’t work here..

asomers:

“By the time we hit fs*t60, the peak value is at -33 db.”

http://www.kvraudio.com/forum/viewtopic.php?t=319767

the 1/10th amplitude time uses a base of .01 instead of 0.1 🙂

my blog-writing brain says that, using this .01 base, t60 would be produced by using 3 / samples. it isn’t.

during testing i could approximate -60dB with 7 / samples.. -40 with 5 / samples, and so on.. i expect this isn’t quite accurate. i’ll have to look into tau (chamberlin’s microprocessors just arrived as did perry cook’s interactive applications)!

this fellow has posted a collection of physics applets.. this one seems especially intriguing for signal processing.. 🙂

http://www.falstad.com/coupled/

xoxosvstJune 1, 2011 at 3:51 am