|
From: | Rick T |
Subject: | Re: Frequency sweep range issue |
Date: | Mon, 4 Jul 2016 03:34:47 -0400 |
%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.)
clc
clear all
freq1=0;
freq2=1000;
fs_rate=44100;
len_in_sec=10;
total_samples=len_in_sec*fs_rate;
t=linspace(0,2*pi*(total_samples/fs_rate),total_samples); %
f=freq1:(freq2-freq1)/length(t):freq2-(freq2-freq1)/length(t);
data=""
wavwrite([data'] ,fs_rate,32,strcat('/tmp/del.wav')); %export file
BorgeThis is driving me nuts, is there something which I (and a lot of other guys online) have missed?The code below will illustrate the problem. Exporting a .wav or using soundsc doesn't change anything, the output frequency span is doubled.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.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.)
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.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);
end;
t=0:1/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
address@hidden
https://lists.gnu.org/mailman/listinfo/help-octave
[Prev in Thread] | Current Thread | [Next in Thread] |