📄 zjd_lvbo.m
字号:
function varargout = zjd_lvbo(varargin)% ZJD_LVBO M-file for zjd_lvbo.fig% ZJD_LVBO, by itself, creates a new ZJD_LVBO or raises the existing% singleton*.%% H = ZJD_LVBO returns the handle to a new ZJD_LVBO or the handle to% the existing singleton*.%% ZJD_LVBO('CALLBACK',hObject,eventData,handles,...) calls the local% function named CALLBACK in ZJD_LVBO.M with the given input arguments.%% ZJD_LVBO('Property','Value',...) creates a new ZJD_LVBO or raises the% existing singleton*. Starting from the left, property value pairs are% applied to the GUI before zjd_lvbo_OpeningFcn gets called. An% unrecognized property name or invalid value makes property application% stop. All inputs are passed to zjd_lvbo_OpeningFcn via varargin.%% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one% instance to run (singleton)".%% See also: GUIDE, GUIDATA, GUIHANDLES% Edit the above text to modify the response to help zjd_lvbo% Last Modified by GUIDE v2.5 12-Apr-2009 16:24:35% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @zjd_lvbo_OpeningFcn, ... 'gui_OutputFcn', @zjd_lvbo_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []);if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1});endif nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});else gui_mainfcn(gui_State, varargin{:});end% End initialization code - DO NOT EDIT% --- Executes just before zjd_lvbo is made visible.function zjd_lvbo_OpeningFcn(hObject, eventdata, handles, varargin)% This function has no output args, see OutputFcn.% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% varargin command line arguments to zjd_lvbo (see VARARGIN)% Choose default command line output for zjd_lvbohandles.output = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes zjd_lvbo wait for user response (see UIRESUME)% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.function varargout = zjd_lvbo_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT);% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Get default command line output from handles structure[x,fs,bits]=wavread('input.wav'); x=x(:,2);t=(0:length(x)-1)/fs;subplot(221);plot(t,x);subplot(223);sigLength=length(x); Y = fft(x,sigLength); Pyy = Y.* conj(Y) / sigLength; halflength=floor(sigLength/2); f=2*(0:halflength)/sigLength; plot(f,Pyy(1:halflength+1));set(findobj('tag','alltime2'), 'String',length(x)/fs);varargout{1} = handles.output;% --- Executes on button press in pushbutton1.function pushbutton1_Callback(hObject, eventdata, handles)[x,fs,bits]=wavread('input.wav'); x=x(:,2);jieshu = handles.metricdata.jieshu;N=jieshu;wc=0.3;[b,a]=butter(N,wc);y=filter(b,a,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 pushbutton1 (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 pushbutton2.function pushbutton2_Callback(hObject, eventdata, handles)[x,fs,bits]=wavread('input.wav');x=x(:,2);low = handles.metricdata.low;high= handles.metricdata.high;wp=[low,high];ws=[0.001,0.999];[N,wc]=buttord(wp,ws,3,18);[b,a]=butter(N,wc,'bandpass'); y=filter(b,a,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 pushbutton2 (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 pushbutton5.function pushbutton5_Callback(hObject, eventdata, handles)[filename,pathname]=uiputfile('*.wav','save as');str=[pathname filename];[x,fs,bits]=wavread('lvbo.wav'); wavwrite(x,fs,bits,str);% 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)% --- Executes on button press in pushbutton6.function pushbutton6_Callback(hObject, eventdata, handles)[x,fs,bits]=wavread('input.wav');x=x(:,1);sound(x,fs,bits); time=length(x)/fs;set(findobj('tag','alltime2'), 'String',time);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 pushbutton6 (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 pushbutton7.function pushbutton7_Callback(hObject, eventdata, handles)close;% 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)function jieshu_Callback(hObject, eventdata, handles)jieshu = str2double(get(hObject, 'String'));if isnan(jieshu) set(hObject, 'String', 0); errordlg('Input must be a number','Error');end% Save the new density valuehandles.metricdata.jieshu = jieshu;guidata(hObject,handles)% hObject handle to jieshu (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 jieshu as text% str2double(get(hObject,'String')) returns contents of jieshu as a double% --- Executes during object creation, after setting all properties.function jieshu_CreateFcn(hObject, eventdata, handles)% hObject handle to jieshu (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 low_Callback(hObject, eventdata, handles)low = str2double(get(hObject, 'String'));if isnan(low) set(hObject, 'String', 0); errordlg('Input must be a number','Error');end% Save the new density valuehandles.metricdata.low = low;guidata(hObject,handles)% hObject handle to low (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 low as text% str2double(get(hObject,'String')) returns contents of low as a double
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -