www.pudn.com > LPCToolbox.rar > PKSFIG_DRAW.M



function [range,key] = pksfig_draw
global Ap Cs Handle PFCvars

newwindow = 0;
if ~isfield(Handle, 'pksfig') | ~ishandle(Handle.pksfig),
pksfig_setup;
newwindow = 1;
end

f1 = Cs.pks(:,1,1);
f2 = Cs.pks(:,2,1);
f3 = Cs.pks(:,3,1);

PFCvars.numclicks = 0; > clean up vars used by pksfig_click

> ---------- display the sampled and analysis data

truelen = length(Cs.snd);
trimlen = ((Cs.nframes-1)*Ap.context_width) + Ap.analysis_width;
msecs_per_sample = 1000/Cs.Fs;
msecs_per_contextframe = Ap.context_width * msecs_per_sample;
framestarttimes = [0:Cs.nframes-1] * msecs_per_contextframe;
starttime = framestarttimes(1); > the +4 is for
endtime = framestarttimes(end) + 4; > an aesthetic gap

> ----- plot the waveform

axes(Handle.wavaxis); cla;

xx = [0:truelen-1] * msecs_per_sample;
plot(xx, Cs.snd(1:truelen));
axis tight;
set(gca, 'xlim', [starttime endtime]);
set(get(gca,'title'), 'string', getstatusstr);

hold on;

> ----- plot the spectrogram &amt; formant peaks

axes(Handle.pksaxis); cla;

if Ap.showspcgm
if newwindow | isempty(Cs.spcgm)
> spectrogram parameters for a broadband spectrogram
segsize = 2^round(log2(0.0064*Cs.Fs)); > 6.4ms window (best for Fs=10kHz)
ntrans = max(1, 256/segsize);
nlap = 8;
> define x-axis in millisec and yaxis in Hz
Cs.spcgm = flipud( specgrm(Cs.snd,segsize,nlap,ntrans) );
Cs.spcgmx = linspace(0, floor(length(Cs.snd)/(Cs.Fs/1000)), size(Cs.spcgm,2));
Cs.spcgmy = linspace(0, Cs.Fs/2, size(Cs.spcgm,1));
end
imagesc(Cs.spcgmx, Cs.spcgmy, Cs.spcgm);
colormap(jet*0.45); axis xy;
hold on;
end

plot(framestarttimes, f1, 'x', ...
framestarttimes, f2, '*', ...
framestarttimes, f3, 'o');

set(get(gca,'xlabel'), 'string', 'msec');
set(get(gca,'ylabel'), 'string', 'Hz');

axis([starttime endtime 0 4000]);

Handle.pksfigtxt = text(-20, -700, ...
'Left-click to define one end of a region');