[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Frequency sweep range issue
From: |
Andreas Stahel |
Subject: |
Re: Frequency sweep range issue |
Date: |
Sun, 3 Jul 2016 18:58:32 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
Børge Strand-Bergesen <borge.strand <at> gmail.com> writes:
>
>
>
>
>
>
>
> Hi guys,
> I'm writing a diy chirp function to generate an audio test signal. My code
is virtually identical to several examples I find on line. I test the
generated audio signal frequency on a digital oscilloscope using a USB DAC
for playback. (The DAC is the actual device under test, but it does not mess
up frequencies.)
> The weird thing is: When I specify a start and stop frequency, the
resulting chirp starts at the right place but then goes in frequency by
twice the gab between start and stop.
> The code below will illustrate the problem. Exporting a .wav or using
soundsc doesn't change anything, the output frequency span is doubled. When
I plot the frequency variable, everything looks fine. As is the
> case when I use the same kind of code to generate a static frequency. And
chirp() seems to generate correct output.
> This is driving me nuts, is there something which I (and a lot of other
guys online) have missed?
>
> System is Win10/64 with a fresh install of Octave 4.0.3.
>
> Thanks for your input,
> Borgef_start = 20; % Frequency in Hzf_end = 200;fs = 44100; % sample rate
in Hzres = 24; % bitsdur = 10; % duration in secondsclear f t;for n =
0:fs*dur f(n+1) = f_start + (f_end - f_start) * n / (fs *
dur);end;t=0:1/fs:dur;x = 0.5*sin(2*pi*f.*t);% Straight line from 20 to
200plot (f);% Sweeps from 20 to 380Hzwavwrite ([x' x'], fs, res,
"c:/music/Test_wav/sweep_20_200_24_6dB.wav");% Sweeps from 20 to
380Hzsoundsc (x, fs);% Spot-on 200Hz playbacky = 0.5 *
sin(2*pi*200.*t);soundsc (y, fs);% Trying the same thing with chirp()y = 0.5
* chirp([0:1/fs:10], 20, 10, 200, "linear");% Comparing, x looks like a bit
more than twice the frequency of yhold offplot (x(440000: 441001), 'r');hold
onplot (y(440000: 441001), 'b');
>
>
> _______________________________________________
> Help-octave mailing list
> Help-octave <at> gnu.org
> https://lists.gnu.org/mailman/listinfo/help-octave
>
Hello
The frequency of the signal u(t) = sin(f(t)) is related to the derivative
v(t) = df(t)/dt. You construction might contain a "hidden" quadratic
contibution.
Consider
omega(t) = omega0 + t*(omega_end-omega_0)/(t_end-t0)
and then
u(t) = sin(omega(t)*t)
now f(t) = omega(t)*t
and df(t)/dt = omega(t) + (omega_end-omega_0)/(t_end-t0)*t
and off you go at twice the expected frequency
I hope it helps
Andreas