I need to process a stereo audio file on iOS as follows:
- Both channels should have equal intensity, ie. make the stereo appear as mono
- Route the mono audio to both left and right channels
- Apply effects to the audio which is output to the right channel
What I currently have is:
+-------------------+ | AVAudioPlayerNode +------------------------+ +--------^----------+ | | | +--------+---------+ +--------v---------+ File ---> AVAudioPCMBuffer | | AVAudioMixerNode +---> Output +--------+---------+ +--------^---------+ | | +--------v----------+ +-------------------+ | | AVAudioPlayerNode +--> AVAudioUnitEffect +-+ +-------------------+ +-------------------+ The effect is a subclass of AVAudioUnitEffect.
I'm having trouble making the stereo input appear as mono and outputting AVAudioPlayerNode to separate channels.
I tried to set the PlayerNodes' volume to 0.5 and pan to -1.0 and 1.0, but, as the input is stereo, this doesn't yield desired effects.
With AVFoundation, I figure I have at least two options: either I…
(1) equalize the channels for PlayerNodes so both PlayerNodes appear as mono — after which I could use the same logic as before: having equal volume on both PlayerNodes, other panning left and other right and applying the effect on one PlayerNode would, after MixerNode, result the effect appear only in right output channel.
(2) Keep the PlayerNodes as stereo (pan = 0.0), apply the effect only on one PlayerNode and then tell the MixerNode to use one PlayerNode's both channels as a source for the left channel and the other's channels for the right channel. I suppose then the MixerNode would effectively equalize the input channels so it would appear as the input is mono and effect can be heard only from one output channel.
The question is: is either of the aforementioned strategies possible and how? Is there another option that I've overlooked?
I'm using Swift for the project, but can cope with Objective-C.
Judging by the lack of responses and my own research, it seems to me AVFoundation might not be the way to go. The simplicity using AVFoundation is tempting, but I'm open to alternatives. Currently I'm researching MTAudioProcessingTap-classes and they might be of use. Help is still appreciated.
0 comments:
Post a Comment