view dsp/dftfmap.m @ 42:ae596261e75f

Various fixes and development to audio handling
author samer
date Tue, 02 Dec 2014 14:51:13 +0000
parents c3b0cd708782
children
line wrap: on
line source
function F=dftfmap(N,Fs)
% dftfmap - Frequency map for DFT of real signal 
%
% dftfmap :: N:natural, real ~'sampling rate' -> dmap(dftbins(N)).

	M=dftbins(N);
	F=dmap(M,@map,@revmap);

	function I=map(X)
		I=round(N*X/Fs);
		I(X<0)=-inf;
		I(X>Fs/2)=inf;
	end

	function X=revmap(I)
		I=shiftdim(shiftdim(I),-1);
		X1=Fs*(2*I-3)/(2*N);
		X2=Fs*(2*I-1)/(2*N);
		X1(I<=1)=0;
		X2(I>=M)=Fs/2;
		X=cat(1,X1,X2);
	end
end