wg_go.m
来自「这是一个用于语音信号处理的工具箱」· M 代码 · 共 83 行
M
83 行
%
% Callback function for "Generate" menu of Wave generator window
% Author : Minkyu Lee
% Date : 27-Feb-1995
%
% Modified by Karthik on May 26 1997
% Modified by D. G. Childers
%
% Get the waveshape
wave_shape=get(wg_po_wave_h,'Value');
% Get the value from the slider
wave_samp=eval(get(wg_ed_samp_h,'String'));
wave_freq=eval(get(wg_ed_freq_h,'String'));
wave_len=eval(get(wg_ed_len_h,'String'));
wave_amp=eval(get(wg_ed_amp_h,'String'));
TT=0:wave_samp*wave_len*1e-3-1;
if wave_shape == 1
SPEECH=wave_amp*sin(2*pi*wave_freq*TT*1/wave_samp);
elseif wave_shape == 2
SPEECH=wave_amp*square(2*pi*wave_freq*TT*1/wave_samp);
elseif wave_shape == 3
SPEECH=wave_amp*sawtooth(2*pi*wave_freq*TT*1/wave_samp);
elseif wave_shape == 4
N=wave_samp*wave_len*1e-3;
rand_seed=wave_freq;
rand('seed',rand_seed);
SPEECH=wave_amp*rand(1,N)-wave_amp/2;
elseif wave_shape == 5
N=wave_samp*wave_len*1e-3;
rand_seed=wave_freq;
rand('seed',rand_seed);
SPEECH=wave_amp*randn(1,N);
end
SPEECH=SPEECH';
% Set position and size of data window
PV=[269 236 519 300];
s2 = 'Input Signal';
% Open analysis window
while exist('ana_wav_win_h')==1
try1 = 'get(ana_wav_win_h,''position'');';
eval(try1,catch2);
if check ==0
clear ana_wav_win_h;
check = 1;
break;
end
s1 = get(ana_wav_win_h,'Name');
if ~strcmp(s1,s2)
clear ana_wav_win_h;
break;
end
figure(ana_wav_win_h);
break;
end;
if exist('ana_wav_win_h')~=1;
ana_wave_win_h=figure('Position',PV,...
'Resize','on',...
'Numbertitle','off',...
'Name',s2);
end
% Findout the input variable name and plot
LEN=length(SPEECH);
LEFT=1;
RIGHT=LEN;
v=1:LEN;
v=v/LEN*wave_len;
sp1_h=plot(v,SPEECH);
V=axis;
axis([V(1) V(2) -1.5*max(abs(SPEECH)) 1.5*max(abs(SPEECH))]);
xlabel('msec');
S=sprintf('Number of samples : %d',LEN);
title(S);
zoom_level=1;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?