?? lp_go.m
字號:
%
% Callback function for popup menu in the Frequency Analysis window
% Author : Minkyu Lee
% Date : 27-Feb-1995
% Modified by Karthik May 27 1997
% Modified by D. G. Childers
% Set position and size of analysis window
PV=[270 100 519 240];
s2 = 'Frequency Domain Analysis - Output';
% Open analysis window
% Open analysis window
while exist('freq_out_win_h')==1
try1 = 'get(freq_out_win_h,''position'');';
eval(try1,catch2);
if check ==0
clear freq_out_win_h;
check = 1;
break;
end
s1 = get(freq_out_win_h,'Name');
if ~strcmp(s1,s2)
clear freq_out_win_h;
break;
end
figure(freq_out_win_h);
break;
end;
if exist('freq_out_win_h')~=1;
freq_out_win_h=figure('Position',PV,...
'Resize','on',...
'Name',s2,...
'Numbertitle','off');
end
% set parameters
if lp_window == 1
window = hamming(lp_frame_len); % Window type
elseif lp_window == 2
window = hanning(lp_frame_len); % Window type
elseif lp_window == 3
beta=0.5;
window = kaiser(lp_frame_len,beta); % Window type
elseif lp_window == 4
window = triang(lp_frame_len); % Window type
elseif lp_window == 5
window = bartlett(lp_frame_len); % Window type
elseif lp_window == 6
window = blackman(lp_frame_len); % Window type
elseif lp_window == 7
window = boxcar(lp_frame_len); % Window type
elseif lp_window == 8
rdb=3;
window = chebwin(lp_frame_len,rdb); % Window type
end
epsilon=1e-15;
val=get(lp_po_method_h,'Value');
button=1;
while button == 1
if freq_lp_mark_flag == 0
if lp_frame_len > length(SPEECH) S=sprintf('Analysis window length is longer that input data. %d of zeros are padded',lp_frame_len-LEN);
disp(S);
temp=zeros(lp_frame_len-LEN,1);
speech1=[SPEECH;temp];
else
S=sprintf('The analysis frame is the first %d points of current data window',lp_frame_len);
disp(S);
speech1=SPEECH_OLD(LEFT:LEFT+lp_frame_len-1);
end
button=0;
else
figure(ana_wav_win_h);
[x,y,button]=ginput(1);
x=round(x);
if button ~= 1
return;
end
speech1=SPEECH_OLD(x(1):x(1)+lp_frame_len-1);
figure(freq_out_win_h);
end
FFT = fft(window.*speech1,lp_frame_len);
wait_window = figure('Numbertitle','off',...
'Color',BACK_COLOR,...
'Name','Please be patient...',...
'Position',[117 248 560 150]);
wait_window_display = uicontrol('Style','Text',...
'Position',[50 50 410 30],...
'Backgroundcolor','white',...
'Foregroundcolor','blue',...
'String','These methods may take a while...please wait');
pause(0.01);
if val == 1
fn = 'Frequency analysis (autocorrelation method)';
[A sig2]=autocorr(window.*speech1,lp_frame_len,lp_num_poles);
elseif val == 2
fn = 'Frequency analysis (covariance method)';
mode=0; % for covariance method
[iflag A sig2]=covmcov(speech1,lp_frame_len,lp_num_poles,mode,epsilon);
elseif val == 3
fn = 'Frequency analysis (modified cov. method)';
mode=1; % for modified covariance method
[iflag A sig2]=covmcov(speech1,lp_frame_len,lp_num_poles,mode,epsilon);
elseif val == 4
fn='Frequency analysis (Burg algorithm)';
[A sig2]=burg(window.*speech1,lp_frame_len,lp_num_poles);
elseif val == 5
fn = 'Frequency analysis (Recursive MLE algorithm)';
[A sig2]=rmle(window.*speech1,lp_frame_len,lp_num_poles);
elseif val == 6
fn = 'Perceptual linear prediction analysis';
[A rc sig2 spectra audspe nfilt ] = plp( speech1,length(speech1),lp_num_poles,1/Ts);
end
set(wait_window_display,'String','Thanks for being patient. Now plotting');
pause(0.01);
close(wait_window);
clear wait_window;
error=filter([1 A],1,speech1);
eng=sqrt(error'*error);
[H W]=freqz(eng,[1 A],lp_frame_len/2);
% plot the spectrum and pole_zero plot
if val == 6
zi=roots([1 A]);
mm=1;
for kk=1:length(zi)
if angle(zi(kk)) >= 0
zzi(mm)=zi(kk);
mm=mm+1;
end
end
fi=17*angle(zzi)/pi;
bi=-34*log(abs(zzi))/pi;
ff=600*sinh(fi/6);
fb=600*sinh(bi/6);
vh=1:length(spectra)/2;
vh=vh/length(spectra)*1/(Ts);
subplot(121), plot(vh,10*log10(spectra(1:length(spectra)/2)));
xlabel('Frequency in (Hz)');
title(fn);
vb=1:length(H);
vb=vb/length(H)*nfilt;
subplot(122), plot(vb,20*log10(sig2*abs(H)));
xlabel('Frequency in (Bark)');
title(fn);
fsave=20*log10(sig2*abs(H));
else
vh=1:lp_frame_len/2;
vh=vh/(lp_frame_len/2)*1/(2*Ts);
subplot(121),plot(vh,20*log10(abs(FFT(1:lp_frame_len/2))));
title(fn);
hold on;
plot(vh,20*log10(abs(H)), ':r');
xlabel('Frequency in (Hz)');
fsave=20*log10(abs(H));
hold off;
subplot(122), zplane([], [1 A]);
title('pole-zero plot');
xlabel('Real');
ylabel('Imag');
end
end
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -