annotate dsp/mag_phase_join.m @ 61:eff6bddf82e3
tip
Finally implemented perceptual brightness thing.
author |
samer |
date |
Sun, 11 Oct 2015 10:20:42 +0100 |
parents |
c3b0cd708782 |
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
|