Forums > MaxMSP

Desperately Seeking: Efficient modulation depth

April 23, 2006 | 9:18 pm

An LFO puts out a signal between 1 and -1. If the desired output shall oscillate between 2 and 0.5, I input my mod depth as 2

So to set the modulation depth (d) of the modulating signal (m) I use

output=input.(m to the power of d)

Is there a more efficient way of doing this ? pow~ is hardly a processor friendly method :-)

Thanks,

Stuart Grimshaw


April 24, 2006 | 3:40 am

mul and add?
like lfo~ -> *~ 0.75 (to make the range 1.5) -> +~ 1.25

max v2;
#N vpatcher 171 442 403 715;
#P origin 0 4;
#P window setfont "Sans Serif" 9.;
#P user number~ 116 163 189 178 9 3 3 2 0. 0. 0 0. 250 0. 0 0 0 221
221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 90 140 46 196617 +~ 1.25;
#P toggle 31 146 15 0;
#P newex 66 186 31 196617 dac~;
#P user number~ 115 117 188 132 9 3 3 2 0. 0. 0 0. 250 0. 0 0 0 221
221 221 222 222 222 0 0 0;
#P newex 90 89 47 196617 *~ 0.75;
#P newex 90 64 58 196617 cycle~ 0.1;
#P connect 4 0 3 0;
#P connect 0 0 1 0;
#P connect 1 0 5 0;
#P connect 1 0 2 0;
#P connect 5 0 6 0;
#P pop;

Jonathan Segel 4014 Brookdale Ave. Oakland, CA 94619
jsegel@magneticmotorworks.com < -----> magsatellite@yahoo.com


April 24, 2006 | 5:14 am

Do you want a wave that spends as much time between 0.5 and 1 as it
does between 1-2 (implying an exponential distortion) or do you want a
wave that is simply balanced between 0.5 and 2 (with a center of 1.25)

If it’s the latter, I have an abstraction, PM.Scale~, that does this
with matrix~ which is very fast. If it’s the former, you could try
doing a lookup table. In all likelihood, there’s not going to be that
many log scales that you’d need (especially if it’s just for an lfo)
and the difference between them will eventually be negligible given
enough samples. Store the log scales in a buffer, and use the exponent
to set the offset into the buffer~. (use a phasor~ to drive a wave~
for this, and have the offset points pass through a sah~ so you only
grab a new offset at the beginning of the cycle)

Alternately, if pow~ is too expensive, you could try putting it in a
poly~, downsampling it n times, and then using rampsmooth~ on the
output.

Peter McCulloch


April 24, 2006 | 8:19 am

I forgot to add that when the LFO outputs zero, then I need a value of 1.
So I guess it’s the exponential that I’m after (anyone know a site for people who haven’t even thought about maths for twenty five years ?).

I had already considered the wave~ lookup solution, maybe even the 2dwave~, which is a bit above me but I might as well get stuck into it now.

Thanks for the suggestions.


Viewing 4 posts - 1 through 4 (of 4 total)