简体   繁体   English

使用 AVAudioPlayer 同时播放多个声音

[英]Playing multiple sounds simultaneously with AVAudioPlayer

Could someone help me with a function that fires multiple AVAudioPlayer s at the same time?有人可以帮助我使用同时触发多个AVAudioPlayer的 function 吗? Right now I am trying to get a total of twelve AVAudioPlayer s to fire at once if twelve buttons are activated, but there is a delay and it sounds like someone is running their finger down a piano instead of hitting all the keys at once.现在,如果激活了 12 个按钮,我正在尝试让总共 12 个AVAudioPlayer立即触发,但是有一个延迟,听起来有人正在用手指在钢琴上弹奏,而不是一次敲击所有琴键。

I've looked at Audio Queue Services and can't understand how to actually implement that into code, but it says it can play synchronized sounds.我查看了音频队列服务,无法理解如何将其实际实现到代码中,但它说它可以播放同步声音。 I'm not sure sure how to set all of it up.我不确定如何设置所有这些。 I'm trying to remake a Tone Grid app.我正在尝试重新制作 Tone Grid 应用程序。

Why don't you use http://www.hollance.com/2011/02/soundbankplayer-using-openal-to-play-musical-instruments-in-your-ios-app/你为什么不使用http://www.hollance.com/2011/02/soundbankplayer-using-openal-to-play-musical-instruments-in-your-ios-app/

There you have a polyphonic player, beautifully coded and ready to rock!那里有一个复调播放器,编码精美,准备好摇滚!

I used it in my first app a while back: http://itunes.apple.com/gb/app/chordwheel-pro/id406836326?mt=8我不久前在我的第一个应用程序中使用了它: http://itunes.apple.com/gb/app/chordwheel-pro/id406836326?mt=8

Are you calling the method prepareToPlay on all 12 AVAudioPlayer instances.您是否在所有 12 个AVAudioPlayer实例上调用方法prepareToPlay From the docs: "Calling this method, preloads the buffers and acquires hardware, to minimize delay."来自文档:“调用此方法,预加载缓冲区并获取硬件,以最大限度地减少延迟。”

See the AVAudioPlayer class reference.请参阅AVAudioPlayer class 参考。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM