Re: AUEffectBase and Stream formats
Re: AUEffectBase and Stream formats
- Subject: Re: AUEffectBase and Stream formats
- From: Bill Stewart <email@hidden>
- Date: Thu, 22 May 2003 15:36:28 -0700
Marc, et al,
So - rather than go the route of introducing a new base class, we've
gone over the kernel stuff, etc, and will continue to use AUEffectBase
as a general subclass for any channel valences... With the continued
advise that the kernel can be used for N->N effects, and for N->M
channel effects the ProcessBufferList method should be overwritten...
To make this work correctly, I've taken the code that Marc wrote
(THANKS!) into the Initialize call of AUEffectBase - please note, there
was a bug in the code Marc posted in the first if test in the loop -
the code (at least what I had from his post) was testing auNumInputs <
0 -> this should be configNumInputs..
Otherwise, its as Marc wrote it - the final version of the Init call
I've pasted in below.
We don't do the validation of channels on the ChangeStreamFormat call -
why have the code in two places, and as discussed previously the
ChangeStreamFormat can't completely validate the format - only
initialize can. Initialize does return an invalid format error if the
channels are wrong, and the host should take some responsibility to
check channel information before setting it (as they all do anyway to
present UI to their users, etc...)
A couple of potential gotchas for those using this class for N->M
effects... both the base class' handling of the Bypass property and
processing inplace, need to be revisited - the base class' support for
both of these properties is contingent on N->N processing.
To get on the same page as the rest of you, we're going to move our
N->M effects over from AUBase, so at some (not too later) date, we'll
have at least some more thorough support for these properties in
AUEffectBase than this does currently.
This seemed an easier path for all concerned than introducing a new
base class - so I hope that is fine with you guys. This update will be
available in the next Dev Tools release... We got all of the other
fixes that had been mentioned on the list after the SDK was last posted.
Thanks again for all your help and attention!
Bill
Here's the new version of Initialize...
ComponentResult AUEffectBase::Initialize()
{
const AUChannelInfo *auChannelConfigs = NULL;
UInt32 numIOconfigs = SupportedNumChannels(&auChannelConfigs);
// does the unit publish specific information about channel
configurations?
if ((numIOconfigs > 0) && (auChannelConfigs != NULL))
{
SInt16 auNumInputs = (SInt16)
GetStreamFormat(kAudioUnitScope_Input, 0).mChannelsPerFrame;
SInt16 auNumOutputs = (SInt16)
GetStreamFormat(kAudioUnitScope_Output, 0).mChannelsPerFrame;
bool foundMatch = false;
for (UInt32 i = 0; (i < numIOconfigs) && !foundMatch; ++i)
{
SInt16 configNumInputs = auChannelConfigs[i].inChannels;
SInt16 configNumOutputs = auChannelConfigs[i].outChannels;
if ((configNumInputs < 0) && (configNumOutputs < 0))
{
// unit accepts any number of channels on input and output
if (((configNumInputs == -1) && (configNumOutputs ==
-2)) || ((configNumInputs == -2) && (configNumOutputs == -1)))
foundMatch = true;
// unit accepts any number of channels on input and output IFF
they are the same number on both scopes
else if (((configNumInputs == -1) && (configNumOutputs
== -1)) && (auNumInputs == auNumOutputs))
foundMatch = true;
// unit has specified a particular number of channels on both
scopes
else
continue;
}
else
{
// the -1 case on either scope is saying that the unit doesn't
care about the
// number of channels on that scope
bool inputMatch = (auNumInputs == configNumInputs) ||
(configNumInputs == -1);
bool outputMatch = (auNumOutputs == configNumOutputs)
|| (configNumOutputs == -1);
if (inputMatch && outputMatch)
foundMatch = true;
}
}
if (!foundMatch)
return kAudioUnitErr_FormatNotSupported;
}
else
{
// there is no specifically published channel info
// so for those kinds of effects, the assumption is that the
channels (whatever their number)
// should match on both scopes
if ((GetNumberOfChannels() !=
GetInput(0)->GetStreamFormat().mChannelsPerFrame) ||
(GetNumberOfChannels() == 0))
return kAudioUnitErr_FormatNotSupported;
}
MaintainKernels();
return noErr;
}
--
mailto:email@hidden
tel: +1 408 974 4056
________________________________________________________________________
__
"Much human ingenuity has gone into finding the ultimate Before.
The current state of knowledge can be summarized thus:
In the beginning, there was nothing, which exploded" - Terry Pratchett
________________________________________________________________________
__
_______________________________________________
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.