实验八:音频频谱分析仪设计与实现
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
实验八:音频频谱分析仪设计与实现
一、实验原理:
MATLAB 是一个数据分析和处理功能十分强大的工程实用软件,其数据采集工具箱为实现数据的输入和输出提供了十分方便的函数和命令。
本实验要求基于声卡与MATLAB 实现音频信号频谱分析仪的设计原理与实现,功能包括:
(1)音频信号输入,从声卡输入,从W A V 文件输入,从标准信号发生器输入;
(2)信号波形分析,包括幅值,频率,周期,相位的估计,以及统计量峰值,均值,均方值和方差的计算;
(3)信号频谱分析,频率,周期的估计,图形显示幅值谱,相位谱,实频谱,虚频谱和功率谱的曲线。
1.频率(周期)检测
对周期信号来说,可以用时域波形分析来确定信号的周期,也就是计算相邻的两个信号波峰的时间差,或过零点的时间差。
这里采用过零点(t )的时间差T (周期)。
频率即为频率即为f=1/T ,由于能够求得多个T 值,故采用他们的平均值作为周期的估计值。
2.幅值检测
在一个周期内,求出信号最大值max y 与最小值min y 的差得一半记为A ,同样得到多个A 值,但第一个A 值对应的max y 和min y 不是在一个周期内搜索得到的,故以除第一个以外的A 值的平均作为幅值的估计值。
3.相位检测
采用过零法,即通过判断与同频零相位信号过零点时刻,计算其时间差,然后换成相应的相
位差。
)π(T /ti -12=ϕ,同样以ϕ的平均值作为相位的估计值。
4.数字信号统计量估计
(1)峰值P 的估计
在样本数据x 中找出最大值与最小值,其差为双峰值,双峰值的一半即为峰值。
P=0.5[max(y)-min(y)]
(2)均值估计
∑=
Ni=0iyN 1)y (E N 为样本容量。
(3)均方值估计
∑=Ni=0iy22N 1
)y (E
(4)方差估计
∑=Ni=0
iy2))(E -(N 1)y (D y 5.频谱分析原理
时域分析只能反映信号的幅值随时间的变化情况,除但频率分量的简单波形外,很难明确提示信号的频率组成和各频率分量大小,而频谱分析能很好的解决此问题。
(1)DFT 与FFT
对于给定的时域信号y ,可以通过Fourier 变换得到频域信息Y 。
Y 可按下式计算
式中,N为样本容量,Δt = 1/Fs为采样间隔。
采样信号的频谱是一个连续的频谱,不可能计算出所有的点的值,故采用离散Fourier变换(DFT),即
式中,Δf = Fs/N。
但上式的计算效率很低,因为有大量的指数(等价于三角函数)运算,故实际中多采用快速Fourier变换(FFT)。
其原理即是将重复的三角函数算计的中间结果保存起来,以减少重复三角函数计算带来的时间浪费。
由于三角函数计算的重复量相当大,故FFT 能极大地提高运算效率。
(2)频率、周期的估计
对于Y(kΔf),如果当kΔf = ~
f时,Y(kΔf)取最大值,则
~
f为频率的估计值,由于采样间隔
的误差,~
f也存在误差,其误差最大为Δf / 2,周期T=1/f。
从原理上可以看出,如果在标准信号中混有噪声,用上述方法仍能够精确地估计出原标准信号的频率和周期。
(3)频谱图
为了直观地表示信号的频率特性,工程上常常将Fourier变换的结果用图形的方式表示,即频谱图。
以频率f为横坐标,|Y(f)|为纵坐标,可以得到幅值谱;
以频率f为横坐标,arg Y(f)为纵坐标,可以得到相位谱;
以频率f为横坐标,Re Y(f)为纵坐标,可以得到实频谱;
以频率f为横坐标,Im Y(f)为纵坐标,可以得到虚频谱。
根据采样定理,只有频率不超过Fs/2的信号才能被正确采集,即Fourier变换的结果中频率大于Fs/2的部分是不正确的部分,故不在频谱图中显示。
即横坐标f ∈[0, Fs/2]
(4)模块划分
模块化就是把程序划分成独立命名且可独立访问的模块,每个模块完成一个子功能,把这些模块集成起来构成一个整体,可以完成制定的功能,满足用户需求。
在模块分化时应遵循如下原则:改进软件结构提高模块独立性;模块规模应该适中;深度、宽度、扇出和扇入都应适当;模块的作用域应该在控制域之内;力争降低模块接口的复杂程度;设计单入口单出口的模块;模块功能应该可以预测。
二、实验内容:
参考给定的代码,构建交互界面,设计一个音频频谱分析仪,实现相应的功能。
程序文本:
function varargout = GGfig(varargin)
% GGFIG M-file for GGfig.fig
% GGFIG, by itself, creates a new GGFIG or raises the existing % singleton*.
%
% H = GGFIG returns the handle to a new GGFIG or the handle to % the existing singleton*.
%
% GGFIG('CALLBACK',hObject,eventData,handles,...) calls the
local
% function named CALLBACK in GGFIG.M with the given input arguments.
%
% GGFIG('Property','Value',...) creates a new GGFIG or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before GGfig_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to GGfig_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 GGfig
% Last Modified by GUIDE v2.5 26-Dec-2014 21:19:45
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @GGfig_OpeningFcn, ...
'gui_OutputFcn', @GGfig_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if 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 GGfig is made visible.
function GGfig_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 GGfig (see VARARGIN)
% Choose default command line output for GGfig
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes zhaiqi wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line. function varargout = GGfig_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
varargout{1} = handles.output;
% --- Executes on button press in inputradiobutton.
function inputradiobutton_Callback(hObject, eventdata, handles)
% hObject handle to inputradiobutton (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 inputradiobutton
function filename_Callback(hObject, eventdata, handles)
% hObject handle to filename (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 filename as text % str2double(get(hObject,'String')) returns contents of filename as a double
% --- Executes during object creation, after setting all properties. function filename_CreateFcn(hObject, eventdata, handles)
% hObject handle to filename (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 pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles) [filename,pathname]=uigetfile('*.wav');
set(handles.filename,'String',filename);
% 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) temp = wavread(get(findobj('Tag','filename'),'String'));
channel = str2double(get(handles.channelinput,'String'));
handles.y = temp(:,channel);
plot(handles.axes3,[0:length(handles.y)-1],handles.y);%波形
title('波形');
guidata(hObject, handles);
ysize = size(handles.y);
set(handles.edit4,'String',num2str(ysize(1)));
set(handles.edit20,'String',num2str(ysize(1)));
function channelinput_Callback(hObject, eventdata, handles)
% hObject handle to channelinput (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 channelinput as text
% str2double(get(hObject,'String')) returns contents of channelinput as a double
% --- Executes during object creation, after setting all properties. function channelinput_CreateFcn(hObject, eventdata, handles)
% hObject handle to channelinput (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
function edit3_Callback(hObject, eventdata, handles)
% hObject handle to edit3 (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 edit3 as text
% str2double(get(hObject,'String')) returns contents of edit3 as a double
% --- Executes during object creation, after setting all properties. function edit3_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit3 (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
function edit4_Callback(hObject, eventdata, handles)
% hObject handle to edit4 (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 edit4 as text
% str2double(get(hObject,'String')) returns contents of edit4 as a double
% --- Executes during object creation, after setting all properties. function edit4_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit4 (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 mouse press over axes background.
function axes2_ButtonDownFcn(hObject, eventdata, handles)
% hObject handle to axes2 (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 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) from = str2double(get(findobj('Tag','edit19'),'String'));
to = str2double(get(findobj('Tag','edit20'),'String'));
Fs = str2double(get(findobj('Tag','edit3'),'String'));
temp2 = handles.y(from:to);
H = fft(temp2,to-from+1);
L = ceil(length(H)/2);
n = 0:L-1;
[C,I] = max(abs(H));
set(handles.edit13,'String',1/(n(I)/L*pi*Fs/2/pi));
set(handles.edit14,'String',(n(I)/L*pi*Fs/2/pi));
if(I == 1)
set(handles.edit13,'String','无限长');
set(handles.edit14,'String','直流');
end
%guo ling jian ce
n=1;
ymax=max([handles.y(1) handles.y(2)]);
ymin=min([handles.y(1) handles.y(2)]);
if from<1 | to-from<5;
msgbox('Error range!');
return;
end
for i=from+2:to-1;
if handles.y(i-1)<0 & handles.y(i-2)<0 & handles.y(i)>=0 & handles.y(i+1)>0
if handles.y(i)==0
ti(n)=i;
else
ti(n)=i-handles.y(i)/(handles.y(i)-handles.y(i-1));
% x1=i-1;
% y1=handles.y(i-1);
% x2=i;
% y2=handles.y(i);
% a=handles.y(i)-handles.y(i-1);
% b=a*x1-y1;
% ti(n)=b/a;
end
amp(n)=(ymax-ymin)/2;
ymax=0;
ymin=0;
n=n+1;
else
if ymax<handles.y(i)
ymax=handles.y(i);
end
if ymin>handles.y(i)
ymin=handles.y(i);
end
end
end
n=n-1;
%freqence and periodicity
for i=1:n-1
T(i)=ti(i+1)-ti(i);
end
freq = Fs/mean(T);%计算频率
set(handles.edit5,'String',1/freq);%周期
set(handles.edit6,'String',num2str(freq));%频率
%幅值
set(handles.edit7,'String',num2str(mean(amp(2:n-1))));
%相位
phase = 2*pi*(1-(ti(1:n-1)-1)./T+floor((ti(1:n-1)-1)./T));
set(handles.edit8,'String',num2str(mean(phase)));
%峰值
set(handles.edit9,'String',(max(handles.y(from:to))-min(handles.y (from:to)))/2);
%均值
set(handles.edit10,'String',mean(handles.y(from:to)));
%均方值
set(handles.edit11,'String',mean(handles.y(from:to).^2));
%半方差
set(handles.edit12,'String',std(handles.y(from:to))^2);
function pushbutton8_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) from = str2double(get(findobj('Tag','edit19'),'String'));
to = str2double(get(findobj('Tag','edit20'),'String'));
Fs = str2double(get(findobj('Tag','edit3'),'String'));
temp2 = handles.y(from:to);
H = fft(temp2,to-from+1);
L = ceil(length(H)/2);
n = 0:L-1;
plot(handles.axes2,n/L*Fs/2/1000,2*sqrt(H(1:L).*conj((H(1:L))))); %幅度谱
grid;
plot(handles.axes4,n/L*Fs/2/1000,angle(H(1:L)));%相位谱
plot(handles.axes5,n/L*Fs/2/1000,real(H(1:L)));%实频
plot(handles.axes6,n/L*Fs/2/1000,imag(H(1:L)));%虚频
plot(handles.axes7,n/L*Fs/2/1000,abs(H(1:L)).^2);%功率谱
[C,I] = max(abs(H));
set(handles.edit13,'String',1/(n(I)/L*pi*Fs/2/pi));
set(handles.edit14,'String',(n(I)/L*pi*Fs/2/pi));
if(I == 1)
set(handles.edit13,'String','无限长');
set(handles.edit14,'String','直流');
end
%guo ling jian ce
n=1;
ymax=max([handles.y(1) handles.y(2)]);
ymin=min([handles.y(1) handles.y(2)]);
if from<1 | to-from<5;
msgbox('Error range!');
return;
end
for i=from+2:to-1;
if handles.y(i-1)<0 & handles.y(i-2)<0 & handles.y(i)>=0 & handles.y(i+1)>0
if handles.y(i)==0
ti(n)=i;
else
ti(n)=i-handles.y(i)/(handles.y(i)-handles.y(i-1));
% x1=i-1;
% y1=handles.y(i-1);
% x2=i;
% y2=handles.y(i);
% a=handles.y(i)-handles.y(i-1);
% b=a*x1-y1;
% ti(n)=b/a;
end
amp(n)=(ymax-ymin)/2;
ymax=0;
ymin=0;
n=n+1;
else
if ymax<handles.y(i)
ymax=handles.y(i);
end
if ymin>handles.y(i)
ymin=handles.y(i);
end
end
end
n=n-1;
%freqence and periodicity
for i=1:n-1
T(i)=ti(i+1)-ti(i);
end
function edit5_Callback(hObject, eventdata, 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
function edit6_Callback(hObject, eventdata, handles)
% hObject handle to edit6 (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 edit6 as text
% str2double(get(hObject,'String')) returns contents of edit6 as a double
% --- Executes during object creation, after setting all properties. function edit6_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit6 (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
function edit7_Callback(hObject, eventdata, handles)
% hObject handle to edit7 (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 edit7 as text
% str2double(get(hObject,'String')) returns contents of
edit7 as a double
% --- Executes during object creation, after setting all properties. function edit7_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit7 (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
function edit8_Callback(hObject, eventdata, handles)
% hObject handle to edit8 (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 edit8 as text
% str2double(get(hObject,'String')) returns contents of edit8 as a double
% --- Executes during object creation, after setting all properties. function edit8_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit8 (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
function edit9_Callback(hObject, eventdata, handles)
% hObject handle to edit9 (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 edit9 as text
% str2double(get(hObject,'String')) returns contents of edit9 as a double
% --- Executes during object creation, after setting all properties. function edit9_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit9 (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
function edit10_Callback(hObject, eventdata, handles)
% hObject handle to edit10 (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 edit10 as text % str2double(get(hObject,'String')) returns contents of edit10 as a double
% --- Executes during object creation, after setting all properties. function edit10_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit10 (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
function edit11_Callback(hObject, eventdata, handles)
% hObject handle to edit11 (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 edit11 as text % str2double(get(hObject,'String')) returns contents of edit11 as a double
% --- Executes during object creation, after setting all properties. function edit11_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit11 (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
function edit12_Callback(hObject, eventdata, handles)
% hObject handle to edit12 (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 edit12 as text % str2double(get(hObject,'String')) returns contents of edit12 as a double
% --- Executes during object creation, after setting all properties. function edit12_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit12 (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
function edit13_Callback(hObject, eventdata, handles)
% hObject handle to edit13 (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 edit13 as text % str2double(get(hObject,'String')) returns contents of edit13 as a double
% --- Executes during object creation, after setting all properties. function edit13_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit13 (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
function edit14_Callback(hObject, eventdata, handles)
% hObject handle to edit14 (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 edit14 as text % str2double(get(hObject,'String')) returns contents of edit14 as a double
% --- Executes during object creation, after setting all properties. function edit14_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit14 (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 radiobutton3.
function radiobutton3_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton3 (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 radiobutton3
% --- Executes on button press in radiobutton4.
function radiobutton4_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton4 (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 radiobutton4
function edit15_Callback(hObject, eventdata, handles)
% hObject handle to edit15 (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 edit15 as text % str2double(get(hObject,'String')) returns contents of edit15 as a double
% --- Executes during object creation, after setting all properties. function edit15_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit15 (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 pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% 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)
Fs = str2double(get(findobj('Tag','edit3'),'String'));
handles.y = wavrecord(str2double(get(handles.edit15,'String'))*Fs,Fs);
guidata(hObject,handles);
plot(handles.axes3,handles.y);%波形
title('波形');
ysize = size(handles.y);
set(handles.edit4,'String',num2str(ysize(1)));
set(handles.edit20,'String',num2str(ysize(1)));
% --- Executes on selection change in listbox1.
function listbox1_Callback(hObject, eventdata, handles)
% hObject handle to listbox1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% Hints: contents = get(hObject,'String') returns listbox1 contents as cell array
% contents{get(hObject,'Value')} returns selected item from listbox1
% --- Executes during object creation, after setting all properties. function listbox1_CreateFcn(hObject, eventdata, handles)
% hObject handle to listbox1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called
% Hint: listbox 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 selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)。