I'm trying to develop an expression to produce a sweep tone that crawls along the logarithmic scale from frequency x to frequency f with an amplitude of y, based upon
sin(2*pi*f*t)
in which I substitute an exponential function for f to produce the sweep crawl. However, it doesn't seem to behave as I would expect.
Using x=20, f=20000, and y=1, and the epxression (so far):
y*sin(2*pi*(2^((log(x)/log(2))+((n/N)*((log(f)/log(2))-(log(x)/log(2))))))*t)
The following fragment of the expression produces 20Hz (value for x) sinewave (as I would expect)
y*sin(2*pi*(2^((log(x)/log(2))))*t)
The following modification of the expression produces 20kHz (value for f) sinewave (as I would expect)
y*sin(2*pi*(2^((log(x)/log(2))+((1)*((log(f)/log(2))-(log(x)/log(2))))))*t)
Yet if I substitute (n/N) for the (1) above, which I would expect to go from 0 to 1, causing the frequency to up the scale from x to f, the results crawl way beyond f, leaving me confused.
Can anybody offer any insight into what I am doing wrong?
Expression for Log Scale Sweep Tone
-
- Site Admin
- Posts: 4372
- Joined: Wed Mar 10, 2004 6:43 pm
- Location: St. John's, NL
- Contact:
Re: Expression for Log Scale Sweep Tone
The frequency varying function cannot be used directly. You need to use the integral of the frequency function.
Re: Expression for Log Scale Sweep Tone
Thank you for the reply! I didn't receive notification that you had, but recently decided to revisit this project and found your reply.
I'll adjust the expression to use the integral variation and give it a shot. Thank you!
I'll adjust the expression to use the integral variation and give it a shot. Thank you!
Re: Expression for Log Scale Sweep Tone
The following expression produces a sweep tone on log scale; x=duration in seconds, y=start frequency, f=end frequency. The first sample will be 0, the final sample may not (depending on how the end frequency lines up with axis crossing), so depending on how clean a transition is needed (for looping, etc...) may want to make the file a little longer and manually trim to zero-crossing.
sin(((2*pi*y*x)/(ln(f/y)))*(exp(((ln(f/y)*t)/x))-1))
sin(((2*pi*y*x)/(ln(f/y)))*(exp(((ln(f/y)*t)/x))-1))