% POSSIBLE VALUES FOR filter_type: % 'low' % 'high' % 'bandpass' % 'stop' function [] = frequencyDomainPlot(filename, filter_type, w_cutoff) global player; global stopped; stopped = 0; [Y,fs,NBITS] = wavread(filename); if nargin == 3 [B, A] = butter(5, w_cutoff/(fs/2), filter_type); Y = filter(B, A, Y); elseif nargin == 2 'Warning: wrong number of arguments. No filter applied.' end player = audioplayer(Y, fs, NBITS); [S F T P] = spectrogram(Y(:,1),fs/10,0,fs/10,fs); figure(1) uicontrol('Style', 'pushbutton', 'String', 'Stop',... 'Position', [10 10 60 25],... 'Callback', 'pause(player); stopped = 1;'); tic play(player); for ii = 2:length(T) timeElapsed = toc; timeDiff = ii/10 - timeElapsed; if timeDiff > 0 pause(timeDiff) end h = stem(F,20*log10(S(:,ii))); set(gca, 'xscale', 'log', 'xlim', [1 10^4]) set(h, 'BaseValue', 1) title(['Spectrum at time t = ' num2str(T(ii))]); ylabel('Amplitude'); ylim([0 75]); xlabel('Frequency'); xlim([0 F(end)]); if(stopped == 1) pause(player); close all; break; end drawnow end