%REQUIRES trumpet.mat FROM CD
clear;load 'trumpet.mat'
NS=0.1;T=0.0015;fs=44100;
L=length(X);
N=NS*randn(1,L);Y=X+N;%noisy
FY=fft(Y)/L;FZ=FY;
FZ(find(abs(FY)<T))=0;
Z=L*real(ifft(FZ));
SNR=10*log10(sum(X.*X)/sum(N.*N))
%Plot time waveforms and spectra:
I=[1000:1199];t=I/fs;%display
subplot(211),plot(t,Y(I))
subplot(212),plot(t,Z(I))
F=[1:5000];f=(F-1)*fs/L;figure
subplot(211),plot(f,abs(FY(F)))
subplot(212),plot(f,abs(FZ(F)))
soundsc(Y,fs),pause,soundsc(Z,fs)
