Reputation: 3119
I build a music player app using AVplayer. The app access and play songs from iPod library. This is how I play mediaItem using AVPlayer
MPMediaItem *mediaItem = ...
NSURL *assetUrl = [mediaItem valueForProperty:MPMediaItemPropertyAssetURL];
AVPlayerItem *playerItem = [AVPlayerItem playerItemWithURL:assetUrl];
self.player = [AVPlayer playerWithPlayerItem:playerItem];
I need to add graphical equaliser to my app to allow users to change the following values
It seems audio processing in iOS is different from other frameworks. I did an R&D and found
My questions are, Is it possible to create custom equaliser with AVPlayer? What technology should I use for my requirement (creating a custom equaliser with AVPlayer)?
P.S. Can any one give a simple working example which I can add to the project and check the changes in the song (I tried the apple documentations, but it is not clear)
Update
btw I built my own eq & processing lib https://github.com/clementprem/CPAudioPlayer
Upvotes: 4
Views: 2306
Reputation: 31
This can be done by NOVOCAINE.
Take the code to instantiate a NVPeakingEQFilter:
NVPeakingEQFilter* PEQ = [[NVPeakingEQFilter alloc] initWithSamplingRate:self.samplingRate];
PEQ.Q = QFactor;
PEQ.G = gain;
PEQ.centerFrequency = centerFrequencies;
you need define 3 parameters: Q, G, and centerFrequency. Both Q and centerFrequency are usually fixed (QFactor in my case is a constant equal to 2.0).
So, you have 10 sliders: each one corresponds to a fixed centerFrequency. I suggested iTunes values: 32Hz, 64Hz, 125Hz, 250Hz, 500Hz, 1KHz, 2KHz, 4KHz, 8KHz, 16KHz. You do not want to change those values when the slider value changes.
What you want to change when the slider value changes is the gain (G). At init time, G can be set to 0.0. This means "no amplification/attenuation".
When the slider moves, you change G, so actually you would do:
PEQ[sender.tag - 1].G = sender.value * kNominalGainRange;
where kNominalGainRange is 12.0, so if sender.value goes from -1.0 to +1.0, G goes from -12 to +12.
Hope this helps.
Upvotes: 0
Reputation: 69027
AVPlayer
will be of no use to you, since it only provides a high level interface.
I implemented an audio equaliser some time ago and my suggestion is going with Novocaine, which uses NVDSP and Audio Unit (and makes it simpler, actually). Novocaine even includes an Equalizer
class, so you just need integrating it into your app (if you do not do streaming, that is really straightforward).
Upvotes: 2