Error trying to play sound

Hi i wanted to use "play" to play the audioplayer(data,fs). 'GUI1' is a .m and .fig.
[data,fs]=wavread('test');
play(audioplayer(data,fs))
error:
Error using GUI1>play
Too many input arguments.
Error in GUI1>buttonPlay_Callback (line 286)
play(player);
Error in gui_mainfcn (line 96)
feval(varargin{:});
Please help, How can i solve this?

1 comentario

tan
tan el 4 de Jun. de 2014
I saw 1 explanation is that maybe there are hidden function in the matlab that takes some input argument. But i do not know how to find out the hidden function and solve it. Any one knows how?

Iniciar sesión para comentar.

 Respuesta aceptada

Star Strider
Star Strider el 4 de Jun. de 2014

1 voto

Use the soundsc function instead:
soundsc(data,fs)
The play function is for audioplayer objects. You seem to have a ‘.wav’ file instead, so soundsc or sound would likely work best for you here.

4 comentarios

tan
tan el 5 de Jun. de 2014
Thank you for answer. after i tried soundsc it can work. However because i need to use audioplayer.Running and etc, so only play function can be use.
Star Strider
Star Strider el 5 de Jun. de 2014
Easily corrected!
You have to create an audioplayer object from your test.wav file.
[data,fs]=audioread('test.wav'); % Read ‘.wav’ file
testobj = audioplayer(data,fs); % Create audioplayer object
play(testobj) % Play the file
I could not play your ‘test.wav’ file because I do not have it, but I did exactly this with a ‘.wav’ file I have, and verified that it works.
Looking at your code, it seems strange that it did not work as you wrote it, but it seems necessary to break it out into two statements. When I tried my file with your syntax, it did not throw an error but it did not produce any sound. When I ran it as I posted in my comment, it worked.
tan
tan el 5 de Jun. de 2014
Thank you!!
Star Strider
Star Strider el 5 de Jun. de 2014
My pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Preguntada:

tan
el 4 de Jun. de 2014

Comentada:

el 5 de Jun. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by