MATLAB: How do you play multiple sound files simultaneously

audiosimultaneoussoundwavplay

Hi, Are you able to play multiple sound clips in matlab simultaneously? I have tried using the sound(…) function and wavplay(…) function by calling them one after another in the following manner:
wavplay(soundClip1,Fs) wavplay(soundClip2,Fs) wavplay(soundClip3,Fs)
but this only plays the files in succession, not at the same time. The work-around I have been using is to sum the data in each array into one:
mergedClip = soundClip1+soundClip2+soundClip3; wavplay(mergedClip,Fs)
Does anyone know if there is a way to call a matlab audio function so the separate files play together?
Thanks, Matt

Best Answer

There is no method provided in MATLAB to play multiple sounds simultaneously. There is no method provided in MATLAB to synchronize multiple audio or video events. Or even to synchronize an audio or video event against some trigger or timer. Or to determine a maximum latency for an audio or video event.
The closest that is available is to use a very recent version of a 64 bit MATLAB, a National Instruments (NI) Digital to Analog converter, the new session-based interface, multiple channels synchronized together, and queue the audio, with the analog output feeding in to some kind of analog mixer. (Possibly it could also be done with the legacy interface and non-NI devices; it should work in principle but I have not yet located specific assurances that the channels would be synchronized.)
Other than that... averaging the signals is the method. Not just adding them together, as that would usually saturate the output. mean() is suitable for the task.