iPhone SDK:AVAudioPlayer 在暂停或完成时发出噪音
我正在使用 AVAudioPlayer 播放多个 wav 文件(我尝试使用 caf 但发生了同样的事情)。所有文件均小于 2 秒,16 位声音 - 文件大小约为 40kb。
我发现它在两种情况下会发出很小的噪音(很难描述,但像“dub”这样的小声音):
1) 当播放暂停或停止时。
2)当一个播放结束而另一个声音正在播放时(当一个播放器完成播放时没有噪音)
噪音并不大,但是当我这样做时,我在我的应用程序中播放了很多,这真的很烦人。在模拟器和 iPhone 中都会发生这种情况。
我在网上非常努力地搜索,但找不到任何类似的问题,我真的很想知道问题是什么。任何想法表示赞赏。谢谢。
I'm playing multiple wav files (I tried using caf but same thing happen) with AVAudioPlayer. All the files are less than 2 sec, and 16 bit sound - file size is ~40kb.
I found it makes small noise (it's hard to describe, but a small sound like 'dub') in two cases:
1) when a play is paused or stopped while playing.
2) when a play finishes while another sound is playing (no noise when a sole player finishes its playing)
The noise is not loud, but when I do this play a lot in my app and it really annoys. It happens both in simulator and iphone.
I searched web really hard but couldn't find any similar issues, and I really wonder what the problems are. Any ideas are appreciated. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
只是在这里猜测,但您是否尝试过在暂停或停止之前将音量设置为 0.0?
Just guessing here but have your tried setting volume to 0.0 before pausing or stopping?
我正在发布我自己的问题。
我并没有真正找到答案,但一些观察可能有用。
1) 似乎通过 NSData 而不是 NSURL 加载声音文件在稍后播放时工作得更快。
2)CAF似乎比wav好一点,但也好不了多少。
我还没有对此进行彻底的实验。
如果有人有更清晰的想法,请告诉我。谢谢。
I'm posting to my own question.
I don't really find the answer, but some observations might be useful.
1) It seems loading the sound file through NSData rather than NSURL works faster later in playing.
2) CAF seems a little better than wav, but not much.
I didn't have thorough experiment on this yet.
If anyone has clearer idea, let me know. Thanks.
如果它是在模拟器中进行的,那么我几乎可以绝对肯定地说它仅在模拟器上进行。我也遇到过这样的错误。通常在播放声音后,它会发出“咻咻”的声音(这是我能描述的最好的了)。在设备上尝试一下,看看是否可以。
if it's doing it in the simulator then I can say with almost absolute certainty that it's only on the simulator. I've had bugs with that too. normally after playing a sound it'll go shoo shooo shoo (that's the best I can describe it). Try it on the device and see if it does it there.