Re: hostcallback in logic
Re: hostcallback in logic
- Subject: Re: hostcallback in logic
- From: Marc Poirier <email@hidden>
- Date: Tue, 9 Sep 2003 12:30:12 -0500 (CDT)
I've said it before and I'll say it again: the mHostCallbacks thing in
AUBase really needs to be better explained in the docs. This sort of
confusion keeps coming up...
Anyway, you can just use mHostCallbacks as is. You don't need to
GetProperty or override GetProperty/SetProperty/etc. to intercept the
HostCallbacks property ID (in fact, that won't even work anyway the
AUBase::Dispatch* methods handle it).
To use the first callback:
if (mHostCallbackInfo.beatAndTempoProc != NULL)
{
Float64 tempo, beat;
OSStatus result = mHostCallbackInfo.beatAndTempoProc(mHostCallbackInfo.hostUserData, &beat, &tempo);
if (result == noErr)
{
/* do something */
}
}
To use the second one:
if (mHostCallbackInfo.musicalTimeLocationProc != NULL)
{
UInt32 sampleOffsetToNextBeat;
Float32 timeSigNumerator;
UInt32 timeSigDenominator;
Float64 currentMeasureDownBeat;
OSStatus result = mHostCallbackInfo.musicalTimeLocationProc(mHostCallbackInfo.hostUserData, &sampleOffsetToNextBeat, &timeSigNumerator, &timeSigDenominator, ¤tMeasureDownBeat);
if (result == noErr)
{
/* do something */
}
}
In addition to being properly explained and documented, it seems to me
like it might make a lot of sense to make a couple of simple and
convenient accessor/wrapper methods to AUBase for this. In fact, slightly
adapting what I just pasted above would do the trick:
OSStatus AUBase::GetTempoAndBeat(Float64 & outTempo, Float64 & outBeat)
{
if (mHostCallbackInfo.beatAndTempoProc == NULL)
return someAppropriateAUError;
return mHostCallbackInfo.beatAndTempoProc(mHostCallbackInfo.hostUserData, &outBeat, &outTempo);
}
OSStatus AUBase::GetMusicalTimeLocation(Float64 & outCurrentMeasureDownBeat, UInt32 & outSampleOffsetToNextBeat, Float32 & outTimeSigNumerator, UInt32 & outTimeSigDenominator)
{
if (mHostCallbackInfo.musicalTimeLocationProc == NULL)
return someAppropriateAUError;
return mHostCallbackInfo.musicalTimeLocationProc(mHostCallbackInfo.hostUserData, &outSampleOffsetToNextBeat, &outTimeSigNumerator, &outTimeSigDenominator, &outCurrentMeasureDownBeat);
}
It seems to me like, with OO C++ and the AUBase stuff and whatnot, we
shouldn't have to worry about passing the hostUserData and checking
nullity and whatnot every time, accessing an inherited member variable,
function pointers, etc., it could be easily simplified I think...
Marc
On Tue, 9 Sep 2003, Robert Fehse wrote:
>
hi list.
>
>
>
i tried the following like in the VST->AU SDK:
>
>
HostCallbackInfo tCBInfo;
>
memset(&tCBInfo, 0, sizeof(HostCallbackInfo));
>
GetProperty(kAudioUnitProperty_HostCallbacks, kAudioUnitScope_Global, 0,
>
&tCBInfo);
>
>
but GetProperty returns -10879 and tCBInfo is empty.
>
>
>
then i saw in setproperty:
>
>
case : kAudioUnitProperty_HostCallbacks: // --------------
>
m_sHostCallback=*(HostCallbackInfo*)(pData);
>
>
but i never got a call here.
>
>
is there another way to get musicaltime info, or what i am missing ?
>
>
i just want to have somthing like ppqPos.
>
>
>
thx
>
>
robert
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.