Link to home
Start Free TrialLog in
Avatar of Member_2_2394978
Member_2_2394978Flag for United Kingdom of Great Britain and Northern Ireland

asked on

audioplayer Play more than one sound at a time

Hi all,

I have a MATLAB programme which works perfectly fine and plays a sound with attached code. However, I would like to be able to run this programme three times, in three different MATLAB instances. It then seems they are fighting for control of the sound system as two of them display errors "Unable to open the audio device for playback: javax.sound.sampled.LineUnavailableException: Audio Device Unavailable", while the other one plays its sound. I should note that each programme has a loop and plays a sound within the loop with some sleeping to allow for the sound to finish playing.

I get this error even with one programme running if some other programmes are using the sound system: I find and kill them with "lsof | grep snd" and "kill" respectively.

So, my question is whether its possible to play more than one sound at a time. If one programme is needed to play the sounds I could pipe the details from the three to this one, and then play ...

Cheers,
James
player = audioplayer(sound, f);
play(player);

Open in new window

Avatar of yuk99
yuk99
Flag of United States of America image

What is OS? What is your Matlab version?

Looks like an internal implementation of audioplayer, that it wants the complete control of audio system.

Not sure if it will help, but you can try to use Java version of audioplayer JavaAudioPlayer.

load handel;
p = com.mathworks.toolbox.audio.JavaAudioPlayer(y, Fs, 16);
p.play;
p.stop;

Open in new window

Avatar of Member_2_2394978

ASKER

Thanks for a quick reply.

'Undefined variable "com" or class "com.mathworks.toolbox.audio.JavaAutioPlayer.'

OS, Ubuntu hardy, matlab 7.8.0
ASKER CERTIFIED SOLUTION
Avatar of yuk99
yuk99
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial