Mercurial > hg > ishara
annotate dsp/mag_phase_join.m @ 32:c3b0cd708782
Imported core dsp tools.
author | samer |
---|---|
date | Sun, 20 Jan 2013 13:48:47 +0000 |
parents | |
children |
rev | line source |
---|---|
samer@32 | 1 function o=mag_phase_join(N) |
samer@32 | 2 % mag_phase_join - get mag and phase spectra and recombine to signal |
samer@32 | 3 % |
samer@32 | 4 % mag_phase_join :: N:natural -> arrow( {[[M,L]], [[M,L]]}, {[[N,L]]}, empty) :- M=dftbins(N). |
samer@32 | 5 % |
samer@32 | 6 % Version 2 corrects error in V. 1 - the wrong bands were being |
samer@32 | 7 % doubled up in the power reckoning. This version now guarantees |
samer@32 | 8 % that sum(magspec(x).^2) = sum(x.^2). |
samer@32 | 9 |
samer@32 | 10 bins=1+floor(N/2); |
samer@32 | 11 last_double=ceil(N/2); |
samer@32 | 12 singles=1:last_double:bins; |
samer@32 | 13 o=arr(@mpj); |
samer@32 | 14 |
samer@32 | 15 function X=mpj(S,P) |
samer@32 | 16 S(singles,:)=S(singles,:)*sqrt(2); |
samer@32 | 17 P(singles,:)=real(P(singles,:)); |
samer@32 | 18 Z=P.*(S*sqrt(N/2)); |
samer@32 | 19 X=ifft([Z;conj(Z(last_double:-1:2,:))]); |
samer@32 | 20 end |
samer@32 | 21 end |
samer@32 | 22 |
samer@32 | 23 |
samer@32 | 24 |