Re: Host callback
Re: Host callback
- Subject: Re: Host callback
- From: email@hidden
- Date: Thu, 03 Mar 2005 15:56:22 +0000
Thank you Guys for your help. I could not make it compile though.
First I added a declaration in the header file:
HostCallbackInfo mHostCallbackInfo;
then I put example code within Process function but compiler says:
error: 'IsTransportStateProcSafe' undeclared (first use this function).
Do excuse me for (probable) newbie cpp issues.
Code is as follows on both files, help much appreciated.
Ralph
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
mAU.h
protected:
class FAUKernel : public AUKernelBase // most of the real work happens here
{
public:
mAUKernel(AUEffectBase *inAudioUnit )
: AUKernelBase(inAudioUnit)
{
}
// *Required* overides for the process method for this effect
// processes one channel of interleaved samples
virtual void Process( const Float32 *inSourceP,
Float32 *inDestP,
UInt32 inFramesToProcess,
UInt32 inNumChannels,
bool &ioSilence);
virtual void Reset();
//private: //state variables...
HostCallbackInfo mHostCallbackInfo;
};
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
mAU.cpp
void mAU::mAUKernel::Process( const Float32 *inSourceP,
Float32 *inDestP,
UInt32 inFramesToProcess,
UInt32 inNumChannels,
bool &ioSilence )
{
//This code will pass-thru the audio data.
//This is where you want to process data to produce an effect.
UInt32 nSampleFrames = inFramesToProcess;
const Float32 *sourceP = inSourceP;
Float32 *destP = inDestP;
Float32 gain = GetParameter( kParam_One );
bool haveSamplePos = false;
Float64 outCurrentSampleInTimeLine;
if ( IsTransportStateProcSafe() && mHostCallbackInfo.transportStateProc )
{
OSStatus result = mHostCallbackInfo.transportStateProc(mHostCallbackInfo.hostUserData, NULL, NULL, &outCurrentSampleInTimeLine, NULL, NULL, NULL);
if ( result == noErr )
{
haveSamplePos = true;
}
}
while (nSampleFrames-- > 0) {
Float32 inputSample = *sourceP;
sourceP += inNumChannels; // advance to next frame (e.g. if stereo, we're advancing 2 samples);
// we're only processing one of an arbitrary number of interleaved channels
// here's where you do your DSP work
Float32 outputSample = inputSample * gain;
*destP = outputSample;
destP += inNumChannels;
}
}
_______________________________________________
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