实验 9 音频信号采集及处理

代码剖析

声音回放

[voice,fs]=audioread('ding.wav'); 
sound(voice,fs); %声音回放

显示音频时域波形

figure(1);
[voice,fs]=audioread('ding.wav'); 
plot(voice); %绘出时域波
xlabel('t'); ylabel('A'); %坐标名称
title(' 初始音频信号时域波形 ','FontName','宋体');
grid on;

显示音频频域波形

figure(2);
[voice,fs]=audioread('ding.wav'); 
n=length(voice); %计算长度
voice1=fft(voice,n);%快速傅里叶变换
plot(abs(voice1)); %绘出原始音频信号频谱
title(' 初始音频信号频域波形 ','FontName','宋体');
xlabel('f'); ylabel('A');
grid on;

声音主要频率1

[signal,fs] = audioread('ding.wav' ); 
len_signal = length( signal );                                      %信号的长度
T = 1/fs;                                                           %采样周期
t = T:T:len_signal/fs;                                              %时间t序列
fft_N = 2^nextpow2( len_signal );                              %计算fft变换的点数
SIGNAL = fft( signal,fft_N );                                  %快速傅里叶变换
SIGNAL_AMP = abs( SIGNAL );         %只做幅频分析,对fft变换后序列取模
SIGNAL_AMP_HALF = SIGNAL_AMP(1:(fft_N/2));%由于对称性,只取前一半
[SIGNAL_pks,locs] = findpeaks( SIGNAL_AMP_HALF );         %寻找频谱峰值点
sort_pks = sort( SIGNAL_pks,'descend' );                  %对频谱峰值点进行排序
sort_loc = find( SIGNAL_pks>=sort_pks(2) ); %找到峰值最大的2个点排序后在pks中的位置
n1 = locs( sort_loc(1) );                                 %最高峰值点在序列中的位置
n2 = locs( sort_loc(2) );         %第二高峰值点在序列中的位置

Y1 = SIGNAL_AMP_HALF(n1);        %最高峰值点在频谱中的幅度
Y2 = SIGNAL_AMP_HALF(n2);         %第二高峰值点在频谱中的幅度

f1 = (n1-1)*fs/fft_N                                     %最高峰值点频率
y1 = (Y1/(Y1+Y2))*cos(2*pi*f1*t);       %第一个频率信号
figure(9);
plot( t,y1 );                    %绘制原信号时域波形
axis( [T len_signal*T -0.08 0.08] );                              %限定显示范围
title( '分解信号时域波形图1' ,'FontName','宋体');                                      %绘制标题
xlabel('时间(s)','FontName','宋体'); ylabel('幅值','FontName','宋体');  

声音主要频率2

[signal,fs] = audioread('ding.wav' ); 

len_signal = length( signal );                                      %信号的长度
T = 1/fs;                                                           %采样周期
t = T:T:len_signal/fs;                                              %时间t序列
fft_N = 2^nextpow2( len_signal );                              %计算fft变换的点数
SIGNAL = fft( signal,fft_N );                                  %快速傅里叶变换
SIGNAL_AMP = abs( SIGNAL );         %只做幅频分析,对fft变换后序列取模
SIGNAL_AMP_HALF = SIGNAL_AMP(1:(fft_N/2));%由于对称性,只取前一半
[SIGNAL_pks,locs] = findpeaks( SIGNAL_AMP_HALF );         %寻找频谱峰值点
sort_pks = sort( SIGNAL_pks,'descend' );                  %对频谱峰值点进行排序
sort_loc = find( SIGNAL_pks>=sort_pks(2) ); %找到峰值最大的2个点排序后在pks中的位置
n1 = locs( sort_loc(1) );                                 %最高峰值点在序列中的位置
n2 = locs( sort_loc(2) );         %第二高峰值点在序列中的位置
Y1 = SIGNAL_AMP_HALF(n1);        %最高峰值点在频谱中的幅度
Y2 = SIGNAL_AMP_HALF(n2);         %第二高峰值点在频谱中的幅度
f1 = (n1-1)*fs/fft_N;                                     %最高峰值点频率
f2 = (n2-1)*fs/fft_N                                     %第二高峰值点频率
y2 = (Y2/(Y1+Y2))*cos(2*pi*f2*t);      %第二个频率信号
figure(8)
plot( t,y2 );                    %绘制原信号时域波形
axis( [T len_signal*T -0.08 0.08] );                              %限定显示范围
title( '分解信号时域波形图2' ,'FontName','宋体');                                      %绘制标题
xlabel('时间(s)','FontName','宋体'); ylabel('幅值','FontName','宋体');  

合成声音播放

[signal,fs] = audioread('ding.wav' ); 

len_signal = length( signal );                                      %信号的长度
T = 1/fs;                                                           %采样周期
t = T:T:len_signal/fs;                                              %时间t序列
fft_N = 2^nextpow2( len_signal );                              %计算fft变换的点数
SIGNAL = fft( signal,fft_N );                                  %快速傅里叶变换
SIGNAL_AMP = abs( SIGNAL );         %只做幅频分析,对fft变换后序列取模
SIGNAL_AMP_HALF = SIGNAL_AMP(1:(fft_N/2));%由于对称性,只取前一半
[SIGNAL_pks,locs] = findpeaks( SIGNAL_AMP_HALF );         %寻找频谱峰值点
sort_pks = sort( SIGNAL_pks,'descend' );                  %对频谱峰值点进行排序
sort_loc = find( SIGNAL_pks>=sort_pks(2) ); %找到峰值最大的2个点排序后在pks中的位置
n1 = locs( sort_loc(1) );                                 %最高峰值点在序列中的位置
n2 = locs( sort_loc(2) );         %第二高峰值点在序列中的位置
Y1 = SIGNAL_AMP_HALF(n1);        %最高峰值点在频谱中的幅度
Y2 = SIGNAL_AMP_HALF(n2);         %第二高峰值点在频谱中的幅度
f1 = (n1-1)*fs/fft_N;                                     %最高峰值点频率
f2 = (n2-1)*fs/fft_N;                                     %第二高峰值点频率

y1 = (Y1/(Y1+Y2))*cos(2*pi*f1*t);       %第一个频率信号
y2 = (Y2/(Y1+Y2))*cos(2*pi*f2*t);      %第二个频率信号
A = max( signal );      %原信号的最大幅度
hecheng = (y1+y2)/max( y1+y2 );        %合成信号归一化
sound( hecheng,fs );                                      %合成音频信号播放

播放加噪信号

[voice,fs]=audioread('ding.wav'); 
n=length(voice); %计算长度
t=0:1/fs:(n-1)/fs;
noise=0.03*sin(2*pi*100000*t'); %100kHz 正弦波噪声
s=voice+noise; %加噪后的音频信号
sound(s,fs); %播放加噪的语音

加噪之后的时域和频谱图

[voice,fs]=audioread('ding.wav'); 
n=length(voice); %计算长度
t=0:1/fs:(n-1)/fs;
noise=0.03*sin(2*pi*100000*t'); %100kHz 正弦波噪声

s=voice+noise; %加噪后的音频信号
figure(3);
n=length(s); %计算长度
voice1=fft(s,n);%快速傅里叶变换
plot(abs(voice1)); %绘出原始音频信号频谱
title(' 加噪音频信号频域波形 ','FontName','宋体');
xlabel('f'); ylabel('A');
grid on;

figure(6);
plot(s); %绘出原始音频信号频谱
title(' 加噪音频信号时域波形 ','FontName','宋体');
xlabel('f'); ylabel('A');
grid on;

显示低通滤波器特性

[voice,fs]=audioread('ding.wav'); 
n=length(voice); %计算长度
t=0:1/fs:(n-1)/fs;
noise=0.03*sin(2*pi*100000*t'); %100kHz 正弦波噪声

s=voice+noise; %加噪后的音频信号

rp=0.1;     %通带最大衰减
rs=60;      %阻带最小衰减
Ft=1000;
Fp=60;      %通带截止频率fp
Fs=100;      %阻带截止频率fs
wp=2*pi*Fp/Ft;%WP是通带截止频率
ws=2*pi*Fs/Ft; %WS是阻带截止频率
[n,wn]=ellipord(wp,ws,rp,rs,'s');% 调用 ellipod 计算椭圆 DF阶数 N和通带截止频率 wp,
[bz,az]=ellip(n,rp,rs,wn);% 调用 ellip 计算椭圆带通 DF系统函数系数向量B和 A
[h,w]=freqz(bz,az);

figure(4);
plot(w*fs/(2*pi),abs(h)); %绘制 IIR 低通滤波器特性曲线
title('IIR 低通滤波器特性曲线 ','FontName','宋体');
grid on;
xlabel('f/Hz');ylabel(' 幅度')

播放滤波后的声音

[voice,fs]=audioread('ding.wav'); 
n=length(voice); %计算长度
t=0:1/fs:(n-1)/fs;
noise=0.03*sin(2*pi*100000*t'); %100kHz 正弦波噪声

s=voice+noise; %加噪后的音频信号

rp=0.1;     %通带最大衰减
rs=60;      %阻带最小衰减
Ft=1000;
Fp=60;      %通带截止频率fp
Fs=100;      %阻带截止频率fs
wp=2*pi*Fp/Ft;%WP是通带截止频率
ws=2*pi*Fs/Ft; %WS是阻带截止频率
[n,wn]=ellipord(wp,ws,rp,rs,'s');% 调用 ellipod 计算椭圆 DF阶数 N和通带截止频率 wp,
[bz,az]=ellip(n,rp,rs,wn);% 调用 ellip 计算椭圆带通 DF系统函数系数向量B和 A
[h,w]=freqz(bz,az);
z=filter(bz,az,s); %滤波
sound(z,fs); %播放加噪的语音

滤波后的时域和频谱图

[voice,fs]=audioread('ding.wav'); 
n=length(voice); %计算长度
t=0:1/fs:(n-1)/fs;
noise=0.03*sin(2*pi*100000*t'); %100kHz 正弦波噪声

s=voice+noise; %加噪后的音频信号

rp=0.1;     %通带最大衰减
rs=60;      %阻带最小衰减
Ft=1000;
Fp=60;      %通带截止频率fp
Fs=100;      %阻带截止频率fs
wp=2*pi*Fp/Ft;%WP是通带截止频率
ws=2*pi*Fs/Ft; %WS是阻带截止频率
[n,wn]=ellipord(wp,ws,rp,rs,'s');% 调用 ellipod 计算椭圆 DF阶数 N和通带截止频率 wp,
[bz,az]=ellip(n,rp,rs,wn);% 调用 ellip 计算椭圆带通 DF系统函数系数向量B和 A
[h,w]=freqz(bz,az);

figure(5);
z=filter(bz,az,s); %滤波

figure(5);
n=length(z); %计算长度
voice1=fft(z,n);%快速傅里叶变换
plot(abs(voice1)); %绘出原始音频信号频谱
title('滤波后音频信号频域波形','FontName','宋体');
xlabel('f'); ylabel('A');
grid on;

figure(7);
plot(z); %绘出原始音频信号频谱
title(' 滤波后音频信号时域波形 ','FontName','宋体');
xlabel('f'); ylabel('A');
grid on;

关闭所有figure

clc;
close all;

鸣谢

感谢我的朋友赵思文轩、陈勇辉为我提供的想法和代码支持

GUI代码

classdef mydsp < matlab.apps.AppBase

    % Properties that correspond to app components
    properties (Access = public)
        UIFigure       matlab.ui.Figure
        dingwavButton  matlab.ui.control.Button
        Button_4       matlab.ui.control.Button
        Button_5       matlab.ui.control.Button
        Button_7       matlab.ui.control.Button
        Button_8       matlab.ui.control.Button
        Button_9       matlab.ui.control.Button
        Button_10      matlab.ui.control.Button
        Button_11      matlab.ui.control.Button
        figureButton   matlab.ui.control.Button
        Button_12      matlab.ui.control.Button
        Button_13      matlab.ui.control.Button
        Button_14      matlab.ui.control.Button
    end

    
    properties (Access = public)
         % Description
    end
    

    % Callbacks that handle component events
    methods (Access = private)

        % Callback function
        function ButtonPushed(app, event)
            clc;
            close all;
            global R;
            R= audiorecorder( 44100, 16 ,1);
            record(R)
            R
        end

        % Callback function
        function Button_2Pushed(app, event)
            global R;
            pause(R);
            R
        end

        % Button pushed function: dingwavButton
        function dingwavButtonPushed(app, event)
            [voice,fs]=audioread('ding.wav'); 
            sound(voice,fs); %声音回放
        end

        % Button pushed function: Button_4
        function Button_4Pushed(app, event)
            figure(1);
            [voice,fs]=audioread('ding.wav'); 
            plot(voice); %绘出时域波
            xlabel('t'); ylabel('A'); %坐标名称
            title(' 初始音频信号时域波形 ','FontName','宋体');
            grid on;
        end

        % Button pushed function: Button_5
        function Button_5Pushed(app, event)
            figure(2);
            [voice,fs]=audioread('ding.wav'); 
            n=length(voice); %计算长度
            voice1=fft(voice,n);%快速傅里叶变换
            plot(abs(voice1)); %绘出原始音频信号频谱
            title(' 初始音频信号频域波形 ','FontName','宋体');
            xlabel('f'); ylabel('A');
            grid on;
        end

        % Callback function
        function Button_6Pushed(app, event)
            wp=2*pi*20000;ws=2*pi*24000;Rp=0.1;As=60;
            [N,wc]=buttord(wp,ws,Rp,As,'s');
            [B,A]=butter(N,wc,'s');
            [voice,fs]=audioread('ding.wav'); 
            
%             n=length(voice); %计算长度
%             voice1=filter(B,A,voice);
%             voice2=fft(voice1,n);%快速傅里叶变换
%             plot(abs(voice2)); %绘出原始音频信号频谱
            
        end

        % Button pushed function: Button_7
        function Button_7Pushed(app, event)
            [voice,fs]=audioread('ding.wav'); 
            n=length(voice); %计算长度
            t=0:1/fs:(n-1)/fs;
            noise=0.03*sin(2*pi*100000*t'); %100kHz 正弦波噪声
            s=voice+noise; %加噪后的音频信号
            sound(s,fs); %播放加噪的语音
        end

        % Button pushed function: Button_8
        function Button_8Pushed(app, event)
            [voice,fs]=audioread('ding.wav'); 
            n=length(voice); %计算长度
            t=0:1/fs:(n-1)/fs;
            noise=0.03*sin(2*pi*100000*t'); %100kHz 正弦波噪声
            
            s=voice+noise; %加噪后的音频信号
            figure(3);
            n=length(s); %计算长度
            voice1=fft(s,n);%快速傅里叶变换
            plot(abs(voice1)); %绘出原始音频信号频谱
            title(' 加噪音频信号频域波形 ','FontName','宋体');
            xlabel('f'); ylabel('A');
            grid on;
            
            figure(6);
            plot(s); %绘出原始音频信号频谱
            title(' 加噪音频信号时域波形 ','FontName','宋体');
            xlabel('f'); ylabel('A');
            grid on;
        end

        % Button pushed function: Button_9
        function Button_9Pushed(app, event)
            [voice,fs]=audioread('ding.wav'); 
            n=length(voice); %计算长度
            t=0:1/fs:(n-1)/fs;
            noise=0.03*sin(2*pi*100000*t'); %100kHz 正弦波噪声
            
            s=voice+noise; %加噪后的音频信号
            
            rp=0.1;     %通带最大衰减
            rs=60;      %阻带最小衰减
            Ft=1000;
            Fp=60;      %通带截止频率fp
            Fs=100;      %阻带截止频率fs
            wp=2*pi*Fp/Ft;%WP是通带截止频率
            ws=2*pi*Fs/Ft; %WS是阻带截止频率
            [n,wn]=ellipord(wp,ws,rp,rs,'s');% 调用 ellipod 计算椭圆 DF阶数 N和通带截止频率 wp,
            [bz,az]=ellip(n,rp,rs,wn);% 调用 ellip 计算椭圆带通 DF系统函数系数向量B和 A
            [h,w]=freqz(bz,az);
            
            figure(4);
            plot(w*fs/(2*pi),abs(h)); %绘制 IIR 低通滤波器特性曲线
            title('IIR 低通滤波器特性曲线 ','FontName','宋体');
            grid on;
            xlabel('f/Hz');ylabel(' 幅度')
        end

        % Button pushed function: Button_10
        function Button_10Pushed(app, event)
            [voice,fs]=audioread('ding.wav'); 
            n=length(voice); %计算长度
            t=0:1/fs:(n-1)/fs;
            noise=0.03*sin(2*pi*100000*t'); %100kHz 正弦波噪声
            
            s=voice+noise; %加噪后的音频信号
            
            rp=0.1;     %通带最大衰减
            rs=60;      %阻带最小衰减
            Ft=1000;
            Fp=60;      %通带截止频率fp
            Fs=100;      %阻带截止频率fs
            wp=2*pi*Fp/Ft;%WP是通带截止频率
            ws=2*pi*Fs/Ft; %WS是阻带截止频率
            [n,wn]=ellipord(wp,ws,rp,rs,'s');% 调用 ellipod 计算椭圆 DF阶数 N和通带截止频率 wp,
            [bz,az]=ellip(n,rp,rs,wn);% 调用 ellip 计算椭圆带通 DF系统函数系数向量B和 A
            [h,w]=freqz(bz,az);
            z=filter(bz,az,s); %滤波
            sound(z,fs); %播放加噪的语音
        end

        % Button pushed function: Button_11
        function Button_11Pushed(app, event)
            [voice,fs]=audioread('ding.wav'); 
            n=length(voice); %计算长度
            t=0:1/fs:(n-1)/fs;
            noise=0.03*sin(2*pi*100000*t'); %100kHz 正弦波噪声
            
            s=voice+noise; %加噪后的音频信号
            
            rp=0.1;     %通带最大衰减
            rs=60;      %阻带最小衰减
            Ft=1000;
            Fp=60;      %通带截止频率fp
            Fs=100;      %阻带截止频率fs
            wp=2*pi*Fp/Ft;%WP是通带截止频率
            ws=2*pi*Fs/Ft; %WS是阻带截止频率
            [n,wn]=ellipord(wp,ws,rp,rs,'s');% 调用 ellipod 计算椭圆 DF阶数 N和通带截止频率 wp,
            [bz,az]=ellip(n,rp,rs,wn);% 调用 ellip 计算椭圆带通 DF系统函数系数向量B和 A
            [h,w]=freqz(bz,az);
            
            figure(5);
            z=filter(bz,az,s); %滤波

            figure(5);
            n=length(z); %计算长度
            voice1=fft(z,n);%快速傅里叶变换
            plot(abs(voice1)); %绘出原始音频信号频谱
            title('滤波后音频信号频域波形','FontName','宋体');
            xlabel('f'); ylabel('A');
            grid on;
            
            figure(7);
            plot(z); %绘出原始音频信号频谱
            title(' 滤波后音频信号时域波形 ','FontName','宋体');
            xlabel('f'); ylabel('A');
            grid on;
        end

        % Button pushed function: figureButton
        function figureButtonPushed(app, event)
            clc;
            close all;
        end

        % Button pushed function: Button_12
        function Button_12Pushed(app, event)
            [signal,fs] = audioread('ding.wav' ); 
            len_signal = length( signal );                                      %信号的长度
            T = 1/fs;                                                           %采样周期
            t = T:T:len_signal/fs;                                              %时间t序列
            fft_N = 2^nextpow2( len_signal );                              %计算fft变换的点数
            SIGNAL = fft( signal,fft_N );                                  %快速傅里叶变换
            SIGNAL_AMP = abs( SIGNAL );         %只做幅频分析,对fft变换后序列取模
            SIGNAL_AMP_HALF = SIGNAL_AMP(1:(fft_N/2));%由于对称性,只取前一半
            [SIGNAL_pks,locs] = findpeaks( SIGNAL_AMP_HALF );         %寻找频谱峰值点
            sort_pks = sort( SIGNAL_pks,'descend' );                  %对频谱峰值点进行排序
            sort_loc = find( SIGNAL_pks>=sort_pks(2) ); %找到峰值最大的2个点排序后在pks中的位置
            n1 = locs( sort_loc(1) );                                 %最高峰值点在序列中的位置
            n2 = locs( sort_loc(2) );         %第二高峰值点在序列中的位置
            
            Y1 = SIGNAL_AMP_HALF(n1);        %最高峰值点在频谱中的幅度
            Y2 = SIGNAL_AMP_HALF(n2);         %第二高峰值点在频谱中的幅度
            
            f1 = (n1-1)*fs/fft_N                                     %最高峰值点频率
            y1 = (Y1/(Y1+Y2))*cos(2*pi*f1*t);       %第一个频率信号
            figure(9);
            plot( t,y1 );                    %绘制原信号时域波形
            axis( [T len_signal*T -0.08 0.08] );                              %限定显示范围
            title( '分解信号时域波形图1' ,'FontName','宋体');                                      %绘制标题
            xlabel('时间(s)','FontName','宋体'); ylabel('幅值','FontName','宋体');                                %绘制横纵坐标的标签
        end

        % Button pushed function: Button_14
        function Button_14Pushed(app, event)
            [signal,fs] = audioread('ding.wav' ); 
            
            len_signal = length( signal );                                      %信号的长度
            T = 1/fs;                                                           %采样周期
            t = T:T:len_signal/fs;                                              %时间t序列
            fft_N = 2^nextpow2( len_signal );                              %计算fft变换的点数
            SIGNAL = fft( signal,fft_N );                                  %快速傅里叶变换
            SIGNAL_AMP = abs( SIGNAL );         %只做幅频分析,对fft变换后序列取模
            SIGNAL_AMP_HALF = SIGNAL_AMP(1:(fft_N/2));%由于对称性,只取前一半
            [SIGNAL_pks,locs] = findpeaks( SIGNAL_AMP_HALF );         %寻找频谱峰值点
            sort_pks = sort( SIGNAL_pks,'descend' );                  %对频谱峰值点进行排序
            sort_loc = find( SIGNAL_pks>=sort_pks(2) ); %找到峰值最大的2个点排序后在pks中的位置
            n1 = locs( sort_loc(1) );                                 %最高峰值点在序列中的位置
            n2 = locs( sort_loc(2) );         %第二高峰值点在序列中的位置
            Y1 = SIGNAL_AMP_HALF(n1);        %最高峰值点在频谱中的幅度
            Y2 = SIGNAL_AMP_HALF(n2);         %第二高峰值点在频谱中的幅度
            f1 = (n1-1)*fs/fft_N;                                     %最高峰值点频率
            f2 = (n2-1)*fs/fft_N;                                     %第二高峰值点频率
            
            y1 = (Y1/(Y1+Y2))*cos(2*pi*f1*t);       %第一个频率信号
            y2 = (Y2/(Y1+Y2))*cos(2*pi*f2*t);      %第二个频率信号
            A = max( signal );      %原信号的最大幅度
            hecheng = (y1+y2)/max( y1+y2 );        %合成信号归一化
            sound( hecheng,fs );                                      %合成音频信号播放
        end

        % Button pushed function: Button_13
        function Button_13Pushed(app, event)
             [signal,fs] = audioread('ding.wav' ); 
            
            len_signal = length( signal );                                      %信号的长度
            T = 1/fs;                                                           %采样周期
            t = T:T:len_signal/fs;                                              %时间t序列
            fft_N = 2^nextpow2( len_signal );                              %计算fft变换的点数
            SIGNAL = fft( signal,fft_N );                                  %快速傅里叶变换
            SIGNAL_AMP = abs( SIGNAL );         %只做幅频分析,对fft变换后序列取模
            SIGNAL_AMP_HALF = SIGNAL_AMP(1:(fft_N/2));%由于对称性,只取前一半
            [SIGNAL_pks,locs] = findpeaks( SIGNAL_AMP_HALF );         %寻找频谱峰值点
            sort_pks = sort( SIGNAL_pks,'descend' );                  %对频谱峰值点进行排序
            sort_loc = find( SIGNAL_pks>=sort_pks(2) ); %找到峰值最大的2个点排序后在pks中的位置
            n1 = locs( sort_loc(1) );                                 %最高峰值点在序列中的位置
            n2 = locs( sort_loc(2) );         %第二高峰值点在序列中的位置
            Y1 = SIGNAL_AMP_HALF(n1);        %最高峰值点在频谱中的幅度
            Y2 = SIGNAL_AMP_HALF(n2);         %第二高峰值点在频谱中的幅度
            f1 = (n1-1)*fs/fft_N;                                     %最高峰值点频率
            f2 = (n2-1)*fs/fft_N                                     %第二高峰值点频率
            y2 = (Y2/(Y1+Y2))*cos(2*pi*f2*t);      %第二个频率信号
            figure(8)
            plot( t,y2 );                    %绘制原信号时域波形
            axis( [T len_signal*T -0.08 0.08] );                              %限定显示范围
            title( '分解信号时域波形图2' ,'FontName','宋体');                                      %绘制标题
            xlabel('时间(s)','FontName','宋体'); ylabel('幅值','FontName','宋体');    
        end
    end

    % Component initialization
    methods (Access = private)

        % Create UIFigure and components
        function createComponents(app)

            % Create UIFigure and hide until all components are created
            app.UIFigure = uifigure('Visible', 'off');
            app.UIFigure.Position = [100 100 640 480];
            app.UIFigure.Name = 'UI Figure';

            % Create dingwavButton
            app.dingwavButton = uibutton(app.UIFigure, 'push');
            app.dingwavButton.ButtonPushedFcn = createCallbackFcn(app, @dingwavButtonPushed, true);
            app.dingwavButton.Position = [76 430 100 24];
            app.dingwavButton.Text = '播放ding.wav';

            % Create Button_4
            app.Button_4 = uibutton(app.UIFigure, 'push');
            app.Button_4.ButtonPushedFcn = createCallbackFcn(app, @Button_4Pushed, true);
            app.Button_4.Position = [76 374 135 24];
            app.Button_4.Text = '显示音频时域波形';

            % Create Button_5
            app.Button_5 = uibutton(app.UIFigure, 'push');
            app.Button_5.ButtonPushedFcn = createCallbackFcn(app, @Button_5Pushed, true);
            app.Button_5.Position = [243 373 123 25];
            app.Button_5.Text = '显示音频频域波形';

            % Create Button_7
            app.Button_7 = uibutton(app.UIFigure, 'push');
            app.Button_7.ButtonPushedFcn = createCallbackFcn(app, @Button_7Pushed, true);
            app.Button_7.Position = [76 229 100 24];
            app.Button_7.Text = '播放加噪信号';

            % Create Button_8
            app.Button_8 = uibutton(app.UIFigure, 'push');
            app.Button_8.ButtonPushedFcn = createCallbackFcn(app, @Button_8Pushed, true);
            app.Button_8.Position = [231 229 147 24];
            app.Button_8.Text = '加噪之后的时域和频谱图';

            % Create Button_9
            app.Button_9 = uibutton(app.UIFigure, 'push');
            app.Button_9.ButtonPushedFcn = createCallbackFcn(app, @Button_9Pushed, true);
            app.Button_9.Position = [76 179 123 24];
            app.Button_9.Text = '显示低通滤波器特性';

            % Create Button_10
            app.Button_10 = uibutton(app.UIFigure, 'push');
            app.Button_10.ButtonPushedFcn = createCallbackFcn(app, @Button_10Pushed, true);
            app.Button_10.Position = [249 179 111 24];
            app.Button_10.Text = '播放滤波后的声音';

            % Create Button_11
            app.Button_11 = uibutton(app.UIFigure, 'push');
            app.Button_11.ButtonPushedFcn = createCallbackFcn(app, @Button_11Pushed, true);
            app.Button_11.Position = [400 179 135 24];
            app.Button_11.Text = '滤波后的时域和频谱图';

            % Create figureButton
            app.figureButton = uibutton(app.UIFigure, 'push');
            app.figureButton.ButtonPushedFcn = createCallbackFcn(app, @figureButtonPushed, true);
            app.figureButton.Position = [260 96 100 24];
            app.figureButton.Text = '关闭所有figure';

            % Create Button_12
            app.Button_12 = uibutton(app.UIFigure, 'push');
            app.Button_12.ButtonPushedFcn = createCallbackFcn(app, @Button_12Pushed, true);
            app.Button_12.Position = [76 291 119 26];
            app.Button_12.Text = '声音主要频率1';

            % Create Button_13
            app.Button_13 = uibutton(app.UIFigure, 'push');
            app.Button_13.ButtonPushedFcn = createCallbackFcn(app, @Button_13Pushed, true);
            app.Button_13.Position = [241 291 119 26];
            app.Button_13.Text = '声音主要频率2';

            % Create Button_14
            app.Button_14 = uibutton(app.UIFigure, 'push');
            app.Button_14.ButtonPushedFcn = createCallbackFcn(app, @Button_14Pushed, true);
            app.Button_14.Position = [400 291 100 26];
            app.Button_14.Text = '合成声音播放';

            % Show the figure after all components are created
            app.UIFigure.Visible = 'on';
        end
    end

    % App creation and deletion
    methods (Access = public)

        % Construct app
        function app = mydsp

            % Create UIFigure and components
            createComponents(app)

            % Register the app with App Designer
            registerApp(app, app.UIFigure)

            if nargout == 0
                clear app
            end
        end

        % Code that executes before app deletion
        function delete(app)

            % Delete UIFigure when app is deleted
            delete(app.UIFigure)
        end
    end
end

代码及ding.wav下载

链接:https://pan.baidu.com/s/1UMIm8A_ThtiTailmHmYnSg
提取码:6666
复制这段内容后打开百度网盘手机App,操作更方便哦

  • 22
    点赞
  • 164
    收藏
    觉得还不错? 一键收藏
  • 12
    评论
LabVIEW是一种用于图形化编程的集成开发环境,可用于音频信号采集处理。在LabVIEW中,我们可以使用各种内置的函数和工具箱来完成这些任务。 首先,我们需要使用合适的硬件设备来进行音频信号采集。常用的设备包括声卡和数据采集卡等。LabVIEW提供了针对这些硬件设备的驱动程序和工具箱,可以轻松地连接和配置这些设备。 然后,我们可以使用LabVIEW的信号处理工具来对采集到的音频信号进行处理。LabVIEW提供了丰富的信号处理函数和工具箱,如滤波、谱分析、傅里叶变换等。我们可以使用这些函数来对信号进行滤波、降噪、频谱分析等操作,从而提取出我们所关注的信息。 此外,LabVIEW还提供了图形化的编程环境,使得我们可以通过拖拽和连接函数块来构建复杂的音频信号处理系统。我们可以将采集到的音频信号与各种信号处理函数进行连接,以实现特定的音频处理功能。 LabVIEW的强大之处在于其易用性和图形化编程的特点。通过拖拽函数块和连接线,我们可以快速搭建音频信号处理系统,即使对于非编程专业背景的人员也能轻松上手。此外,LabVIEW还提供了丰富的示例程序和教程,供我们学习和参考。 总之,LabVIEW是一种强大且易用的工具,适用于音频信号采集处理。通过使用LabVIEW中的信号处理函数和工具箱,我们可以对音频信号进行各种操作,从而实现我们所需要的音频处理功能。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 12
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值