audioplayer() not enough input arguments
Show older comments
I am having an issue with using the audioplayer() function, where it always returns me with the error not enough input arguments. Here is what I believe to be the relevant code snippets:
% Button pushed function: UploadButton
function UploadButtonPushed(app, event)
[filename,filepath] =uigetfile({'*.wav'}, 'Select File to Open');
app.fullname = [filepath, filename];
This is for uploading a .wav file into the program.
I then attempt to access this file later in the program to play it:
% Button pushed function: PlayButton
function PlayButtonPushed(app, event)
[audioSound, sampleRate] = audioread(app.fullname);
app.sound = audioplayer(audioSound, sampleRate);
play(app.sound);
However, this invariably results in the not enough inputs error mentioned.
I have checked the variables, and audioSound is an array of doubles and sampleRate is a double, so I am not sure what I am doing wrong.
Answers (1)
Cris LaPierre
on 5 Mar 2024
0 votes
See this Answer for a potential fix, which is that app.sound might need to be declared as a public property of the app.
2 Comments
Hank
on 5 Mar 2024
Cris LaPierre
on 5 Mar 2024
Your original code works for me in R2023b on a Win11 machine. Perhaps the issue is with the wav file you are uploading. Try creating one of your own.
load handel.mat
audiowrite("handel.wav",y,Fs)
clear y Fs
Categories
Find more on Audio and Video Data in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!