2
votes

Apple's 3D Mixer Audio Unit guide states:

To use a stereo source, you may treat its left and right channels as two independent single-channel sources, and then feed each side of the stereo stream to its own input bus.

https://developer.apple.com/library/ios/qa/qa1695/_index.html

However, I can not figure out how to send each channel of my stereo Audio Unit into the 3D Mixer. How does one do this?

1
Did you manage to solve this problem?Harman

1 Answers

0
votes

bascially, you'll need to do something like

@interface AudioEngine () {
    AVAudioEngine                       *_engine;
    AVAudioEnvironmentNode              *_environment;
    AVAudioPCMBuffer                    *_ouputBuffer;
    NSMutableArray <AVAudioPlayerNode*> *_PlayerArray;
    AVAudioPlayerNode                   *_soundPlayer;
    AVAudioPCMBuffer                    *_soundBuffer;
    bool                                _multichannelOutputEnabled

;

load a file and grab it from the buffer. to split the stereo into multichannel, you need something like

outputLayoutTag = kAudioChannelLayoutTag_AudioUnit_2;
_multichannelOutputEnabled = true;

this '_multichannelOutputEnabled = true;' is usually set to false

then setup the algorithm to do something with your channels

AVAudio3DMixingRenderingAlgorithm renderingTHIS = _multichannelOutputEnabled ? 
AVAudio3DMixingRenderingAlgorithmSoundField : AVAudio3DMixingRenderingAlgorithmEqualPowerPanning;
        newPlayer.renderingAlgorithm = renderingTHIS;

somewhere in a view controller your might have something like this tied to an object in a game

[self.epicAudioEngine.updateListenerOrientation:AVAudioMake3DAngularOrientation([ang.x,ang.y,ang.z])

[self updateEulerAnglesAndListenerFromDeltaX:dX DeltaY:dY]

look through ffmpeg source code for libavformat,libavutil to get an idea of how to process audio