简体   繁体   English

使用AudioUnits播放和播放音乐库中的歌曲

[英]Using AudioUnits to play and eq songs from music library

I'm building an app that involves playing songs from the user's music library while applying an equalization (EQ) effect. 我正在构建一个应用程序,其中涉及在应用均衡(EQ)效果的同时播放用户音乐库中的歌曲。 I've only used AudioUnits to generate sound before, so I'm having a bit of trouble. 我以前只使用AudioUnits来产生声音,所以有点麻烦。

My current plan is to use AVAssetReader to get the samples, and though I'm a bit fuzzy on that, my question here is with regards to the correct AudioUnit design pattern to use from Apple's documentation: https://developer.apple.com/library/ios/documentation/MusicAudio/Conceptual/AudioUnitHostingGuide_iOS/ConstructingAudioUnitApps/ConstructingAudioUnitApps.html#//apple_ref/doc/uid/TP40009492-CH16-SW1 . 我目前的计划是使用AVAssetReader来获取样本,尽管对此有些模糊,但我的问题是要从Apple文档中使用正确的AudioUnit设计模式: https : //developer.apple.com /library/ios/documentation/MusicAudio/Conceptual/AudioUnitHostingGuide_iOS/ConstructingAudioUnitApps/ConstructingAudioUnitApps.html#//apple_ref/doc/uid/TP40009492-CH16-SW1

My guess is that a render callback is needed to perform my EQ effect (I was thinking kAudioUnitSubType_ParametricEQ ), so that leaves either the "I/O with a Render Callback Function" pattern or the "Output-Only with a Render Callback Function." 我的猜测是执行我的EQ效果需要渲染回调(我在想kAudioUnitSubType_ParametricEQ ),这样就留下了“带有渲染回调函数的I / O”模式或“带有渲染回调函数的仅输出”模式。 If I'm reading data from the music library (potentially via AVAssetReader ), which of these two patterns would be the best fit? 如果我正在从音乐库中读取数据(可能是通过AVAssetReader ),那么这两种模式中哪一种最合适?

I think you would need to use an Output-Only with a Render Callback Function. 我认为您将需要使用仅输出和渲染回调函数。 The callback function should be responsible for reading/decoding the audio data, and applying the EQ effect. 回调函数应负责读取/解码音频数据,并应用EQ效果。

By the way, I don't know if this might be useful in any way, but here it says that there's an already existing EQ audio unit that you could use. 顺便说一句,我不知道这是否有任何用处,但在这里它说已经存在一个可以使用的EQ音频单元。

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

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