annotate dsp/mag_phase_split.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_split(N)
|
samer@32
|
2 % mag_phase_split - arrow to get FFT and do mag/phase split
|
samer@32
|
3 %
|
samer@32
|
4 % mag_phase_split ::
|
samer@32
|
5 % N:natural ~'frame size'
|
samer@32
|
6 % -> arrow( {[[N,L]]}, {[[M,L]], [[M,L]]},empty) :- M=dftbins(N).
|
samer@32
|
7
|
samer@32
|
8 bins=1+floor(N/2);
|
samer@32
|
9 singles=1:ceil(N/2):bins;
|
samer@32
|
10 o=arr(@mps);
|
samer@32
|
11
|
samer@32
|
12 function [S,P]=mps(X)
|
samer@32
|
13 Y=fft(X,N);
|
samer@32
|
14 Z=Y(1:bins,:);
|
samer@32
|
15 M=abs(Z);
|
samer@32
|
16 P=Z./M; % get complex phases of components.
|
samer@32
|
17 S=M*sqrt(2/N); % sqrt of double of total power per band
|
samer@32
|
18 S(singles,:)=S(singles,:)/sqrt(2); % undo double counting of singletons
|
samer@32
|
19 end
|
samer@32
|
20 end
|
samer@32
|
21
|