samer@0
|
1 % spec_bench - Arrow for doing spectral-based processing
|
samer@0
|
2 %
|
samer@0
|
3 % spec_bench ::
|
samer@0
|
4 % N:natural ~'frame size',
|
samer@0
|
5 % M:natural ~'hop size'
|
samer@0
|
6 % arrow( {[dftbins(N),W]}, {[dftbins(N),W]}, S1), ~'arrow to process magnitude spectra',
|
samer@0
|
7 % arrow( {[dftbins(N),W]}, {[dftbins(N),W]}, S2), ~'arrow to process phase spectra'
|
samer@0
|
8 % -> arrow( {[N,W]}, {[N,W]}, spec_bench_state(S1,S2)) ~'total arrow'.
|
samer@0
|
9 %
|
samer@0
|
10 % This splits a signal into magnitude and phase spectra (using Hanning analysis window),
|
samer@0
|
11 % applies supplied arrows to the two branches, and then recombines them using an inverse
|
samer@0
|
12 % DFT and overlap-and-add to compose the output signal.
|
samer@0
|
13
|
samer@0
|
14 function o=spec_bench(N,M,a1,a2)
|
samer@0
|
15 H=spdiag(hanning(N,'periodic'));
|
samer@0
|
16
|
samer@0
|
17 o= ( amult(H) ... % analysis window
|
samer@0
|
18 * mag_phase_split(N) ... % split into magnitude and phase spectra
|
samer@0
|
19 * (a1 + a2) ... % apply a1 and a2 to mag and phase
|
samer@0
|
20 * mag_phase_join(N) ... % reconstruct
|
samer@0
|
21 * amult((N/M/6)*H) ... % reconstruction window
|
samer@0
|
22 * aolapadd(N,M) ... % overlap and add
|
samer@0
|
23 );
|
samer@0
|
24 end
|
samer@0
|
25
|