• 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: Custom Audio Units on the iPhone
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Custom Audio Units on the iPhone


  • Subject: Re: Custom Audio Units on the iPhone
  • From: William Stewart <email@hidden>
  • Date: Wed, 26 Nov 2008 10:34:01 -0800

ah...

2 things:

(1) you are using the wrong output unit.
kAudioUnitSubType_GenericOutput
is the generic output unit - it isn't attached to an audio device - all that it does is provide you with the semantics of an AUConveter (it can do linear pcm conversions) in an output unit. If you have a look at /Developer/Examples/CoreAudio/SimpleSDK/PlaySequence you can see an example of how you might want to use this audio unit


you want to replace kAudioUnitSubType_GenericOutput with kAudioUnitSubType_RemoteIO for iPhone or kAudioUnitSubType_DefaultOutput for the desktop. The RemoteIO audio unit is the one that attaches to the audio I/O sub system on the phone and will output audio for you

(2) OSStatus TestCallback(void* inRefCon, AudioUnitRenderActionFlags* ioActionFlags, const AudioTimeStamp* inTimeStamp, UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList* ioData)

you should make sure that you set the contents of ioData to silence, or once this does actually play you will hear some noise:

	AudioBuffer *buf = ioData->mBuffers;
	for (UInt32 i = ioData->mNumberBuffers; i--; ++buf)
		memset((Byte *)buf->mData, 0, buf->mDataByteSize);


(3) I just removed this completely (it was confusing me)
/*err = AUGraphNodeInfo(graph, mixerNode, &mixerDescription, &mixerUnit);
NSAssert(err == noErr, @"Error obtaining mixer unit.");
err = AudioUnitSetProperty(mixerUnit, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Input, 0, &callback, sizeof(callback)); */


Bill

On Nov 26, 2008, at 2:08 AM, Thomas Zoechling wrote:

I removed all the unnecessary code and ended up with this:

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_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_GenericOutput;
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.");
AURenderCallbackStruct callback;
callback.inputProc = TestCallback;
callback.inputProcRefCon = NULL;
err = AUGraphSetNodeInputCallback(graph, mixerNode, 0, &callback);
NSAssert(err == noErr, @"Error setting render callback.");
err = AUGraphConnectNodeInput(graph, mixerNode, 0, outputNode, 0);
NSAssert(err == noErr, @"Error connecting mixer to output.");
err = AUGraphInitialize(graph);
NSAssert(err == noErr, @"Error initializing graph.");
err = AUGraphStart(graph);
NSAssert(err == noErr, @"Error starting graph.");
CAShow(graph);


This is the TestCallback I provide:

OSStatus TestCallback(void* inRefCon, AudioUnitRenderActionFlags* ioActionFlags, const AudioTimeStamp* inTimeStamp, UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList* ioData)
{
NSLog(@"called!");
return noErr;
}


CAShow displays:

AudioUnitGraph 0x104B414:
 Member Nodes:
	node 1: aumx 3dem appl, instance 0x57d810 O I
	node 2: auou genr appl, instance 0x58f1e0 O I
 Connections:
	node   1 bus   0 => node   2 bus   0  [2 ch, 44100 Hz]
 Input Callbacks:
	{0x373b, 0x0} => node   1 bus   0  [1 ch, 44100 Hz]
 CurrentState:
	mLastUpdateError=0, eventsToProcess=F, isRunning=T

But still my Callback does not get called :(

--thomas
_______________________________________________
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
References: 
 >Custom Audio Units on the iPhone (From: Thomas Zoechling <email@hidden>)
 >Re: Custom Audio Units on the iPhone (From: William Stewart <email@hidden>)
 >Re: Custom Audio Units on the iPhone (From: Thomas Zoechling <email@hidden>)

  • Prev by Date: Re: Custom Audio Units on the iPhone
  • Next by Date: Re: Midi Controller Plugin
  • Previous by thread: Re: Custom Audio Units on the iPhone
  • Next by thread: reading from the iPhone mic with a small buffer size
  • Index(es):
    • Date
    • Thread