function varargout = sigany(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @sigany_OpeningFcn, ...
'gui_OutputFcn', @sigany_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 sigany is made visible.
function sigany_OpeningFcn(hObject, ~, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);
function varargout = sigany_OutputFcn(~, ~, handles)
varargout{1} = handles.output;
% --- Executes on button press in start.
% --------------------------------------------------------------------
function init_Callback(hObject, eventdata, handles)%清理内存 初始化
clear all;
clc;
% --------------------------------------------------------------------
function openexistdata_Callback(hObject, ~, handles)%打开音频,并显示时域波形
[FileName,PathName]= uigetfile('*.wav'); %打开对话框
if ~isequal(FileName, 0)
% open(file);
[y, fs]=wavread([PathName FileName]);%x是音频的数据向量,fs是采样频率(单位Hz),bits是每一个采样点的数据深度(即比特数)
end
handles.data=y; %x是向量含有的所有数字的个数,与数据的大小有关
handles.sample=fs; %采样的频率 一般为8k
t=length(handles.data)/fs; %采样的总时间
tt=0:t/length(handles.data):t; %中间计算出来的采样周期
handles.t=tt(1:length(tt)-1); %作为要显示图形的横坐标
guidata(hObject, handles); %保存更新
axes(handles.axes2); %打开的文件显示在第二个里
plot(handles.t,y); % ±ò¨
ylabel('signal Magnitude ');
xlabel('time(s)');
title('时域波形');
% --------------------------------------------------------------------
% --------------------------------------------------------------------
function wavsave_Callback(~, ~, handles) %时域保存
% hObject handle to wavsave (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[file,path] = uiputfile('wave.jpg','Save file name'); %打开保存窗口
%~isempty(handles.data);
h=figure; %画图
plot(handles.t,handles.data);
saveas(h,[path file]); %保存
close(h);
% --------------------------------------------------------------------
function savefftpic_Callback(~, ~, handles)%频谱保存
% hObject handle to savefftpic (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
Fs=handles.sample; % 采样率
data=handles.data; % 样本向量
blockSize=length(data); % 样本大小
xFFT = fft(data); % 快速傅里叶变换
xfft = abs(xFFT); % 离散傅里叶变换的幅值
index = xfft == 0;
xfft(index) = 1e-17;
mag = 20*log10(xfft); %20倍的log以10为底求对数
mag = mag(1:blockSize/2); %只取前一半
%原因:对实信号fft,产生了负频率,由于FFT变化是对称的,
%所以负频率对应到了Fs/2~Fs上,对实信号而言,该段频率没有任何意义,
%所以只显示到Fs/2。
%f = (0:length(mag)-1)*Fs/blockSize;
f = (0:length(mag)-1)*Fs/blockSize; %求横坐标 频率序列
[file,path] = uiputfile('fft.jpg','Save file name'); %保存图片,同上
h=figure;
plot(f(:,1),mag(:,1));
ylabel('Magnitude (dB)');
xlabel('Frequency (Hz)');
title('频谱图');
saveas(h,[path file]);
close(h);
% --------------------------------------------------------------------
function picdaopusave_Callback(~, ~, handles)%倒谱保存
% hObject handle to picdaopusave (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
c=fft(log(abs(handles.data)+eps));% 取模 取对数 快速傅里叶 求出倒谱 eps返回参数的精度
ms1=handles.sample/1000;
ms20=handles.sample/50;
q=(ms1:ms20)/handles.sample; % 横坐标 时间序列
[file,path] = uiputfile('daopu.jpg','Save file name');
h=figure; %作图 保存
plot(q,abs(c(ms1:ms20)));
xlabel('倒角');
ylabel('倒谱幅度');
title('倒谱图');
saveas(h,[path file]);
close(h);
% --------------------------------------------------------------------
function picyupusave_Callback(~, ~, handles) %语谱图保存
% hObject handle to picyupusave (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
Winsiz=256;Shift=128;Base=0;%帧长 帧移植 基准电平值
signal=handles.data;
fs=handles.sample;
nseg=floor((length(signal)-Winsiz)/Shift)+1; %floor 朝负无穷方向舍入
A=zeros(Winsiz/2+1,nseg);
%下面循环是x信号的加窗处理并求出各点频谱能量
for i=1:nseg
n1=(i-1)*Shift+1;
n2=n1+(Winsiz-1);
xx=signal(n1:n2);
xx=xx.*hamming(Winsiz);
y=fft(xx);
y=y(1:Winsiz/2+1);
y=y.*conj(y);
y=10*log10(y);
A(:,i)=y;
end
L1=(A>Base);
L0=(A<Base);
B=A.*L1+Base*L0;
C=(B-Base)./(max(max(B))-Base);%灰度
y=[0:Winsiz/2]*fs/Winsiz; %纵坐标频率
x=[0:nseg-1]*Shift; %横坐标时间
%保存
[file,path] = uiputfile('yuputu.jpg','Save file name');
h=figure;
imagesc(x,y,C);axis xy;
saveas(h,[path file]);
close(h);
function picsaveglp_Callback(~, ~, handles)%功率谱保存
% hObject handle to picsaveglp (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
Fs=handles.sample; %
xn=handles.data;
window=rectwin(length(xn)); %矩形加窗
nfft=1024;
[Pxx,f]=periodogram(xn,window,nfft,Fs); %求功率谱的
[file,path] = uiputfile('gonglvpu.jpg','Save file name');%保存文件
h=figure;
plot(f,10*log10(Pxx));
title('功率谱');
saveas(h,[path file]);
close(h);
% --- Executes on button press in wavepos.
function wavepos_Callback(~, ~, handles) %时域回调
% hObject handle to wavepos (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
y=handles.data; % ù
axes(handles.axes2); % èúò
plot(handles.t,y); % 时域直接表示即可
ylabel('signal Magnitude ');
xlabel('time(s)');
title('时域波形');
function fftplot_Callback(~, ~, handles)%频域回调
% hObject handle to fftplot (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
Fs=handles.sample; % ù
data=handles.data; % ù
blockSize=length(data);
xFFT = fft(data); % 快速傅里叶变换
xfft = abs(xFFT); % 取模值
%index = xfft == 0;
%xfft(index) = 1e-17;
mag = 20*log10(xfft); % 转化成以dB为单位的数值
mag = mag(1:blockSize/2);
f = (0:length(mag)-1)*Fs/blockSize;
axes(handles.axes2);
plot(f(:,1),mag(:,1));
ylabel('Magnitude (dB)');
xlabel('Frequency (Hz)');
title('频谱图');
function glpbutton_Callback(hObject, eventdata, handles) %功率谱的
% hObject handle to glpbutton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
ggp_Callback(hObject, eventdata, handles);
function daopu_Callback(~, ~, handles)%倒谱回调
% hObject handle to daopu (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
c=fft(log(abs(handles.data)+eps)); % ×
ms1=handles.sample/1000;
ms20=handles.sample/50;
q=(ms1:ms20)/handles.sample;
axes(han
没有合适的资源?快使用搜索试试~ 我知道了~
GUI_matlab.zip_GUI语谱图_语音保存_语音功率谱gui_语音处理 GUI
共4个文件
wav:2个
m:1个
fig:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 1 下载量 144 浏览量
2022-09-22
23:52:14
上传
评论
收藏 87KB ZIP 举报
温馨提示
实现物种功能的语音处理:倒谱、时域、频谱、语谱图以及功率谱,并加有详尽的注释。另外还可以保存图像,一倍后来研究!matlab GUI编程
资源推荐
资源详情
资源评论
收起资源包目录
GUI_matlab.zip (4个子文件)
GUI_matlab
sigany.m 11KB
mynewwav.wav 68KB
sigany.fig 7KB
myv.wav 57KB
共 4 条
- 1
资源评论
- 2301_763137762023-04-24资源内容总结的很到位,内容详实,很受用,学到了~
刘良运
- 粉丝: 68
- 资源: 1万+
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功