简体   繁体   English

IOS:如何在 Swift 中增加 AVAudioPlayer 的低音和高音?

[英]IOS: How to increase the Bass and Treble of a AVAudioPlayer in Swift?

  1. Anyone knows how to increase the bass and treble of a track ?有人知道如何增加曲目的低音和高音吗?

  2. Within the same track, if I do a split into 3 sections, can I adjust & have say 3 different level of reverb, ie one in each section ?在同一条轨道上,如果我分成 3 个部分,我可以调整并说 3 个不同级别的混响,即每个部分一个?

Thanks谢谢

I don't think it is possible to use EQ effects with an AVAudioPlayer .我认为不可能在AVAudioPlayer使用 EQ 效果。

A quick search gave me answers like this from StackOverflow:快速搜索从 StackOverflow 给了我这样的答案:

can I use AVAudioPlayer to make an equalizer player? 我可以使用 AVAudioPlayer 制作均衡器播放器吗?

Or this sadly unanswered question from Apple Developer Forums:或者来自 Apple Developer Forums 的这个令人遗憾的未回答问题:

https://forums.developer.apple.com/thread/46998 https://forums.developer.apple.com/thread/46998

Instead反而

What you can do instead is use the AVAudioEngine ( https://developer.apple.com/reference/avfoundation/avaudioengine ) which gives you the opportunity to add an EQ node (or other effect nodes) to your AVAudioPlayer node.您可以做的是使用AVAudioEngine ( https://developer.apple.com/reference/avfoundation/avaudioengine ),它使您有机会将EQ 节点(或其他效果节点)添加到AVAudioPlayer节点。

AVAudioEngine may seem daunting at first, but think of it as a mixer. AVAudioEngine可能令人生畏,但可以将其视为混音器。 You have some input nodes that generate sound ( AVAudioPlayer nodes for instance), and you can then attach and connect those notes to your AVAudioEngine .您有一些生成声音的输入节点(例如AVAudioPlayer节点),然后您可以将这些音符附加并连接到您的AVAudioEngine The AVAudioEngine has a AVAudioMixerNode so you can control things like volume and so forth. AVAudioEngine有一个AVAudioMixerNode,因此您可以控制音量等。

Between your input nodes and your mixer you can attach effect nodes, like an EQ node for instance and you can add a "tap" and record the final output to a file if so desired.在输入节点和混音器之间,您可以附加效果节点,例如 EQ 节点,如果需要,您可以添加“tap”并将最终输出记录到文件中。

Reading material阅读材料

This slideshare introduction helped me a great deal understanding what AVAudioEngine is (the code is Objective C though, but it should be understandable) 这个幻灯片介绍帮助我很好地理解了AVAudioEngine是什么(虽然代码是 Objective C,但它应该是可以理解的)

The AVAudioEngine in Practice from WWDC 2014 is a great introduction too.来自 WWDC 2014 的AVAudioEngine in Practice也是一个很好的介绍。

So, I hope you are not frightened by the above, as said, it may seem daunting when you see it at first, but once you get it wired together it works fine and you have the option to add other effects than just EQ (pitch shifting, slowing down a file and so on).所以,我希望你不要被上面的内容吓到,如上所述,当你第一次看到它时可能会让人望而生畏,但是一旦你把它连接在一起,它就可以正常工作,你可以选择添加其他效果,而不仅仅是 EQ(音高)移动,减慢文件等)。

Hope that helps you.希望能帮到你。

unfortunately, it doesn't allow you to stream remote URLs.不幸的是,它不允许您流式传输远程 URL。 The only way around that is to download a track, convert it from mp4 or m4a to LPCM format using audio services API and then schedule a buffer to run through the audio engine.解决此问题的唯一方法是下载曲目,使用音频服务 API 将其从 mp4 或 m4a 转换为 LPCM 格式,然后安排一个缓冲区以通过音频引擎运行。 AVPlayer, on the other hand, allows you to stream remote media but it's extremely hard to attach and eq to it ... you may be able to look into MpAudioProcessingTap but that only works with local files as well.另一方面,AVPlayer 允许您流式传输远程媒体,但很难附加和均衡到它……您可以查看 MpAudioProcessingTap,但它也仅适用于本地文件。

There is a good write up to do this through AVAudioEngine here有一篇很好的文章可以通过 AVAudioEngine here来做到这一点

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

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