6
$\begingroup$

I want to excite a loudspeaker with a constant magnitude chirp that sweeps across all frequencies in the audio band. I downloaded a test file from this Audio Check - High Definition Audio Test Files to start with.

I plot the log magnitude of the file with the following code which I use for other applications as well.

[X Fs nbits] = wavread('audiocheck.net_hdchirp_96k_-3dBFS_log.wav');
X = X(:,1);
fft_prep = fftshift(fft(X));
fft_mag = real(fft_prep).^2 + imag(fft_prep).^2;
pos_fft=fft_mag(ceil(length(fft_mag)/2+1:length(fft_mag)));
db_fft=20*log10(pos_fft);
figure(1);
plot(linspace(0,48000,length(db_fft)), db_fft);

I see this graph:

sweep

I was hoping to see a constant magnitude response. A friend of mine mentioned something about how Parseval's Theorem states that there will be different energy in different frequencies. I found this link that talks about Parseval's Theorem and also says in the section "Spectral features and energy of chirps":

Important and desired spectral properties of excitation signals to improve the quality of wideband measurement are: flat amplitude spectrum with minimal fluctuation (ripple) together with the absence of overshoots inside the generated (excitation) bandwidth Bexc =ffin - fst; steep drop-down of the amplitude spectrum outside the bandwidth Bexc; maximal energy-efficiency, i.e., the ratio between the energy lying within the generated (excitation) bandwidth Bexc and total energy of the signal.

good chirps

To avoid worrying about a chirp someone else made. I am also trying to generate a chirp in Matlab and I am seeing the following response with:

t = 0:0.001:10;      % 10 seconds @ 1kHz sample rate
fo = 10; f1 = 400;   % Start at 10Hz, go up to 400Hz
X = chirp(t,fo,10,f1,'logarithmic');
fft_prep = fftshift(fft(X));
fft_mag = abs(fft_prep);
pos_fft = fft_mag(ceil(length(fft_mag)/2)+1:length(fft_mag));
db_fft = 20*log10(pos_fft);
figure(1);
plot(linspace(fo,f1,length(db_fft)), db_fft);

enter image description here

How can I generate a relatively constant magnitude sweep across the audio range in Matlab like I see in figure 8 above? Any advice is welcome and I appreciate the help.

$\endgroup$

1 Answer 1

3
$\begingroup$

If you change the "X = chirp(t,fo,10,f1,'logarithmic');" to "X = chirp(t,fo,10,f1,'linear');" you will get the response that you want.

To have the energy be equal it must spend an equal amount of time at each frequency. With the linear sweep it does that. With the logarithmic sweep it spends more time at the lower frequencies and much less time at the higher frequencies, resulting in unequal energy.

$\endgroup$
1
  • $\begingroup$ Excellent, thank you! I also found a bug in my code where I plotted versus the linspace from the lowest frequency to the highest, where I should have been plotting to the full length of the signal. $\endgroup$ Commented Mar 15, 2013 at 19:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.