Hi everybody and thanks for taking time on this.
I have a time domain signal vectorized at a sampling frequency of 16kHz. I want to convert it back to time domain by using phase and magnitude, after I have made some modification to its spectrum. The code is, e.g.:
[x, fs]=wavread('file'); l_x=length(x); M=round((32*1e-3)*fs); N=M/2; % analysis window
shift=floor((l_x-M)/N);G=ones(1,length(R)); for i=1:shift right=fft( x_r((i-1)*N+1:M+(i-1)*N) ); phaseR=angle( right ); magniR(i,:) = abs(right(1:N)); %take only first M/2 points
magniRR(i,:)=magniR(i,:).*G; %apply spectrum modification
frame_r(i,:)= real(ifft( [magniRR(i,:) magniRR(i,N:-1:1)].*exp(1j*phaseR)' ))end% % overlap-and-add syntheses Allen & Rabiner's method
indf = N*[ 0:(shift-1) ]; inds = [ 1:M ]'; indexes = indf(ones(M,1),:) + inds(:,ones(1,shift));rr = zeros(1, l_x); wsumR = zeros(1, l_x); window=hann(M);for m = 1:shift, rr(indexes(:,m)) = rr(indexes(:,m))+ frame_r(m,:).*window'; wsumR(indexes(:,m)) = wsumR(indexes(:,m)) + window';endrr = rr./wsumR;% divide out summed-up analysis windows
plot(rr)soundsc(rr,fs);
There is something wrong with this.
Best Answer