| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
This is consistent with the way we use Log/Exp...
So, the idea here is that the parameter value is squared to a linear value with the Display Squared flag
"Display the parameter's value by TRANSFORM_IT function on that value" kind of thing.
This is how DisplayLog has always been interpreted, so we wanted to be consistent with that.
Bill
On 14/02/2005, at 12:38 PM, Marc Poirier wrote:
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
| References: | |
| >AU parameter display flags (From: Marc Poirier <email@hidden>) | |
| >Re: AU parameter display flags (From: William Stewart <email@hidden>) |
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.