Add iPod Equalizer effect using AVPlayer

心不动则不痛 提交于 2019-12-21 04:46:12

问题


We are developing a music app using AVPlayer, which is at the end stage. Everything was on track until we started working on iPod Equalizer applying effects to the currents song. We are able to fetch the built in Equalizers list when we apply the AudioUnitProperty we don't see any effects in songs.

Your valuable response will be helpful to us.


回答1:


You can most certainly accomplish various EQ effects using an AUGraph and AudioUnits in iOS.

Basically, you would insert the effect between the source and the output of your audio. You can use things like a multichannel mixer to have some control, or other, more complex audio units in an AUGraph to obtain much greater control over the Audio. Using AudioUnits, if you needed to, you could even get at each audio sample in the buffer. This would require you to re-code some of your audio processing, but it would certainly allow you to apply the EQ effects.

You could use the iPod Effects Unit, which is exactly the same unit as iOS uses to apply those effects when it plays music. This will should give you the closest match for effect sounds, since it is exactly the same AudioUnit.

From Apple:

iPod EQ Audio Unit Description (scroll down the page)

Type Definition for Audio Unit Subtype

The iPod EQ unit provides a set of predefined tonal equalization curves as factory presets. Obtain the array of available EQ settings by accessing the audio unit’s kAudioUnitProperty_FactoryPresets property. You can then apply a setting by using it as the value for the kAudioUnitProperty_PresentPreset property.

You would insert this unit between your audio source (be it a file, microphone input, etc.) and your audio output (speakers, headphones, etc.). You can then apply any of the iPod EQ effects to your audio.

Here's the attributes to use when specifying the iPod EQ Unit:

kAudioUnitType_Effect

kAudioUnitSubType_AUiPodEQ

kAudioUnitManufacturer_Apple

Also, be sure to check out the Audio Unit Hosting Guide from Apple. This page contains links to much of the other relevant documentation that you will want to reference.




回答2:


Use MTAudioProcessingTap + AUGraph + AudioUnit can do that, the official demo AudioTapProcessor show you how to use MTAudioProcessingTap to handle audio data and then combine with AVPlayer on it's process callback, replace it's AudioUnit by using AUGraph +AudioUnit



来源:https://stackoverflow.com/questions/16889857/add-ipod-equalizer-effect-using-avplayer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!