excitation_create.m
来自「这是一个用于语音信号处理的工具箱」· M 代码 · 共 108 行
M
108 行
%Callback function for the Create new file button in the new file window
%
%Author : Albert Hsiao
%Karthik 2/97 ...used Albert's code to create this program
%A filename can be specified interactively.
%The source file is named filename_source and the formant file is
%called filename_formant.
%Modified greatly by D. G. Childers 2/25/98 to eliminate the time varying features
clear excitation;
segment_no=1;
%Nframe = 20;%Default number of frames
if exist ('Nframe1')
Nframe=Nframe1;
end
Srate = 10000; %Default sampling rate
%% generate a default source file %%
Pitch=100*ones(Nframe,1); % pitch period
Vgain= 5*ones(Nframe,1); % voicing gain
Lcof= ones(Nframe,5); % 5 LF timing coefficients
Lcof(:,1)=50*Lcof(:,1); % Ee
Lcof(:,2)=0.5*Lcof(:,2); % Tp
Lcof(:,3)=0.6*Lcof(:,3); % Te
Lcof(:,4)=0.05*Lcof(:,4); % Ta
Lcof(:,5)=0.8*Lcof(:,5); % Tc
Ngain=zeros(Nframe,1); % fricative noise gain
Ncof=ones(Nframe,5); % 5 noise coefficients
Ncof(:,1)=0*Ncof(:,1); % asp. noise gain
Ncof(:,2)=0*Ncof(:,2); % amp1
Ncof(:,3)=0.75*Ncof(:,3); % offset
Ncof(:,4)=0*Ncof(:,4); % amp2
Ncof(:,5)=0.25*Ncof(:,5); % duration
%Generate the default excitation signal
%Voiced excitation
% 1. calculate the LF model waveform for voiced excitation
Tp=Lcof(1,2);
Te=Lcof(1,3);
Ta=Lcof(1,4);
Tc=Lcof(1,5);
Ee=Lcof(1,1);
Lens=Pitch(1);
temp_excitation = lfpuls(Tp,Te,Ta,Tc,Ee,Lens);
gm=Vgain(1)-Ngain(1)-Ncof(1,1);
if Vgain(1)==0
amp=0;
else
amp=sqrt(gm*Lens/sum(temp_excitation.^2));
end
temp_excitation = amp*temp_excitation;
% 2. calculate the noise exciation
Aspgain=Ncof(1,1); % aspiration noise gain
Amp1=Ncof(1,2);
Offset=Ncof(1,3);
Amp2=Ncof(1,4);
Duration=Ncof(1,5);
Fgain=Ngain(1); % fricative noise gain
temp_noise_excitation=nspuls(Amp1,Offset,Amp2,Duration,Lens,Aspgain,Fgain);
% 3. plot the combined the excitation waveform (voiced+unvoiced)
temp_excitation = temp_excitation + temp_noise_excitation;
%Replicate this array to produce the excitation
for i = 1:Nframe
start_point = (i*Lens) - (Lens-1);
end_point = start_point + Lens - 1;
excitation(start_point:end_point) = temp_excitation;
end
Lens_array = Pitch;
uvindicate = ones(1,Nframe);
PV = [436 204 244 81];
s2 = 'Excitation has been created';
message_fig = figure('Position',PV,...
'Numbertitle','off',...
'Color',[0.5 0.5 0.5],...
'Name',s2);
uicontrol('Style','Frame',...
'Units','Normalized',...
'Position',[0.05 0.05 0.9 0.9],...
'BackGroundColor',[0.9 0.9 0.9]);
uicontrol('Style','text',...
'Units','Normalized',...
'Position',[0.1 0.2 0.8 0.4],...
'ForegroundColor','red',...
'BackGroundColor',[0.9 0.9 0.9],...
'String','A default source has been created. You can modify it now');
pause(3);
close(message_fig);
clear message_fig;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?