MATLAB, Section 2

 

%%  Creating the chirp


fs= 44100;

t= 0: 1/fs: 5 - (1/fs);

y= chirp(t, 20, 5,  20000, 'logarithmic');

y= y';

Y= (fft(y));


%% Creating the Equal Loudness Curve


curve= iso226(0)'; %%%%%%%%%%%%%%%%% Click iso226 to view code


fs_old= 2* (length(curve)/(12500 / ((20000-20)/5)));

C= interp(curve, round(fs/fs_old));


diff= (length(Y)/2) - length(C);

H= flipud(C(1: diff)) + C(length(C));

Ccat= cat(1, C, H);

C2= flipud(Ccat);

CdB= cat(1, Ccat, C2);


EQL= Y + CdB;

eql= real(ifft(EQL));


%%  Plotting

subplot 211

plot(t, y)

axis tight

xlabel('Time (sec)')

ylabel('Amplitude')

title('"Chirp" 20 - 20 kHz Sine wave sweep   ')


subplot 212

f= linspace(0, fs/2, length(EQL)/2);

subplot 212

plot(f, 20*log10(abs(Y(1:length(Y)/2))))

axis tight

xlabel('Freq (Hz)')

ylabel('dB');

title('Magnitude Response')


%%

subplot 211

plot(t, real(eql ))

axis tight

xlabel('Time (sec)')

ylabel('Amplitude')

title('Equal Loudness "Chirp"   ')



f= linspace(0, fs/2, length(EQL)/2);

subplot 212

plot(f, 20*log10(abs(EQL(1:length(EQL)/2))))

axis tight

xlabel('Freq (Hz)')

ylabel('dB');

title('Magnitude Response')



%%

sound(real(eql), fs)

%%

wavwrite(real(eql2), fs, 'Q2 jb eql.wav')


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



%% Creates the Broadband Equal Loudness version.



[y2, fs]= wavread('JamesBrown.wav');

y2= y2(10*fs : ((10 + 5)*fs)- (1/fs))';

Y2= fft(y2);

EQL2= Y2 + CdB;

eql2= real(ifft(EQL2));


%%

subplot 211

plot(t, y2)

axis tight

xlabel('Time (sec)')

ylabel('Amplitude')

title('James Brown, Down in NY City   ')


subplot 212

f= linspace(0, fs/2, length(EQL2)/2);

subplot 212

plot(f, 20*log10(abs(Y2(1:length(Y2)/2))))

axis tight

xlabel('Freq (Hz)')

ylabel('dB');

title('Magnitude Response')


%%

sound(eql2, fs)

%%

sound(y2,fs)


%%


print 'Q2 a jb' -djpeg100 -r200







Back