⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zjd_lvbo.m

📁 语音信号滤波程序(低通、带通、多带通、fft卷积滤波 自己动手做的
💻 M
📖 第 1 页 / 共 2 页
字号:
% --- Executes during object creation, after setting all properties.function low_CreateFcn(hObject, eventdata, handles)% hObject    handle to low (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.%       See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))    set(hObject,'BackgroundColor','white');endfunction high_Callback(hObject, eventdata, handles)high = str2double(get(hObject, 'String'));if isnan(high)    set(hObject, 'String', 0);    errordlg('Input must be a number','Error');end% Save the new density valuehandles.metricdata.high = high;guidata(hObject,handles)% hObject    handle to high (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of high as text%        str2double(get(hObject,'String')) returns contents of high as a double% --- Executes during object creation, after setting all properties.function high_CreateFcn(hObject, eventdata, handles)% hObject    handle to high (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.%       See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))    set(hObject,'BackgroundColor','white');end% --- Executes on button press in pushbutton3.function pushbutton3_Callback(hObject, eventdata, handles)a = handles.metricdata.a;b = handles.metricdata.b;c = handles.metricdata.c;d = handles.metricdata.d;e = handles.metricdata.e;f = handles.metricdata.f;[x,fs,bits]=wavread('input.wav');x=x(:,2);f=[0 0.99*a ,a b,1.01*b 0.99*c, c d,1.01*d 0.99*e,e f,1.01*f 1];a=[0 0 ,1 1, 0 0, 1 1,0 0,1 1,0 0];bb = firpm(20,f,a,'h');   % Bandpass Hilberty = filter(bb,1,x);wavwrite(y,fs,bits,'lvbo.wav');t=(0:length(y)-1)/fs;subplot(222);plot(t,y);sigLength=length(y); Y = fft(y,sigLength); Pyy = Y.* conj(Y) / sigLength; halflength=floor(sigLength/2); f=2*(0:halflength)/sigLength; subplot(224);plot(f,Pyy(1:halflength+1));% 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)% --- Executes on button press in pushbutton4.function pushbutton4_Callback(hObject, eventdata, handles)lenN = handles.metricdata.lenN;[x,fs,bits]=wavread('input.wav');x=x(:,1);h = ones(1,lenN)/lenN; y = conv(h,x);wavwrite(y,fs,bits,'lvbo.wav');  t=(0:length(y)-1)/fs;subplot(222);plot(t,y);sigLength=length(y); Y = fft(y,sigLength); Pyy = Y.* conj(Y) / sigLength; halflength=floor(sigLength/2); f=2*(0:halflength)/sigLength; subplot(224);plot(f,Pyy(1:halflength+1));% hObject    handle to pushbutton4 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% --- Executes on button press in pushbutton8.function pushbutton8_Callback(hObject, eventdata, handles)prompt={'请输入起始数字通带:','请输入截止数字通带:'};name='多带通滤波';numlines=1;defaultanswer={'0.01','0.1'};options.Resize='on';options.WindowStyle='normal';options.Interpreter='tex';answer=inputdlg(prompt,name,numlines,defaultanswer,options);a=str2num(char(answer(1,1)));b=str2num(char(answer(2,1)));handles.metricdata.a = a;handles.metricdata.b = b;guidata(hObject,handles)% hObject    handle to pushbutton8 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% --- Executes on button press in pushbutton9.function pushbutton9_Callback(hObject, eventdata, handles)prompt={'请输入起始数字通带:','请输入截止数字通带:'};name='多带通滤波';numlines=1;defaultanswer={'0.2','0.3'};options.Resize='on';options.WindowStyle='normal';options.Interpreter='tex';answer=inputdlg(prompt,name,numlines,defaultanswer,options);c=str2num(char(answer(1,1)));d=str2num(char(answer(2,1)));handles.metricdata.c = c;handles.metricdata.d = d;guidata(hObject,handles)% hObject    handle to pushbutton9 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% --- Executes on button press in pushbutton10.function pushbutton10_Callback(hObject, eventdata, handles)prompt={'请输入起始数字通带:','请输入截止数字通带:'};name='多带通滤波';numlines=1;defaultanswer={'0.8','0.9'};options.Resize='on';options.WindowStyle='normal';options.Interpreter='tex';answer=inputdlg(prompt,name,numlines,defaultanswer,options);e=str2num(char(answer(1,1)));f=str2num(char(answer(2,1)));handles.metricdata.e = e;handles.metricdata.f = f;guidata(hObject,handles)% hObject    handle to pushbutton10 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% --- Executes on button press in pushbutton11.function pushbutton11_Callback(hObject, eventdata, handles)[x,fs,bits]=wavread('lvbo.wav');sound(x,fs,bits); time=length(x)/fs;for i=0:0.1:time;    set(findobj('tag','jindu2'),'Value',i/time);    set(findobj('tag','xianshi2'),'String',fix(i));    pause(0.1);end;% hObject    handle to pushbutton11 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% --- Executes on slider movement.function jindu2_Callback(hObject, eventdata, handles)% hObject    handle to jindu2 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% Hints: get(hObject,'Value') returns position of slider%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider% --- Executes during object creation, after setting all properties.function jindu2_CreateFcn(hObject, eventdata, handles)% hObject    handle to jindu2 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% Hint: slider controls usually have a light gray background.if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))    set(hObject,'BackgroundColor',[.9 .9 .9]);endfunction edit5_Callback(hObject, eventdata, handles)lenN = str2double(get(hObject, 'String'));if isnan(lenN)    set(hObject, 'String', 0);    errordlg('Input must be a number','Error');end% Save the new density valuehandles.metricdata.lenN = lenN;guidata(hObject,handles)% hObject    handle to edit5 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of edit5 as text%        str2double(get(hObject,'String')) returns contents of edit5 as a double% --- Executes during object creation, after setting all properties.function edit5_CreateFcn(hObject, eventdata, handles)% hObject    handle to edit5 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.%       See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))    set(hObject,'BackgroundColor','white');end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -