简体   繁体   English

iPhone SDK音频混音器

[英]iPhone SDK Audio Mixer

What I need to do is be able to mix 4 channels of audio (not from a live source, just prerecorded audio files in the app bundle), and change their volumes individually, in real time, preferably with MP3s. 我需要做的是能够混合4个音频通道(不是来自实时源,而是应用程序捆绑中的预录音频文件),并实时,最好是使用MP3分别更改其音量。 What's the best/correct road for me to take, regarding all the various sound APIs for the iPhone? 对于iPhone的所有各种声音API,对我而言,最佳/正确的道路是什么?

Thanks! 谢谢!

Storm Sim does this with AVAudioPlayer, which is certainly the simplest methdod. Storm Sim使用AVAudioPlayer做到这一点,它当然是最简单的方法。 You can call prepareToPlay on each of the player objects then kick them off with play later so there won't be any delay. 您可以在每个播放器对象上调用prepareToPlay,然后在播放时将其启动,因此不会有任何延迟。 I also use a blank 1-second audio player on eternal loop to keep the deviceTime counting down, so you can use playAfter to give a specific deviceTime in the future to make all the samples play in-sync or offset relative to each other (deviceTime only ticks if there is some sort of audio playing). 我还在永恒循环上使用了一个空白的1秒音频播放器来使deviceTime保持递减计数,因此您可以在以后使用playAfter来指定特定的deviceTime,以使所有采样同步播放或相对于彼此偏移(deviceTime仅在播放某种音频时打勾)。 The AVAudioPlayerDelegate has interrupted/resumed events and finishedPlaying so you can get notification of what is happening. AVAudioPlayerDelegate已中断/恢复事件并完成播放,因此您可以获取正在发生的事件的通知。

However there is only one hardware MP3/AAC decoder, so the other three will use up CPU (and thus battery) doing the decoding. 但是,只有一个硬件MP3 / AAC解码器,因此其他三个将用尽CPU(从而消耗电池)进行解码。 If you want to maximize battery life, use CAF files in IMA4@44100. 如果要最大程度地延长电池寿命,请使用IMA4 @ 44100中的CAF文件。 It is about 1/4 the size of the raw WAV files so it isn't as good as MP3 but the performance is much better, especially if you are using a lot of small audio tracks. 它的大小约为原始WAV文件的1/4,因此虽然不如MP3好,但性能要好得多,尤其是在使用大量小型音频轨道的情况下。 If you are using voice you can get away with much less fidelity and smash the files even more. 如果您使用语音,则保真度会大大降低,甚至会粉碎文件更多。 afconvert in terminal can help you getting your source files in the CAF format (you should use CAF files no matter what the encoding). 在终端中的afconvert可以帮助您以CAF格式获取源文件(无论编码如何,都应使用CAF文件)。

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

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