Re: AudioUnitRender
Re: AudioUnitRender
- Subject: Re: AudioUnitRender
- From: William Stewart <email@hidden>
- Date: Fri, 26 Oct 2007 19:15:04 -0700
You should not initialise the other AU until you are initialised.
when you call the other AU's AU Render call you need to have a
callback function to provide input for it - and you have to get the
input for your surrounding AU too. So, have a look at the
AUEffectBase::Render call and follow the input element's path to
getting the input
But, really I have to ask the inevitable question - why are you
writing an AU to host another AU? Why not just connect that AU to the
one you are writing (MyAU)
Bill
On Oct 26, 2007, at 1:14 PM, email@hidden wrote:
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
_______________________________________________
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