필터 지우기
필터 지우기

audioplayer() not enough input arguments

조회 수: 4 (최근 30일)
Hank
Hank 2024년 3월 5일
댓글: Cris LaPierre 2024년 3월 5일
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.
  댓글 수: 2
Stephen23
Stephen23 2024년 3월 5일
"However, this invariably results in the not enough inputs error mentioned."
Mentioning an error is not a helpful as showing us the complete error message. This means all of the red text.
Hank
Hank 2024년 3월 5일
Here are the two error messages:
Matlab:
Error using audioplayer
Not enough input arguments.
Error in appbaseAudioWorksHchenCopy/PlayButtonPushed (line 84)
app.sound = audioplayer(audioSound, sampleRate);
Error in matlab.apps.AppBase>@(source,event)executeCallback(ams,app,callback,requiresEventData,event) (line 62)
newCallback = @(source, event)executeCallback(ams, ...
Error while evaluating Button PrivateButtonPushedFcn.
and Appdesigner:
Error using audioplayer
Not enough input arguments.
app.sound = audioplayer(audioSound, sampleRate);

댓글을 달려면 로그인하십시오.

답변 (1개)

Cris LaPierre
Cris LaPierre 2024년 3월 5일
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
Hank
Hank 2024년 3월 5일
I have added the segment
properties (Access = public)
sound % Sound of Sample
fullname %file
end
However, the error persists. I also tried the demo example attached by Subhadeep Koley, but I experienced the same error, giving me this message in matlab:
Error using audioplayer
Not enough input arguments.
Error in appExample/ClicktoplayButtonPushed (line 25)
app.player = audioplayer(app.S.y, app.S.Fs);
Error in matlab.apps.AppBase>@(source,event)executeCallback(ams,app,callback,requiresEventData,event) (line 62)
newCallback = @(source, event)executeCallback(ams, ...
Error while evaluating Button PrivateButtonPushedFcn.
And this one in Appdesigner:
Error using audioplayer
Not enough input arguments.
app.player = audioplayer(app.S.y, app.S.Fs);
Cris LaPierre
Cris LaPierre 2024년 3월 5일
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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Audio and Video Data에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by