I am making a MATLAB DJ program in which I can load in a song, have it display on a listbox, stop, pause, and play it, as well as determine it's BPM. I am trying to use audioplayer for my push buttons (stop, play, etc.) but for some reason, it is not working properly. I used GUIDE to make my GUI, but I will show my m.file
function varargout = MatlabMedia(varargin)
% MATLABMEDIA M-file for MatlabMedia.fig
% MATLABMEDIA, by itself, creates a new MATLABMEDIA or raises the existing
% singleton*.
%
% H = MATLABMEDIA returns the handle to a new MATLABMEDIA or the handle to
% the existing singleton*.
%
% MATLABMEDIA('CALLBACK',hObject,eventData,handles,. ..) calls the local
% function named CALLBACK in MATLABMEDIA.M with the given input arguments.
%
% MATLABMEDIA('Property','Value',...) creates a new MATLABMEDIA or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before MatlabMedia_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to MatlabMedia_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 MatlabMedia
% Last Modified by GUIDE v2.5 29-Apr-2010 20:22:36
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @MatlabMedia_OpeningFcn, ...
'gui_OutputFcn', @MatlabMedia_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 MatlabMedia is made visible.
function MatlabMedia_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 MatlabMedia (see VARARGIN)
axis off
% Choose default command line output for MatlabMedia
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes MatlabMedia wait for user response (see UIRESUME)
% uiwait(handles.figure1);
global p
p=audioplayer();
% --- Outputs from this function are returned to the command line.
function varargout = MatlabMedia_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 stop.
function stop_Callback(hObject, eventdata, handles)
% hObject handle to stop (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
clear playsnd
% --- Executes on button press in play.
function play_Callback(hObject, eventdata, handles)
% hObject handle to play (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global p
[y f]=wavread(get(handles.list,'String'));
p=audioplayer(y,f);
play(y)
%wavplay(y,f,'async')
% --- Executes on button press in pause.
function pause_Callback(hObject, eventdata, handles)
% hObject handle to pause (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global p
[y f]=wavread(get(handles.list,'String'));
p=audioplayer(y);
pause(y)
% --- Executes on button press in load.
function load_Callback(hObject, eventdata, handles)
% hObject handle to load (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global p
[file path] = uigetfile('*.wav*','Select your song')
song=[path file];
%p=audioplayer(file);
%y=wavread(song);
%song = fullfile(y,file);
set(handles.list,'String',song);
Whenever I try to run my program, I get these errors
??? Error using ==> audioplayer.audioplayer at 44
Not enough input arguments.
Error in ==> MatlabMedia>MatlabMedia_OpeningFcn at 64
p=audioplayer();
Error in ==> gui_mainfcn at 221
feval(gui_State.gui_OpeningFcn, gui_hFigure, [], guidata(gui_hFigure),
varargin{:});
Error in ==> MatlabMedia at 42
gui_mainfcn(gui_State, varargin{:});
I could play the wav files using wavplay, but then i cannot use stop and pause features that audioplayer has...


LinkBack URL
About LinkBacks
