# HG changeset patch # User emmanouilb # Date 1366463060 -3600 # Node ID 840a4c453edc1f53b4d498ae6dee62bb876389e7 # Parent aeccfa83c7a4278ef82a610986da8732d2a2338f wav -> fft -> wav diff -r aeccfa83c7a4 -r 840a4c453edc wave2fft2wave.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wave2fft2wave.m Sat Apr 20 14:04:20 2013 +0100 @@ -0,0 +1,39 @@ +%function [y,yh,ys,fr0] = wave2fft2wave(x,fs,w,N,t,nH,minf0,maxf0,f0et,maxhd,stocf) +function [y] = wave2fft2wave(x,w,N) +%e.g. y = wave2fft2wave(x,hamming(2025),4096); + + +M = length(w); % analysis window size +Ns = 1024; % FFT size for synthesis +H = 256; % hop size for analysis and synthesis +soundlength = length(x); % length of input sound array +hNs = Ns/2; % half synthesis window size +hM = (M-1)/2; % half analysis window size +pin = max(hNs+1,1+hM); % initialize sound pointer to middle of analysis window +pend = soundlength-max(hM,hNs); % last sample to start a frame +fftbuffer = zeros(N,1); % initialize buffer for FFT +y = zeros(soundlength+Ns/2,1); % output sine component +w = w/sum(w); % normalize analysis window +sw = zeros(Ns,1); +ow = triang(2*H-1); % overlapping window +ovidx = Ns/2+1-H+1:Ns/2+H; % overlap indexes +sw(ovidx) = ow(1:2*H-1); +bh = blackmanharris(Ns); % synthesis window +bh = bh ./ sum(bh); % normalize synthesis window +sw(ovidx) = sw(ovidx) ./ bh(ovidx); + + +while pin