samer@32: function o=mag_phase_join(N) samer@32: % mag_phase_join - get mag and phase spectra and recombine to signal samer@32: % samer@32: % mag_phase_join :: N:natural -> arrow( {[[M,L]], [[M,L]]}, {[[N,L]]}, empty) :- M=dftbins(N). samer@32: % samer@32: % Version 2 corrects error in V. 1 - the wrong bands were being samer@32: % doubled up in the power reckoning. This version now guarantees samer@32: % that sum(magspec(x).^2) = sum(x.^2). samer@32: samer@32: bins=1+floor(N/2); samer@32: last_double=ceil(N/2); samer@32: singles=1:last_double:bins; samer@32: o=arr(@mpj); samer@32: samer@32: function X=mpj(S,P) samer@32: S(singles,:)=S(singles,:)*sqrt(2); samer@32: P(singles,:)=real(P(singles,:)); samer@32: Z=P.*(S*sqrt(N/2)); samer@32: X=ifft([Z;conj(Z(last_double:-1:2,:))]); samer@32: end samer@32: end samer@32: samer@32: samer@32: