第一范文网 - 专业文章范例文档资料分享平台

数字变声器

来源:用户分享 时间:2025/11/14 12:58:17 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

4.4每个控件的程序如下

4.4.1“录音”radiobutton(radiobutton1)

% --- Executes on button press in radiobutton1.

function radiobutton1_Callback(hObject, eventdata, handles) % hObject handle to radiobutton1 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton1 if get(hObject,'Value')

set(handles.pushbutton1,'Enable','on'); set(handles.edit1,'Enable','on'); set(handles.edit2,'Enable','on'); set(handles.radiobutton2,'Value',0); set(handles.pushbutton3,'Enable','off'); else end

4.4.2“打开”radiobutton(radiobutton2)

% --- Executes on button press in radiobutton2.

function radiobutton2_Callback(hObject, eventdata, handles) % hObject handle to radiobutton2 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) if get(hObject,'Value')

set(handles.radiobutton1,'Value',0); set(handles.pushbutton1,'Enable','off'); set(handles.edit1,'Enable','off'); set(handles.edit2,'Enable','off');

set(handles.pushbutton3,'Enable','on'); else end

13 / 24

4.4.3“开始 ”按钮(pushbutton1)

% --- Executes on button press in pushbutton1. function pushbutton1_Callback(hObject, eventdata, handles) % hObject handle to pushbutton1 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) set(hObject,'string','luyinzhong'); pause(0.4);

Fs=str2double(get(handles.edit2,'String')); t=str2double(get(handles.edit1,'String')); ai=analoginput('winsound',0); chane1=addchannel(ai,1); set(ai,'SampleRate',Fs); duration=t;

set(ai,'SamplesPerTrigger',duration*Fs); start(ai); y=0;time=0;

[y,time]=getdata(ai); handles.y=y; handles.Fs=Fs;

guidata(hObject,handles); plot(handles.axes1,handles.y) title(handles.axes1,'shiyutu'); ysize=size(handles.y);

y=fft(handles.y,length(handles.y)); ysize=size(y);

plot(handles.axes2,abs(y)); xlabel(handles.axes2,'pinlv'); ylabel(handles.axes2,'fudu');

title(handles.axes2,'pinlvtexing'); set(hObject,'string','wanbi');

set(handles.pushbutton2,'Enable','on'); 4.4.4“保存”按钮(pushbutton2)

% --- Executes on button press in pushbutton2.

function pushbutton2_Callback(hObject, eventdata, handles) % hObject handle to pushbutton2 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) Fs=handles.Fs; fs=Fs;

14 / 24

[filename]=uiputfile({'*.wav','ALL FILES(*.*)'},'wenjianbaocun'); wavwrite(handles.y,fs,filename); 4.4.5“打开音频文件按钮”(pushbutton3)

% --- Executes on button press in pushbutton3.

function pushbutton3_Callback(hObject, eventdata, handles) % hObject handle to pushbutton3 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) [filename pathname]=uigetfile({'*.wav','ALL FILES'},'xuanzeshengyinwenjian'); if isequal([filename pathname],[0,0]) return; end

str=[pathname filename]; [temp Fs]=wavread(str);

handles.y=temp;handles.Fs=Fs; handles.xuanze=2;

guidata(hObject,handles);

set(handles.pushbutton2,'Enable','on'); 4.4.6“原声”按钮(pushbutton5)

% --- Executes on button press in pushbutton5.

function pushbutton5_Callback(hObject, eventdata, handles) % hObject handle to pushbutton5 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) c=handles.Fs; Fs=c;

wavplay(handles.y,Fs);

plot(handles.axes1,handles.y) title(handles.axes1,'shiyutu'); ysize=size(handles.y);

y=fft(handles.y,length(handles.y)); ysize=size(y);

plot(handles.axes2,abs(y(1:ysize/2))); xlabel(handles.axes2,'pinlv'); ylabel(handles.axes2,'fudu');

title(handles.axes2,'pinlvtexing');

15 / 24

4.4.7“女声”按钮(pushbutton7)

% --- Executes on button press in pushbutton7.

function pushbutton7_Callback(hObject, eventdata, handles) % hObject handle to pushbutton7 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) FL = 80; WL = 240; P = 10; s=handles.y;fs=handles.Fs;

s = s/max(s); L = length(s); FN = floor(L/FL)-2;

exc=zeros(L,1); zi_pre = zeros(P,1); s_rec = zeros(L,1); zi_rec = zeros(P,1); exc_syn = zeros(L,1); s_syn = zeros(L,1); last_syn = 0;

zi_syn = zeros(P,1);

exc_syn_t = zeros(L,1); s_syn_t = zeros(L,1); last_syn_t = 0; zi_syn_t = zeros(P,1); hw = hamming(WL); for n = 3:FN

s_w = s(n*FL-WL+1:n*FL).*hw; [A E] = lpc(s_w, P); ? s_f=s((n-1)*FL+1:n*FL); ??

[exc1,zi_pre] = filter(A,1,s_f,zi_pre); exc((n-1)*FL+1:n*FL) = exc1;

[s_rec1,zi_rec] = filter(1,A,exc1,zi_rec); s_rec((n-1)*FL+1:n*FL) = s_rec1; s_Pitch = exc(n*FL-222:n*FL); PT = findpitch(s_Pitch); G = sqrt(E*PT);

tempn_syn = [1:n*FL-last_syn]';

exc_syn1 = zeros(length(tempn_syn),1); exc_syn1(mod(tempn_syn,PT)==0) = G;

exc_syn1 = exc_syn1((n-1)*FL-last_syn+1:n*FL-last_syn); [s_syn1,zi_syn] = filter(1,A,exc_syn1,zi_syn); exc_syn((n-1)*FL+1:n*FL)=exc_syn1;

16 / 24

搜索更多关于: 数字变声器 的文档
数字变声器.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c13c4c44rjl02ra61xnee_4.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top