%REQUIRES twotrumpetsAB.mat FROM CD
clear;load 'twotrumpetsAB.mat'
fs=44100;fr=436;%reject note A
L=length(X);FX=fft(X)/L;FY=FX;
NF=round(fr*L/fs);%fundamental index
%K=indices where spectra set to 0:
K=[];for N=1:9;
K=[K ([-30:30]+N*NF)];end
K=[K L+2-K];%append conjugate indices
FY(K)=0;%set harmonics of f to 0.
Y=L*real(ifft(FY));
%Plot time waveforms and spectra:
I=[1000:1199];t=I/fs;%display
subplot(211),plot(t,X(I))
subplot(212),plot(t,Y(I))
F=[1:5000];f=(F-1)*fs/L;figure
subplot(211),plot(f,abs(FX(F)))
subplot(212),plot(f,abs(FY(F)))
soundsc(X,fs),pause,soundsc(Y,fs)
