• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: 3D Mixer on iPhone
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 3D Mixer on iPhone


  • Subject: Re: 3D Mixer on iPhone
  • From: Aran Mulholland <email@hidden>
  • Date: Fri, 1 Oct 2010 09:25:38 +1000

>From the doco: (http://developer.apple.com/library/ios/#documentation/MusicAudio/Conceptual/CoreAudioOverview/CoreAudioEssentials/CoreAudioEssentials.html)

3D mixer unit—Allows any number of mono inputs, each of which can be
8-bit or 16-bit linear PCM. Provides one stereo output in 8.24-bit
fixed-point PCM. The 3D mixer unit performs sample rate conversion on
its inputs and provides a great deal of control over each input
channel. This control includes volume, muting, panning, distance
attenuation, and rate control for these changes. Programmatically,
this is the kAudioUnitSubType_AU3DMixerEmbedded

- only mono inputs...I reckon thats where your dramas lie :)

Cheers

Aran.

On Fri, Oct 1, 2010 at 2:49 AM, Paul Slocum <email@hidden> wrote:
> The following code works fine, but if I switch in the commented-out
> line to use the 3DMixer instead of the Multichannel mixer, I get only
> noise on the output when I hit my "play" button.  I suspect that it is
> a format mismatch, but as I am setting all the audio formats
> explicitly, I'm not sure what's going on.  Thanks in advance for any
> help...
>
> // CALLBACK
> static OSStatus masterFaderCallback(void *inRefCon,
>                                                            AudioUnitRenderActionFlags *ioActionFlags,
>                                                                const AudioTimeStamp *inTimeStamp,
>                                                                UInt32 inBusNumber,
>                                                                UInt32 inNumberFrames,
>                                                                AudioBufferList *ioData) {
>
>        //get self
>        DJMixer *djMixer = (DJMixer *)inRefCon;
>
>        static UInt32 frameCounter;
>
>        //loop through all the buffers that need to be filled
>        for (int i = 0 ; i < ioData->mNumberBuffers; i++)
>        {
>                SInt32 *frameBuffer = ioData->mBuffers[0].mData;
>
>                for (int j = 0; j < inNumberFrames; j++)
>                        frameBuffer[j] = [djMixer.loopOne getNextPacket];
>        }// for each buffer
>        return 0;
> }
>
> // AUDIO SETUP
>        //=======================================
>
>        AudioComponentDescription mixerDescription,outputDescription;
>        AUNode mixerNode,outputNode;
>
>        OSErr err = noErr;
>        err = NewAUGraph(&graph);
>        NSAssert(err == noErr, @"Error creating graph.");
>        mixerDescription.componentFlags = 0;
>        mixerDescription.componentFlagsMask = 0;
>        mixerDescription.componentType = kAudioUnitType_Mixer;
>        //mixerDescription.componentSubType = kAudioUnitSubType_MultiChannelMixer;
>        mixerDescription.componentSubType = kAudioUnitSubType_AU3DMixerEmbedded;
>        mixerDescription.componentManufacturer = kAudioUnitManufacturer_Apple;
>        err = AUGraphAddNode(graph, &mixerDescription, &mixerNode);
>        NSAssert(err == noErr, @"Error creating mixer node.");
>        outputDescription.componentFlags = 0;
>        outputDescription.componentFlagsMask = 0;
>        outputDescription.componentType = kAudioUnitType_Output;
>        outputDescription.componentSubType = kAudioUnitSubType_RemoteIO;
>        outputDescription.componentManufacturer = kAudioUnitManufacturer_Apple;
>        err = AUGraphAddNode(graph, &outputDescription, &outputNode);
>        NSAssert(err == noErr, @"Error creating output node.");
>        err = AUGraphOpen(graph);
>        NSAssert(err == noErr, @"Error opening graph.");
>        err = AUGraphConnectNodeInput(graph, mixerNode, 0, outputNode, 0);
>        NSAssert(err == noErr, @"Error connecting mixer to output.");
>
>        //wire up the callback (for >1 Callbacks, increment the bus number)
>        AURenderCallbackStruct callback;
>        callback.inputProc = masterFaderCallback;
>        callback.inputProcRefCon = self;
>        err = AUGraphSetNodeInputCallback(graph, mixerNode, 0, &callback);
>        NSAssert(err == noErr, @"Error setting render callback.");
>
>        //|||||||||||||||||||||||||||||||||||||||||||||||||||||
>        err = AUGraphNodeInfo(graph, mixerNode, &mixerDescription, &masterFaderMixer);
>        //get the output
>        err = AUGraphNodeInfo(graph, outputNode, &outputDescription, &output);
>
>        //---------------------------------------------------
>
>        // Describe format
>        audioFormat.mSampleRate                 = 44100.00;
>        audioFormat.mFormatID                   = kAudioFormatLinearPCM;
>        audioFormat.mFormatFlags                = kAudioFormatFlagIsSignedInteger |
> kAudioFormatFlagIsPacked ;
>        audioFormat.mFramesPerPacket    = 1;
>        audioFormat.mChannelsPerFrame   = 2;
>        audioFormat.mBitsPerChannel             = 16;
>        audioFormat.mBytesPerPacket             = 4;
>        audioFormat.mBytesPerFrame              = 4;
>
>        //---------------------------------------------------
>        // OUTPUT
>        err = AudioUnitSetProperty(output, kAudioUnitProperty_StreamFormat,
> kAudioUnitScope_Input, 0, &audioFormat, sizeof(audioFormat));
>        NSAssert(err == noErr, @"Error setting RIO input property.");
>
>        //---------------------------------------------------
>        // MASTER FADER (3DMixer)
>        err = AudioUnitSetProperty(masterFaderMixer,
> kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, 0,
> &audioFormat, sizeof(audioFormat));
>        NSAssert(err == noErr, @"Error setting Master fader property.");
>        err = AudioUnitSetProperty(masterFaderMixer,
> kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0,
> &audioFormat, sizeof(audioFormat));
>        NSAssert(err == noErr, @"Error setting Master fader property.");
>
>        //---------------------------------------------------
>
>        err = AUGraphInitialize(graph);
>        NSAssert(err == noErr, @"Error initializing graph.");
>        err = AUGraphStart(graph);
>        NSAssert(err == noErr, @"Error starting graph.");
>        CAShow(graph);
>
>        //=======================================
>
> // AUDIO STATUS W MULTICHANNEL MIXER
>
> AudioUnitGraph 0xE1D002:
>  Member Nodes:
>        node 1: 'aumx' 'mcmx' 'appl', instance 0x5f16250 O I
>        node 2: 'auou' 'rioc' 'appl', instance 0x6917570 O I
>  Connections:
>        node   1 bus   0 => node   2 bus   0  [ 2 ch,  44100 Hz, 'lpcm'
> (0x0000000C) 16-bit little-endian signed integer]
>  Input Callbacks:
>        {0x2a79, 0x690ec00} => node   1 bus   0  [2 ch, 44100 Hz]
>  CurrentState:
>        mLastUpdateError=0, eventsToProcess=F, isRunning=T (1)
>
> // AUDIO STATUS W 3D MIXER
>
> AudioUnitGraph 0xE48002:
>  Member Nodes:
>        node 1: 'aumx' '3dem' 'appl', instance 0x6a0be10 O I
>        node 2: 'auou' 'rioc' 'appl', instance 0x6a233a0 O I
>  Connections:
>        node   1 bus   0 => node   2 bus   0  [ 2 ch,  44100 Hz, 'lpcm'
> (0x0000000C) 16-bit little-endian signed integer]
>  Input Callbacks:
>        {0x2a79, 0x5f1b230} => node   1 bus   0  [2 ch, 44100 Hz]
>  CurrentState:
>        mLastUpdateError=0, eventsToProcess=F, isRunning=T (1)
>  _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Coreaudio-api mailing list      (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: 3D Mixer on iPhone
      • From: Bob Lang <email@hidden>
References: 
 >3D Mixer on iPhone (From: Paul Slocum <email@hidden>)

  • Prev by Date: Re: Extracting Amplitude Data from Linear PCM on the iPhone
  • Next by Date: Re: 3D Mixer on iPhone
  • Previous by thread: 3D Mixer on iPhone
  • Next by thread: Re: 3D Mixer on iPhone
  • Index(es):
    • Date
    • Thread