Wonky
2006-10-12 06:39:02 UTC
I need an audio chirp, 20Hz-20kHz, 48000 samples/sec, 10 seconds. I
tried
t=0:1/48000:10;
x=linspace(20,20000,length(t));
s=sin(2*pi.*x*t); # generate the chirp
sm=(s*((2^15)-1))+(2^15); # use 16 bit signed integers, rather than
floats
That produced a chirp at 48000 samples/sec, for 10 seconds; fft of the
whole thing indicated success, but piecewise fft revealed that it
increased linearly in frequency to 24kHz after 6 seconds, then fell
back to about 8200Hz. It appears to be a chirp from 20Hz to about
42kHz. I tried replacing the "linspace..." line with
x=(1998*t) + 20;
since that produces a linearly increasing quantity from 20 to 20000,
but it made no difference (I compared the result of linspace(...) and
this; the maximum variation was less than 10^-12).
Can anyone see what I've done wrong, and/or suggest a better way to
achieve what I want?
TIA
fishcustard
tried
t=0:1/48000:10;
x=linspace(20,20000,length(t));
s=sin(2*pi.*x*t); # generate the chirp
sm=(s*((2^15)-1))+(2^15); # use 16 bit signed integers, rather than
floats
That produced a chirp at 48000 samples/sec, for 10 seconds; fft of the
whole thing indicated success, but piecewise fft revealed that it
increased linearly in frequency to 24kHz after 6 seconds, then fell
back to about 8200Hz. It appears to be a chirp from 20Hz to about
42kHz. I tried replacing the "linspace..." line with
x=(1998*t) + 20;
since that produces a linearly increasing quantity from 20 to 20000,
but it made no difference (I compared the result of linspace(...) and
this; the maximum variation was less than 10^-12).
Can anyone see what I've done wrong, and/or suggest a better way to
achieve what I want?
TIA
fishcustard