MATLAB: How to use the PLAY function to play a sound wave without using the handle of an AUDIOPLAYER object
MATLAB
The command
play(audioplayer(rand(1,44100),44100));
does not play anything but
playblocking(audioplayer(rand(1,44100),44100));
works fine.
Best Answer
The ability to use the PLAY function with an AUDIOPLAYER object without using the handle to that object is not available in MATLAB.
The proper way to use the PLAY function and AUDIOPLAYER objects is, as stated in the documentation, by using the handle to the AUDIOPLAYER object. For example:
The only known way to stop sound() from playing is to
clear sound
You should be looking at the pause() and resume() audioplayer methods, and you will need to use the audioplayer callbacks to detect end of sound to know to play() the object again in order to loop. There will generally be a delay in playing before the player restarts.
I would suggest that you instead look at the Audio System Toolbox in order to be able to stream audio.
Best Answer