• 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
AudioUnitRender
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AudioUnitRender


  • Subject: AudioUnitRender
  • From: email@hidden
  • Date: Fri, 26 Oct 2007 16:14:10 -0400 (EDT)

Hey,

I'm trying to create an audio unit which calls another audio unit and I'm not "getting" something I'm reading in the documentation.

AU's are based on a pull model, so is there an accepted way to "push" data through an AU?  In the sample code below I've sucessfully instantiated and initialized the AUPitch component and now I'd like the AU to Process data inline.

I must be missing something obvious.....

->Ken

************************************************
#include "MyAU.h"
#include <AudioToolbox/AudioToolbox.h>


struct AudioUnitRenderGluePB {
	unsigned char                  componentFlags;
	unsigned char                  componentParamSize;
	short                          componentWhat;
	AudioBufferList*               ioData;
	UInt32                         inNumberFrames;
	UInt32                         inOutputBusNumber;
	const AudioTimeStamp*          inTimeStamp;
	AudioUnitRenderActionFlags*    ioActionFlags;
	AudioUnit                      ci;
};



//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

COMPONENT_ENTRY(MyAU)

ComponentInstance				MyAU::softWhammy_ = NULL;
Component						MyAU::softWhammyComponent_ = NULL;
AudioTimeStamp*					MyAU::theTimeStamp_ = NULL;
AudioUnitRenderActionFlags*		MyAU::ioActionFlags_;

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//	MyAU::MyAU
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
MyAU::MyAU(AudioUnit component) :
	AUEffectBase(component)
{
	ComponentDescription softWhammy = { kAudioUnitType_Effect, kAudioUnitSubType_TimePitch,
             kAudioUnitManufacturer_Apple, 0, 0};

	CreateElements();
	Globals()->UseIndexedParameters(kNumberOfParameters);
	SetParameter(kParam_One, kDefaultValue_ParamOne );

	softWhammyComponent_ = FindNextComponent(NULL,&softWhammy);
	softWhammy_ = OpenComponent(softWhammyComponent_);
	ComponentResult result = AudioUnitInitialize( softWhammy_);


#if AU_DEBUG_DISPATCHER
	mDebugDispatcher = new AUDebugDispatcher (this);
#endif

}

ComponentResult	MyAU::ComponentEntryDispatch(ComponentParameters *params, AUBase *This)
{

	ComponentResult result = noErr;

	switch (params->what) {
		case kAudioUnitRenderSelect :
		{
			AudioUnitRenderGluePB *theParams = (AudioUnitRenderGluePB *)params;
			theTimeStamp_ = (AudioTimeStamp*)theParams->inTimeStamp;
			ioActionFlags_ = (AudioUnitRenderActionFlags*)theParams->ioActionFlags;
		}
	}

	result = AUEffectBase::ComponentEntryDispatch(params, This);
	return	result;

}


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//	MyAU::MyAUKernel::Process
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void MyAU::MyAUKernel::Process(
                const Float32 	*inSourceP,
                      Float32   *inDestP,
                      UInt32 	inFramesToProcess,
                      UInt32	inNumChannels, // for version 2 AudioUnits inNumChannels is always 1
                      bool			&ioSilence )
{

	AudioBuffer		theBuffer = { inNumChannels, inFramesToProcess * sizeof(Float32), inDestP };
	AudioBufferList	theList = { 0 };

	theList.mNumberBuffers = 1;
	theList.mBuffers[0] = theBuffer;

	ComponentResult result =
              AudioUnitRender(
				softWhammy_,
				ioActionFlags_,
				(const AudioTimeStamp*)	theTimeStamp_,
				0,
				inFramesToProcess,
				&theList);
}


 _______________________________________________
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: AudioUnitRender
      • From: William Stewart <email@hidden>
  • Prev by Date: Re: Help needed for Audio Unit Parameter Change Notification
  • Next by Date: Re: Help needed for Audio Unit Parameter Change Notification
  • Previous by thread: Re: Simple Question on m4a CAStreamBasicDescription and Recording
  • Next by thread: Re: AudioUnitRender
  • Index(es):
    • Date
    • Thread