?? pcm_gui.m
字號:
function varargout = pcm_gui(varargin)% PCM_GUI M-file for pcm_gui.fig% PCM_GUI, by itself, creates a new PCM_GUI or raises the existing% singleton*.%% H = PCM_GUI returns the handle to a new PCM_GUI or the handle to% the existing singleton*.%% PCM_GUI('CALLBACK',hObject,eventData,handles,...) calls the local% function named CALLBACK in PCM_GUI.M with the given input arguments.%% PCM_GUI('Property','Value',...) creates a new PCM_GUI or raises% the existing singleton*. Starting from the left, property value pairs are% applied to the GUI before pcm_gui_OpeningFcn gets called. An% unrecognized property name or invalid value makes property application% stop. All inputs are passed to pcm_gui_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 pcm_gui% Last Modified by GUIDE v2.5 13-Mar-2009 09:01:22% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @pcm_gui_OpeningFcn, ... 'gui_OutputFcn', @pcm_gui_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 pcm_gui is made visible.function pcm_gui_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 pcm_gui (see VARARGIN)% Choose default command line output for pcm_guihandles.output = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes pcm_gui wait for user response (see UIRESUME)% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.function varargout = pcm_gui_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 structurevarargout{1} = handles.output;% --- Executes on button press in origin_open_pushbutton.function origin_open_pushbutton_Callback(hObject, eventdata, handles)% hObject handle to origin_open_pushbutton (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)'%打開聲音文件[name,path]=uigetfile({'*.wav','請選擇一個聲音文件(*.wav)'},'請打開一個聲音文件');handles.name=name;file=strcat(path,name);%使用wavread函數讀入[origin, fs, nbits, opts] = wavread(file);handles.origin=origin;handles.fs=fs;%畫出圖像曲線axes(handles.axes2);plot(origin);axis([0 length(origin) -1 1]);guidata(hObject,handles);% --- Executes on button press in alaw_generate_pushbutton.function alaw_generate_pushbutton_Callback(hObject, eventdata, handles)% hObject handle to alaw_generate_pushbutton (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)%生成基于A律的壓縮文件origin=handles.origin;fs=handles.fs;name=handles.name;alaw(origin,name);% --- Executes on button press in mulaw_generate_pushbutton.function mulaw_generate_pushbutton_Callback(hObject, eventdata, handles)% hObject handle to mulaw_generate_pushbutton (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)%生成基于mu律的壓縮文件origin=handles.origin;fs=handles.fs;name=handles.name;mulaw(origin,name);% --- Executes on button press in uniform_generate_pushbutton.function uniform_generate_pushbutton_Callback(hObject, eventdata, handles)% hObject handle to uniform_generate_pushbutton (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)%生成基于uniform律的壓縮文件origin=handles.origin;fs=handles.fs;name=handles.name;pcm(origin,name);% --- Executes on button press in compare_plot_pushbutton.function compare_plot_pushbutton_Callback(hObject, eventdata, handles)% hObject handle to compare_plot_pushbutton (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)%讀入界面中獲取的左右端點值h_left=findobj(gcbf,'Tag','left_edit');h_right=findobj(gcbf,'Tag','right_edit');left=eval(get(h_left,'String'));right=eval(get(h_right,'String'));%分別繪出該段的曲線圖像cla;axes(handles.axes2);plot([left:right],handles.origin(left:right));axes(handles.axes4);plot([left:right],handles.uniform_data(left:right));axes(handles.axes5);plot([left:right],handles.alaw_data(left:right));axes(handles.axes6);plot([left:right],handles.mulaw_data(left:right));function left_edit_Callback(hObject, eventdata, handles)% hObject handle to left_edit (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 left_edit as text% str2double(get(hObject,'String')) returns contents of left_edit as a double% --- Executes during object creation, after setting all properties.function left_edit_CreateFcn(hObject, eventdata, handles)% hObject handle to left_edit (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 right_edit_Callback(hObject, eventdata, handles)% hObject handle to right_edit (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 right_edit as text% str2double(get(hObject,'String')) returns contents of right_edit as a double% --- Executes during object creation, after setting all properties.function right_edit_CreateFcn(hObject, eventdata, handles)% hObject handle to right_edit (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 reset_pushbutton.function reset_pushbutton_Callback(hObject, eventdata, handles)% hObject handle to reset_pushbutton (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)axes(handles.axes2);cla;axes(handles.axes4);cla;axes(handles.axes5);cla;axes(handles.axes6);cla;% --- Executes on button press in origin_play.function origin_play_Callback(hObject, eventdata, handles)% hObject handle to origin_play (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)wavplay(handles.origin,handles.fs);% --- Executes on button press in uniform_play.function uniform_play_Callback(hObject, eventdata, handles)% hObject handle to uniform_play (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)%基于均勻pcm的解碼uniform_data=unpcm(handles.name);handles.uniform_data=uniform_data;guidata(hObject,handles);%畫出圖像axes(handles.axes4);plot(uniform_data);axis([0 length(handles.origin) -1 1]);%聲音回放wavplay(handles.uniform_data,handles.fs);% --- Executes on button press in mulaw_play.function mulaw_play_Callback(hObject, eventdata, handles)% hObject handle to mulaw_play (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)%基于mu律的解碼mulaw_data=unmulaw(handles.name);handles.mulaw_data=mulaw_data;guidata(hObject,handles);%畫出圖像axes(handles.axes6);plot(mulaw_data);axis([0 length(handles.origin) -1 1]);%聲音回放wavplay(handles.mulaw_data,handles.fs);% --- Executes on button press in alaw_play.function alaw_play_Callback(hObject, eventdata, handles)% hObject handle to alaw_play (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)%基于mu律的解碼alaw_data=unalaw(handles.name);handles.alaw_data=alaw_data;guidata(hObject,handles);%畫出圖像axes(handles.axes5);plot(alaw_data);axis([0 length(handles.origin) -1 1]);%聲音回放wavplay(handles.alaw_data,handles.fs);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -