简体   繁体   English

性能方面,我是否应该使用 AVAudioEngine 来获得多种音效?

[英]performance wise, should I use AVAudioEngine for multiple sound effects yes or no?

Performance-wise, is it better to use an AVAudioPlayerNode instance with性能方面,将AVAudioPlayerNode实例与

A. one AVAudioEngine instance, to which I connect multiple sound effects to its mixer A. 一个AVAudioEngine实例,我将多个音效连接到它的混音器

B. a separate instance of AVAudioEngine for each sound effect? B. 每个音效都有一个单独的AVAudioEngine实例?

The reason I'm using AVAudioEngine is because I'm doing some audio processing with AVAudioUnitVaryspeed, but each sound effect can be (and is) independent, so I was wondering if anyone knows what's best?我使用 AVAudioEngine 的原因是因为我正在使用 AVAudioUnitVaryspeed 进行一些音频处理,但是每个音效都可以(并且是)独立的,所以我想知道是否有人知道什么是最好的?

Is it OK to have an AVAudioEngine and its nodes for each effect or should I manage a single engine instance and connect / disconnect nodes as sounds play?每个效果都有一个 AVAudioEngine 及其节点是否可以,或者我应该管理单个引擎实例并在声音播放时连接/断开节点?

You should manage a single AVAudioEngine instance to which all your effects and player are connected, and connect/disconnect nodes as sounds play.您应该管理所有效果和播放器都连接到的单个AVAudioEngine实例,并在声音播放时连接/断开节点。

Having multiple AVAudioEngine instances isn't a problem because of the performance overhead, but because it'll become too complicated to manage them all in real time, having them all respond to AVAudioSession.routeChangeNotification and AVAudioSession.interruptionNotification , keeping all the players in sync, testing each one of them using renderOffline , and so on.由于性能开销,拥有多个AVAudioEngine实例不是问题,但因为实时管理它们会变得太复杂,让它们都响应AVAudioSession.routeChangeNotificationAVAudioSession.interruptionNotification ,让所有玩家保持同步,使用renderOffline测试它们中的每一个,等等。

I recommend you watch WWDC 2014 Session 502 - AVAudioEngine in Practice, for a good introduction to this API.我建议您观看 WWDC 2014 Session 502 - AVAudioEngine in Practice,以获得对 API 的良好介绍。 One of the use cases they bring up is very similar to yours – and they use just one AVAudioEngine instance:-)他们提出的一个用例与您的非常相似——他们只使用一个AVAudioEngine实例:-)

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

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