% spectra.m displays the spectra of some notes, chords, and spoken sounds p=2^(1/12); % frequency multiplier between notes t=1:44100; % vector of time indices a =sin(440*2*pi*t/44100); % define an a as=sin(440*(p^1)*2*pi*t/44100); b =sin(440*(p^2)*2*pi*t/44100); c =sin(440*(p^3)*2*pi*t/44100); cs=sin(440*(p^4)*2*pi*t/44100); d =sin(440*(p^5)*2*pi*t/44100); ds=sin(440*(p^6)*2*pi*t/44100); e =sin(440*(p^7)*2*pi*t/44100); f =sin(440*(p^8)*2*pi*t/44100); fs=sin(440*(p^9)*2*pi*t/44100); g =sin(440*(p^10)*2*pi*t/44100); gs=sin(440*(p^11)*2*pi*t/44100); a2 =sin(440*(p^12)*2*pi*t/44100); % a one octave up a3 =sin(440*(p^24)*2*pi*t/44100); % another octave up a_spectrum = fft(a); % spectrum is the fast Fourier transform a_spectrum(1)=1; chord=a+cs+e; chord = chord/(max(abs(chord))); chord_spectrum = fft(chord); chord_spectrum(1)=1; [sa]=wavread('a.spoken.out'); % read spoken a data sa_spectrum=fft(sa); sa_spectrum(1)=1; [se]=wavread('e.spoken.out'); % read spoken e data se_spectrum=fft(se); se_spectrum(1)=1; [so]=wavread('o.spoken.out'); % read spoken o data so_spectrum=fft(so); so_spectrum(1)=1; [su]=wavread('oo.spoken.out'); % read spoken oo data su_spectrum=fft(su); su_spectrum(1)=1; ind=1:(44100/20); % indices t=ind/44100; % rescale to be time in seconds subplot(4,2,1) plot(t,a(ind)); title('Pure A (440 Hz)'); axis([0 0.05 -1.2 1.2]); xlabel('Time'); ylabel('Speaker cone location'); subplot(4,2,2) plot(t,chord(ind)); title('A-C#-E chord (440, 554, 659 Hz)'); axis([0 0.05 -1.2 1.2]); xlabel('Time'); ylabel('Speaker cone location'); k=[1:1:900]; % vector of frequencies to plot subplot(4,2,3) plot(k,abs(a_spectrum(k))/5000), text(600,4.5,'Pure A') ylabel('Strength'); xlabel('Frequency'); title('Frequency spectrum for pure A'); subplot(4,2,4) plot(k,abs(chord_spectrum(k))/5000), text(600,1.2,'A-C#-E chord') ylabel('Strength'); xlabel('Frequency'); title('Frequency spectrum for A-C#-E chord'); subplot(4,2,5) plot(k,abs(sa_spectrum(k))/5000), text(600,125,'Spoken a') ylabel('Strength'); xlabel('Frequency'); title('Frequency spectrum for spoken long A'); subplot(4,2,6) plot(k,abs(se_spectrum(k))/5000), text(600,70,'Spoken e') ylabel('Strength'); xlabel('Frequency'); title('Frequency spectrum for spoken long E'); subplot(4,2,7) plot(k,abs(so_spectrum(k))/5000), text(600,50,'Spoken o') ylabel('Strength'); xlabel('Frequency'); title('Frequency spectrum for spoken long O'); subplot(4,2,8) plot(k,abs(su_spectrum(k))/5000), text(600,80,'Spoken oo') ylabel('Strength'); xlabel('Frequency'); title('Frequency spectrum for spoken OO'); orient tall print -deps spectra.eps