How to stop sound in MATLAB?

matlab

Solution

Never used "sound()" but when I have played audio using wavplay(..., ..., 'async') I can stop the sound by issuing

clear playsnd

Maybe that works with sound() as well? Note: This is when playing asynchronously. For synchronous playback I assume that CTRL-C should break it, but I had issues with wavplay() last time I tried that.

Problem

When playing a sound using e.g: ``` sound(x,fs); ``` I sometimes by accident play the wrong one. If x is of substantial length, I currently try to wait until the sound has completed. Any suggestions on how to "abort" the playback? I've already tried ``` sound(mute,fs); % Mute is a short vector containing all zeroes ``` But that didn't work. I'm using Windows by the way. UPDATE: The following solution proposed by kigurai seems to do the trick: ``` sound(x,fs); % Start the audio ``` Now kill audio by ``` clear playsnd ```

Original source