如何在音频播放器中实现iPhone的均衡器设置
如何以编程方式为我的 iPhone 应用程序设置低音或其他类型的均衡器? 有现成的框架或方法可用吗?麻烦给个参考..
How can i set the bass, or other kind of Equalizer programatically for my iphone app?
Are there ready frameworks or methods available?? Kindly please provide a reference..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您将音频播放构建为 AudioUnit 图表,您应该能够使用内置的 iPod EQ AudioUnit,以及与 iPod 应用程序中类似的预设。看看这个示例,希望能有所帮助你知道如何做到这一点。
当您阅读代码时,请确保您了解音频单元是图形中的节点,其中音频信号通过回调方式流过图形,并且每个节点都可以修改流向输出节点的信号(因此,您要做的就是将文件加载到内存中,然后在您指定的回调中将 PCM(声音样本)数据提供给音频单元。当缓冲区为空时,将调用回调,您可以填充它。
链接的示例设置了混音器节点、输出节点和均衡器节点,将它们连接在一起,并在将它们加载到内存后开始播放多个声音文件。
如果 iPod EQ AU 没有实现您想要的功能,您可以构建自己的 AudioUnit 并稍后替换它,但这需要一些 DSP 知识。您也许还可以找到一些作为音频单元实现的开源均衡器(这是 Mac 平台上用于音乐制作工具中使用的效果的常见格式。)
If you build your audio playback as an AudioUnit graph, you should be able to use the built-in iPod EQ AudioUnit, with presets like those in the iPod application. Have a look at this example which will hopefully help you understand how to do this.
As you're reading the code, make sure you understand that Audio Units are nodes in a graph, where the audio signal flows through the graph by means of callbacks, and that each node can modify the signal on it's way towards the output node (essentially the speaker.) So what you do is you load your file into memory, and you then feed the PCM (sound sample) data to the audio unit in a callback that you have specified. When the buffer is empty, the callback will be invoked and you can fill it up.
The linked example sets up a mixer node, an output node and the equalizer node, connects them together, and starts playing a number of sound files after having loaded them into memory.
If the iPod EQ AU doesn't do what you want it to do, you can build your own AudioUnit and replace it later, but that requires some DSP knowledge. You may also be able to find some open-source equalizers out there that have been implemented as Audio Units (which is a common format on the Mac platform for effects used in music production tools for example.)
如果您使用音频队列或 RemoteIO 音频单元来处理音频,则可以编写并使用自己的 DSP 滤波器来处理和均衡音频样本数组或缓冲区。级联或并行的 IIR 滤波器组是一种可能性。 FFT 重叠添加/保存滤波是另一种可能的 DSP 技术,它允许自定义均衡曲线。
If you are using audio queues or remoteIO audio units for audio, you can write and use your own DSP filters to process and equalize your audio sample arrays or buffers. Cascaded or parallel banks of IIR filters are one possibility. FFT overlap add/save filtering is another possible DSP technique that will allow a custom equalization curve.
不,您无法在 AVAudio Player 中获得直接设置/均衡器设置。
它是Apple提供的框架,因此您所能访问的只是您在类参考中获得的所有内容。
所以我想浏览一下类参考,但没有任何地方说您可以访问均衡器设置。
这是它的链接。
http://developer.apple.com/ Library/ios/#documentation/AVFoundation/Reference/AVAudioPlayerClassReference/Reference/Reference.html
希望这会有所帮助。
EDIT-1:
如果您想使用其他一些库,它可以让您广泛访问设置,甚至可以提供连 DJ 都会满意的声音效果,那么您可以使用
BASS 音频库
这是一个付费库,但如果您确实想要良好且有效的音效并访问所有设置,那么它值得购买。
No there is no way you can get a direct settings/Equalizer Settings in AVAudio Player.
It is an framework provided by Apple, so all you can access is all you get in class reference.
So I would like to go through Class Reference and there is no point where it says you can access the Equalizer settings.
Here is the link for it.
http://developer.apple.com/library/ios/#documentation/AVFoundation/Reference/AVAudioPlayerClassReference/Reference/Reference.html
Hope this helps.
EDIT-1:
If you are wanting to use some other library which gives you extensive access to settings and which can even give sounds effects that even a DJ would be pleased by then you can use
BASS Audio Library
This is a paid library but it is worth buying if you really want good and effective sound effects and access to all the settings.
不,没有可用的框架。我认为不提供这样的框架的原因是均衡和设置低音、经典等模式并不是所有使用音频服务的应用程序可能需要的通用功能。那些有要求的人需要实施它们。
No there is no framework available for that. I think the reason behind not providing such framework is that equalizing and setting the mode like bass, classic, etc. is not a generic functionality that all application using audio services may need. Those who require that need to implement them.