function o=mag_phase_split(N)
% mag_phase_split - arrow to get FFT and do mag/phase split
%
% mag_phase_split :: 
%    N:natural ~'frame size'
% -> arrow( {[[N,L]]}, {[[M,L]], [[M,L]]},empty) :- M=dftbins(N).

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

	function [S,P]=mps(X)
		Y=fft(X,N);
		Z=Y(1:bins,:);
		M=abs(Z);
		P=Z./M; % get complex phases of components.
		S=M*sqrt(2/N); % sqrt of double of total power per band
		S(singles,:)=S(singles,:)/sqrt(2); % undo double counting of singletons
	end
end

