% COMPARE_CQNSGT.M - Nicki Holighaus 21.03.11 % % This helper function produces a plot comparing % a regular Gabor transform with a constant-Q type % nonstationary Gabor transform. % % Uses routines from LTFAT 0.97 or higher, available at: % http://ltfat.sourceforge.net/ % % External: DGT (LTFAT routine) function compare_cqnsgt(name) switch name case {'glockenspiel','Glockenspiel'} f = wavread('glockenspiel'); fmin = 200; sr = 44100; case {'ligeti','Ligeti'} f = wavread('ligeti'); fmin = 130; sr = 44100; case {'tufrial','Tufrial'} f = wavread('tufrial'); fmin = 130; sr = 44100; case {'hancock','Hancock'} f = wavread('hancock'); fmin = 130; sr = 44100; case {'fugue','Fugue'} f = wavread('fugue'); fmin = 130; sr = 44100; case {'kafziel','Kafziel'} f = wavread('kafziel'); fmin = 130; sr = 44100; case {'Sretil','sretil'} f = wavread('sretil'); fmin = 130; sr = 44100; case {'chirp','Chirp'} f = wavread('logchirp'); fmin = 130; sr = 22050; otherwise error('Unknown signal'); end fmax = 22050; bins = 48; Ls = length(f); G = comp_dgt_fb(f,winfuns('hann',2560),1536,2560); dynrange = 60; ma=20*log10(max(abs(G(:)))); [g,shift,M] = nsgcqwin(fmin,fmax,bins,sr,Ls); [c,Ls] = nsgtf(f,g,shift,8192); ma2=20*log10(max(abs(c(:)))); figure(1); clf subplot(1,2,1); imagesc([0 2*length(f)/sr],[0 sr/2], 20*log10((abs(G(1:floor((2560-1)/2)+1,:)+eps))),[ma-dynrange,ma]); axis xy; title([name, ' - dB-scaled Gabor transform'],'FontSize',14.0); xlabel('time (seconds)','FontSize',14.0); ylabel('frequency (Hz)','FontSize',14.0); set(gca,'FontSize',14); axis square subplot(1,2,2); imagesc([0 2*length(f)/sr],[0 floor(length(g)/2)+1], 20*log10((abs(c(:,1:floor(length(g)/2)+1)+eps)')),[ma2-dynrange,ma2]); axis xy; set(gca,'YTick',2:2*bins:(1+size(c,1)/2),'FontSize',14.0); h = get(gca); yTick = [h.YTick';(1+size(c,1)/2)]; yTickLabel = num2str([round(fmin*2.^((yTick(1:end-1)-2)/bins));sr/2],5); set(gca,'YTick',yTick,'YTickLabel',yTickLabel,'FontSize',14.0); xlabel('time (seconds)','FontSize',14.0); ylabel('frequency (Hz)','FontSize',14.0); title([name, ' - dB-scaled CQ-NSGT'],'FontSize',14.0); set(gca,'FontSize',14); axis square