【语音播放】基于matlab GUI MP3设计【含Matlab源码 425期】

一、简介

基于matlab GUI MP3设计

二、源代码

function varargout = myaudioplayer(varargin)
% MY_MUSIC_ANALYSIS_SOFTWARE M-file for my_music_analysis_software.fig
%      MY_MUSIC_ANALYSIS_SOFTWARE, by itself, creates a new MY_MUSIC_ANALYSIS_SOFTWARE or raises the existing
%      singleton*.
%
%      H = MY_MUSIC_ANALYSIS_SOFTWARE returns the handle to a new MY_MUSIC_ANALYSIS_SOFTWARE or the handle to
%      the existing singleton*.
%
%      MY_MUSIC_ANALYSIS_SOFTWARE('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in MY_MUSIC_ANALYSIS_SOFTWARE.M with the given input arguments.
%
%      MY_MUSIC_ANALYSIS_SOFTWARE('Property','Value',...) creates a new MY_MUSIC_ANALYSIS_SOFTWARE or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before myaudioplayer_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to myaudioplayer_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 my_music_analysis_software

% Last Modified by GUIDE v2.5 14-Jun-2014 17:43:41

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @myaudioplayer_OpeningFcn, ...
                   'gui_OutputFcn',  @myaudioplayer_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 my_music_analysis_software is made visible.
function myaudioplayer_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 my_music_analysis_software (see VARARGIN)

% Choose default command line output for my_music_analysis_software
handles.output = hObject;
handles.output = hObject;
setappdata(handles.my_music_analysis_software,'Max',0);
setappdata(handles.my_music_analysis_software,'fpath',0);
set(handles.my_music_analysis_software,'defaultAxesColor',[0.4 0.5 0.7])
handles.timer1= timer('Period',0.01,'ExecutionMode','FixedRate','TimerFcn',{
    
    @PlotUpdate,handles});
 %handles.timer2= timer('ExecutionMode','singleShot','TimerFcn',{
    
    @close,handles});
% Update handles structure
guidata(hObject, handles);
global n stop1 fs C m a b color1 color2 colorOrder1 ;
n=10;m=0;color1='b';color2='c';
stop1=0;
C=zeros(1,5);
fs=11025;
[a,b]=coef();
colorOrder1 = ['r';'g'; 'b';'c';'m';'y';'k';'w'];
set(handles.jindu_var,'min',0);
set(handles.jindu_var,'max',100);
equalizer_plot();
% Update handles structure
guidata(hObject, handles);

% UIWAIT makes my_music_analysis_software wait for user response (see UIRESUME)
% uiwait(handles.my_music_analysis_software);


% --- Outputs from this function are returned to the command line.
function varargout = myaudioplayer_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 button_load.
function button_load_Callback(hObject, eventdata, handles)
% hObject    handle to button_load (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
stop(handles.timer1);
global n stop1 x y fs  C w fpath step w1 w2 w3 w4 w5 a b;
n=1;
[filename, pathname] = uigetfile( ...
       {
    
    '*.wav', 'All Image Files (*.wav)'; ...
        '*.*',                   'All Files (*.*)'}, ...
        'Pick a wave');
if isequal(filename,0) || isequal(pathname,0),
return;
end
fpath=[pathname filename];
y=wavread(fpath);
 w1=filter(10^(C(1)/20)*b{
    
    1},a{
    
    1},y);
 w2=filter(10^(C(2)/20)*b{
    
    2},a{
    
    2},y);
 w3=filter(10^(C(3)/20)*b{
    
    3},a{
    
    3},y);
 w4=filter(10^(C(4)/20)*b{
    
    4},a{
    
    4},y);
 w5=filter(10^(C(5)/20)*b{
    
    5},a{
    
    5},y);
 w=w1+w2+w3+w4+w5;
% w=y;
x=audioplayer(y,fs);
stop1=0;
Max=length(y);
setappdata(handles.my_music_analysis_software,'Max',Max);
setappdata(handles.my_music_analysis_software,'fpath',fpath);
set(handles.jindu_var,'max',100);
str=ConvTime(fix(x.TotalSamples/fs));
set(handles.text_begin,'string','0:00');
set(handles.text_end,'string',str);
step=fix(x.TotalSamples/fs/4);
%Info= strcat('正在播放:   ',filename);
set(handles.text_info,'string',filename);
guidata(hObject,handles); 



% --- Executes on button press in button_play.
function button_play_Callback(hObject, eventdata, handles)
% hObject    handle to button_play (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global x w fs stop1;
    x=audioplayer(w,fs);
    play(x);
    stop1=0;
    start(handles.timer1);

% --- Executes on button press in button_pause.
function button_pause_Callback(hObject, eventdata, handles)
% hObject    handle to button_pause (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global  stop1 x ;
     stop1=1;
     pause(x);
guidata(hObject,handles); 


% --- Executes on button press in button_continue.
function button_continue_Callback(hObject, eventdata, handles)
% hObject    handle to button_continue (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
    global  stop1 x ;
    stop1=0;
    resume(x);

% --- Executes on button press in button_stop.
function button_stop_Callback(hObject, eventdata, handles)
% hObject    handle to button_stop (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global x;
stop(x);
stop(handles.timer1);


function PlotUpdate(obj,events,handles)
global n w stop1 x  fs t color1;
str=ConvTime(fix(x.CurrentSample/fs));
set(handles.text_time_info,'Visible','on');
set(handles.text_time,'string',str);
if (stop1==0)
    if(isplaying(x))
        t=x.CurrentSample/x.TotalSamples;
        set(handles.jindu_var,'value',100*t)

 Max=getappdata(handles.my_music_analysis_software,'Max');
 fpath=getappdata(handles.my_music_analysis_software,'fpath');
if 1100*n<Max 
    m=w(1100*(n-1)+1:1100*n); 
    M=abs(fft(m));
for s=1:32
    Z(s)=mean(M((s-1)*15+1:s*15));
end
axes(handles.axes1);
h1=bar(Z,color1);
axis off;box off;
set(h1,'ButtonDownFcn',{
    
    @Changecolor, 1});
end
n=n+1;
    end
end


% --- Executes on slider movement.
function jindu_var_Callback(hObject, eventdata, handles)
% hObject    handle to jindu_var (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,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
global x n;
duty=get(hObject,'value');
Setting=x.TotalSamples*duty/100;
Cul=x.CurrentSample;
stop(x);
play(x,Setting);
n=fix(Setting/1100);



% --- Executes during object creation, after setting all properties.
function jindu_var_CreateFcn(hObject, eventdata, handles)
% hObject    handle to jindu_var (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.502 .502 .502]);
end

三、运行结果

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

四、备注

完整代码或者代写添加QQ 1564658423
往期回顾>>>>>>
【信号处理】基于matlab HMM的睡眠状态检测【含Matlab源码 050期】
【信号处理】基于matlab CDR噪声和混响抑制【含Matlab源码 051期】
【信号处理】基于matlab最小二乘法解决稀疏信号恢复问题【含Matlab源码 052期】
【信号处理】基于matlab小波变换的音频水印嵌入提取【含Matlab源码 053期】
【信号处理】基于matlab ICA算法信号分离【含Matlab源码 054期】
【信号处理】基于matlab GUI界面的脉搏信号之脉率存档【含Matlab源码 237期】
【信号处理】基于matlab GUI界面的虚拟信号发生器(各种波形)【含Matlab源码 271期】
【信号处理】基于matlab GUI界面信号发生器之电子琴【含Matlab源码 272期】
【信号处理】基于matlab的数字电子琴设计与实现【含Matlab源码 273期】
【雷达通信】基于matlab的雷达数字信号处理【含Matlab源码 281期】
【雷达通信】基于matlab线性调频(LFM)脉冲压缩雷达仿真【含Matlab源码 283期】
【雷达通信】基于mtatlab距离多普勒(RD)、CS、RM算法的机载雷达成像【含Matlab源码 284期】
【雷达通信】《现代雷达系统分析与设计》大作业【含Matlab源码 285期】
【信号处理】基于matlab GUI语音信号综合处理平台【含Matlab源码 290期】
【信号处理】基于matlab GUI语音信号采集【含Matlab源码 291期】
【信号处理】基于matlab GUI语音幅度调制【含Matlab源码 292期】
【信号处理】基于matlab GUI语音合成【含Matlab源码 293期】
【信号处理】基于matlab GUI语音基频识别【含Matlab源码 294期】
【信号处理】基于matlab GUI语音信号加密解密【含Matlab源码 295期】
【信号处理】基于matlab小波变换的语音增强【含Matlab源码 296期】
【信号处理】基于matlab GUI语音傅立叶变换降噪混频【含Matlab源码 297期】
【信号处理】基于matlab GUI维纳滤波之语音增强【含Matlab源码 298期】
【音频处理】基于matlab GUI语音信号处理2【含Matlab源码 299期】
【雷达通信】基于matlab GUI雷达定位【含Matlab源码 302期】
【雷达通信】基于matlab GUI雷达脉冲压缩【含Matlab源码 303期】
【雷达通信】基于matlab GUI雷达定位模拟【含Matlab源码 304期】
【雷达通信】基于matlab SVM识别雷达数据【含Matlab源码 305期】
【雷达图像】SAR合成孔径雷达成像及处理【含Matlab源码 307期】
【信息处理】基于GUI数字波束的算法库【含Matlab源码 313期】
【通信】基于matlab的OFDM-MIMO通信建模与仿真【含Matlab源码 314期】
【通信】基于matlab的OFDM仿真【含Matlab源码 315期】
【信号处理】基于matlab窗函数法的FIR数字滤波器设计【含Matlab源码 316期】
【通信】基于matlab FIR低通数字滤波器设计【含Matlab源码 323期】
【通信】基于matlab FIR IIR数字滤波器设计【含Matlab源码 324期】
【信号处理】基于matlab的语音信号频谱分析仪【含Matlab源码 325期】
【调制信号】基于matlab GUI数字调制信号仿真【含Matlab源码 336期】
【通信】基于matlab的扩频通信系统设计【含Matlab源码 337期】
【通信】基于matlab多径衰落信道的仿真【含Matlab源码 338期】
【语音识别】基于matlab BP神经网络的语音情感识别【含Matlab源码 349期】
【信号处理】基于matlab音频水印嵌入与提取【含Matlab源码 350期】
【音频水印】基于matlab小波变换的量化音频数字水印【含Matlab源码 351期】
【语音去噪】基于matlab低通和自适应滤波去噪【含Matlab源码 352期】
【信号处理】基于matlab 8级m序列【含Matlab源码 353期】
【情感识别】基于matlab GUI语音情感分类识别【含Matlab源码 354期】
【信号处理】基于matlab FIR与IIR滤波器低通、高通、带通设计【含Matlab源码 360期】
【语音处理】基于matlab语音信号的预处理【含Matlab源码 364期】
【语音识别】基于matlab 傅立叶变换0-9的数字语音识别【含Matlab源码 384期】
【语音识别】基于matlab GUI DTW的0-9数字语音识别【含Matlab源码 385期】

猜你喜欢

转载自blog.csdn.net/TIQCmatlab/article/details/114224402