[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Frequency sweep range issue

From: Rick T
Subject: Re: Frequency sweep range issue
Date: Mon, 4 Jul 2016 03:34:47 -0400

This may help

%Please note with the following values when t=5 frequency will be 1000hz %and at t=10 frequency will be 2000hz.  (freq2=1000 is only the half way %point with swept signals.)

clear all
t=linspace(0,2*pi*(total_samples/fs_rate),total_samples); %


wavwrite([data'] ,fs_rate,32,strcat('/tmp/del.wav')); %export file

On Sun, Jul 3, 2016 at 12:13 PM, Børge Strand-Bergesen <address@hidden> wrote:
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,


f_start = 20; % Frequency in Hz
f_end = 200;
fs = 44100; % sample rate in Hz
res = 24; % bits
dur = 10; % duration in seconds

clear f t;
for n = 0:fs*dur
  f(n+1) = f_start + (f_end - f_start) * n / (fs * dur);
x = 0.5*sin(2*pi*f.*t);

% Straight line from 20 to 200
plot (f);

% Sweeps from 20 to 380Hz
wavwrite ([x' x'], fs, res, "c:/music/Test_wav/sweep_20_200_24_6dB.wav");

% Sweeps from 20 to 380Hz
soundsc (x, fs);

% Spot-on 200Hz playback
y = 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 y
hold off
plot (x(440000: 441001), 'r');
hold on
plot (y(440000: 441001), 'b');

Help-octave mailing list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]