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:
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.
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);
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.