view 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
line wrap: on
line source
function o=mag_phase_join(N)
% mag_phase_join - get mag and phase spectra and recombine to signal
%
% mag_phase_join :: N:natural -> arrow( {[[M,L]], [[M,L]]}, {[[N,L]]}, empty) :- M=dftbins(N).
%
% Version 2 corrects error in V. 1 - the wrong bands were being
% doubled up in the power reckoning. This version now guarantees
% that sum(magspec(x).^2) = sum(x.^2).

	bins=1+floor(N/2);
	last_double=ceil(N/2);
	singles=1:last_double:bins;
	o=arr(@mpj);

	function X=mpj(S,P)
		S(singles,:)=S(singles,:)*sqrt(2); 
		P(singles,:)=real(P(singles,:));
		Z=P.*(S*sqrt(N/2)); 
		X=ifft([Z;conj(Z(last_double:-1:2,:))]);
	end
end