katkost@3: function y = stft(x, w, N, H) katkost@3: % Analysis/synthesis of a sound using the short-time fourier transform katkost@3: % x: input sound, w: analysis window (odd size), N: FFT size, H: hop size katkost@3: % y: output sound katkost@3: M = length(w); % analysis window size katkost@3: N2 = N/2+1; % size of positive spectrum katkost@3: soundlength = length(x); % length of input sound array katkost@3: hM = (M-1)/2; % half analysis window size katkost@3: pin = 1+hM; % initialize sound pointer in middle of analysis window katkost@3: pend = soundlength-hM; % last sample to start a frame katkost@3: fftbuffer = zeros(N,1); % initialize buffer for FFT katkost@3: yw = zeros(M,1); % initialize output sound frame katkost@3: y = zeros(soundlength,1); % initialize output array katkost@3: w = w/sum(w); % normalize analysis window katkost@3: while pin