如何在MATLAB中停止声音? [英] How to stop sound in MATLAB?

查看:826
本文介绍了如何在MATLAB中停止声音?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用以下方式播放声音时:

When playing a sound using e.g:

sound(x,fs);

有时我会不小心打错了.如果x的长度很大,我目前尝试等待直到声音结束为止.关于如何中止"播放的任何建议?我已经尝试过了

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

但这没用.顺便说一下,我正在使用Windows.

But that didn't work. I'm using Windows by the way.

更新:
kigurai提出的以下解决方案似乎可以解决问题:

UPDATE:
The following solution proposed by kigurai seems to do the trick:

sound(x,fs); % Start the audio

现在通过消灭音频

clear playsnd

推荐答案

从不使用"sound()",但是当我使用wavplay(...,...,'async')播放音频时,我可以停止声音通过发行

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

clear playsnd

也许也可以与sound()一起使用? 注意:这是异步播放时.对于同步播放,我认为CTRL-C应该可以打破它,但是上次尝试使用wavplay()时遇到问题.

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.

这篇关于如何在MATLAB中停止声音?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆