function mapsound2 (w,dt,fmin,fmax,simpl,rate) // Plots a sound map for a sound. // It does FFT at time increments dt. // rate is the sampling rate. // simpl points are collected for speed reasons. [lhs,rhs]=argn(0); if ( rhs <= 5 ) then rate=0;end if ( rhs <= 4 ) then simpl=1; end ; if ( rhs <= 3 ) then fmax=1500; end ; if ( rhs <= 2 ) then fmin=100; end ; if ( rhs <= 1 ) then dt=0.1; end ; n=prod(size(w)); defaultrate=44000; if rate==0; rate=defaultrate; end; dp=dt*rate; points=2^floor(log(dp)/log(2)); ind=fmin/rate*points/simpl:fmax/rate*points/simpl; f=abs(fft(w(1:points),1)); f=sum(matrix(f,points/simpl,simpl),'c')'; M=f(ind); i=1; i=i+dp; while i+points <= n; f=abs(fft(w(i:i+points-1),1)); f=sum(matrix(f,points/simpl,simpl),'c')'; M=[M;f(ind)]; i=i+dp; end; [nl,nc]=size(M); if nl==1 ; return;end x_abs= (0:(nl-1))*(n/rate)/(nl-1); y_abs= (0:(nc-1))/(nc-1); y_abs= fmin*(1-y_abs) + fmax*(y_abs) grayplot(x_abs,y_abs,M) endfunction function cmap = jetcolormap2(varargin) if size(varargin)<>1 then error(msprintf(gettext("%s: Wrong number of input argument(s): %d expected.\n"), "jetcolormap2", 1)); end n=varargin(1); // Check size of input argument if size(n,'*')<>1 then error(msprintf(gettext("%s: Wrong size for input argument #%d: An integer expected.\n"),"jetcolormap2",1)); end // Check value of input argument if n<3 then error(msprintf(gettext("%s: Wrong value for input argument #%d: An integer greater or equal than %d expected.\n"),"jetcolormap2",1,3)); end r = [ 0/10 1/10 2/10 3/10 4/10 5/10 6/10 7/10 8/10 9/10 10/10 ; 1 1/2 0 0 0 0 0 1/2 1 1 1]; g = [ 0/10 1/10 2/10 3/10 4/10 5/10 6/10 7/10 8/10 9/10 10/10 ; 0 0 0 1/2 1 1 1 1 1 1/2 0]; b = [ 0/10 1/10 2/10 3/10 4/10 5/10 6/10 7/10 8/10 9/10 10/10 ; 1 1 1 1 1 1/2 0 0 0 0 0]; d = 0.5/n; x = linspace(d,1-d,n) cmap = [ interpln(r, x);... interpln(g, x);... interpln(b, x) ]'; cmap = min(1, max(0 , cmap)) // normaly not necessary endfunction fe=44000; n=0.5; t=soundsec(n,fe); f1=440; son=0.2*sin(2*%pi*f1*t)+0.05*sin(2*%pi*2*f1*t); sonampli=son*2; clf(0); subplot(131);plot(son); subplot(132);analyze(sonampli,fmin=10,fmax=2000,rate=fe,points=8192); f=scf(0); f.color_map=jetcolormap2 (128); subplot(133);mapsound2(sonampli,dt=0.1,simpl=1,fmin=20,fmax=2000,rate=fe); e=gce(); colorbar(0,max(e.data.z));