AU parameter display flags
AU parameter display flags
- Subject: AU parameter display flags
- From: Marc Poirier <email@hidden>
- Date: Mon, 14 Feb 2005 15:38:51 -0500
So I've just been working on an AU that provides no custom view and
using the display AU parameter flags for a few parameters, a feature
which was added due to my ceaseless nagging ;-), and now I notice that
a few of them have actually been implemented in the inverse fashion.
Or at least the inverse of what I had suggested. I'm not sure if this
is just a straight-up bug in the AudioUnitToolbox code, or intentional
(and just different than what I would have thought would be intended),
so I was wondering if anyone knows which is the case.
Specifically, I am talking about these display options:
kAudioUnitParameterFlag_DisplaySquareRoot
kAudioUnitParameterFlag_DisplaySquared
kAudioUnitParameterFlag_DisplayCubed
kAudioUnitParameterFlag_DisplayCubeRoot
Rather than try to explain what I expect, I will just show what I would
have thought the math might look like:
Float32 AUParameterValueFromLinear(Float32 inLinearValue, const
AudioUnitParameter * inParameter)
{
Float32 minValue = inParameter->minValue;
Float32 valueRange = inParameter->maxValue - minValue;
switch (inParameter->flags & kAudioUnitParameterFlag_DisplayMask)
{
case kAudioUnitParameterFlag_DisplaySquareRoot:
return (sqrtf(inLinearValue) * valueRange) + minValue;
case kAudioUnitParameterFlag_DisplaySquared:
return (inLinearValue*inLinearValue * valueRange) + minValue;
case kAudioUnitParameterFlag_DisplayCubed:
return (inLinearValue*inLinearValue*inLinearValue * valueRange) +
minValue;
case kAudioUnitParameterFlag_DisplayCubeRoot:
return (inLinearValue*inLinearValue*inLinearValue * valueRange) +
minValue;
default:
return (inLinearValue * valueRange) + minValue;
}
}
Float32 AUParameterValueToLinear(Float32 inParameterValue, const
AudioUnitParameter * inParameter)
{
Float32 minValue = inParameter->minValue;
Float32 valueRange = inParameter->maxValue - minValue;
switch (inParameter->flags & kAudioUnitParameterFlag_DisplayMask)
{
case kAudioUnitParameterFlag_DisplaySquareRoot:
return (sqrtf(inParameterValue) * valueRange) + minValue;
case kAudioUnitParameterFlag_DisplaySquared:
return sqrtf((inParameterValue-minValue) / valueRange);
case kAudioUnitParameterFlag_DisplayCubed:
return powf( (inParameterValue-minValue) / valueRange, 1.0f/3.0f );
case kAudioUnitParameterFlag_DisplayCubeRoot:
return powf( (inParameterValue-minValue) / valueRange, 1.0f/3.0f );
default:
return (inParameterValue-minValue) / valueRange;
}
}
This is what I would expect, but the behavior that I am getting has
kAudioUnitParameterFlag_DisplaySquareRoot switched with
kAudioUnitParameterFlag_DisplaySquared, and
kAudioUnitParameterFlag_DisplayCubed switched with
kAudioUnitParameterFlag_DisplayCubeRoot.
thanks,
Marc
_______________________________________________
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