samples = wavread('onsei3');
nsamples = length(samples);
nframes = floor((nsamples-N)/(N/4))+1;
samples2D = zeros(N,nframes);
for frame=1:nframes
ns = 1+(N/4)*(frame-1);
ne = N+(N/4)*(frame-1);
samples2D(:,frame) = samples(ns:ne);
end
spectrum2D = zeros(N,nframes);
for frame=1:nframes
spectrum2D(:,frame) = fft(samples2D(:,frame).*hamming(N));
end
mag_fft2D = abs(spectrum2D);
arg_fft2D = angle(spectrum2D);
spectrum2D = mag_fft2D.*exp(j*arg_fft2D);
output2D = zeros(N,nframes);
for frame=1:nframes
output2D(:,frame) = real(ifft(spectrum2D(:,frame)));
output2D(:,frame) = output2D(:,frame).*hamming(N);
end
output = zeros(nsamples,1);
for frame=1:nframes
ns = 1+(N/4)*(frame-1);
ne = N+(N/4)*(frame-1);
output(ns:ne) = output(ns:ne)+output2D(:,frame);
end
output = output/max(abs(output))*0.95;
wavwrite(output, 16000, 'onsei3_enh.wav')
Similar Posts: