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

数字信号处理实验8音频频谱分析仪设计与实现(4)

来源:网络收集 时间:2019-04-05 下载这篇文档 手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:或QQ: 处理(尽可能给您提供完整文档),感谢您的支持与谅解。点击这里给我发消息

% See ISPC and COMPUTER.

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end

% --- Executes during object creation, after setting all properties. function pointfrom_CreateFcn(hObject, eventdata, handles) % hObject handle to pointfrom (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 during object creation, after setting all properties. function pointto_CreateFcn(hObject, eventdata, handles) % hObject handle to pointto (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 timeanalyse.

function timeanalyse_Callback(hObject, eventdata, handles) % hObject handle to timeanalyse (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','caiyangpinlv'),'String')); N=str2double(get(findobj('Tag','caiyangdianshu'),'String')); if handles.inputtype==0

msgbox('No wave exist! Please choose a input type!'); return; end

%guo ling jian ce n=1;

ymax=max([handles.y(1) handles.y(2)]); ymin=min([handles.y(1) handles.y(2)]);

from=str2double(get(handles.pointfrom,'String')); to=str2double(get(handles.pointto,'String')); 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;

15 / 21

% 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

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);

if (handles.inputtype==1||handles.inputtype==2||handles.inputtype==4) set(handles.circle,'String','非周期'); set(handles.outfreq,'String','非周期'); end

if(handles.inputtype==3)

set(handles.circle,'String',1/freq);

set(handles.outfreq,'String',num2str(freq)); end

set(handles.outamp,'String',num2str(mean(amp(2:n-1)))); %phase

phase=2*pi*(1-(ti(1:n-1)-1)./T+floor((ti(1:n-1)-1)./T)); set(handles.outphase,'String',num2str(mean(phase))); %peak

set(handles.outpeak,'String',(max(handles.y(from:to))-min(handles.y(from:to)))/2); %mean

set(handles.outmean,'String',mean(handles.y(from:to))); %meansquare

set(handles.outmeansquare,'String',mean(handles.y(from:to).^2)); %s

set(handles.outminus,'String',std(handles.y(from:to))^2);

% --------------------------------------------------------------------

function uipanel18_ButtonDownFcn(hObject, eventdata, handles) % hObject handle to uipanel18 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) [filename,filepath]=uigetfile('*.wav','wavfile'); set(handles.wavname,'string',filename); [handles.y,Fs,bit]=wavread(filename); handles.inputtype=2; guidata(hObject,handles);

plot(handles.axes1,(1:length(handles.y))/Fs,handles.y);

16 / 21

ysize=size(handles.y);

set(handles.samplenum,'String',num2str(ysize(1))); set(handles.samplefre,'string',Fs);

h=waitbar(0,'pleas wait...'); for i=1:10000

waitbar(i/10000,h) end

close(h)

% --- Executes on button press in freqanalyse.

function freqanalyse_Callback(hObject, eventdata, handles) % hObject handle to freqanalyse (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','caiyangpinlv'),'String')); N=str2double(get(findobj('Tag','caiyangdianshu'),'String')); if handles.inputtype==0

msgbox('No wave exist! Please choose a input type!'); return; end

from=str2double(get(handles.pointfrom,'String')); to=str2double(get(handles.pointto,'String')); sample=handles.y(from:to);

f=linspace(0,Fs/2,(to-from+1)/2); Y=fft(sample,to-from+1); [C,I]=max(abs(Y));

if(handles.inputtype==1||handles.inputtype==2||handles.inputtype==4) set(handles.foutt,'String','非周期'); set(handles.foutfreq,'String','非周期'); end

if(handles.inputtype==3)

set(handles.foutt,'String',1/f(I)); set(handles.foutfreq,'String',f(I)); end

Y=Y(1:(to-from+1)/2);

plot(handles.fuzhipu,f,2*sqrt(Y.*conj(Y))); plot(handles.xiangweipu,f,angle(Y)); plot(handles.shipin,f,real(Y)); plot(handles.xupin,f,imag(Y));

plot(handles.gonglvpu,f,abs(Y).^2); xlabel(handles.fuzhipu,'freqency(Hz)'); xlabel(handles.xiangweipu,'freqency(Hz)'); xlabel(handles.shipin,'freqency(Hz)'); xlabel(handles.xupin,'freqency(Hz)'); xlabel(handles.gonglvpu,'freqency(Hz)'); ylabel(handles.fuzhipu,'amplitude'); ylabel(handles.xiangweipu,'phase(rad)'); ylabel(handles.shipin,'real');

ylabel(handles.xupin,'Imaginary'); ylabel(handles.gonglvpu,'power');

五、音频频谱分析仪运行结果

17 / 21

1. 声卡输入

声卡输入的录音是非周期的,故时域分析和频域分析结果都是“非周期”。

2. wav文件输入

由于wav文件是非周期的,故时域分析和频域分析结果都是“非周期”。

3. 信号发生器

18 / 21

(1) 正弦波

(2) 方波

19 / 21

百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库数字信号处理实验8音频频谱分析仪设计与实现(4)在线全文阅读。

数字信号处理实验8音频频谱分析仪设计与实现(4).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印 下载失败或者文档不完整,请联系客服人员解决!
本文链接:https://www.77cn.com.cn/wenku/zonghe/572990.html(转载请注明文章来源)
Copyright © 2008-2022 免费范文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ: 邮箱:tiandhx2@hotmail.com
苏ICP备16052595号-18
× 注册会员免费下载(下载后可以自由复制和排版)
注册会员下载
全站内容免费自由复制
注册会员下载
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: