| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
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:
http://lists.apple.com/mailman/options/coreaudio-api/email@hidden
This email sent to email@hidden
| References: | |
| >AU parameter display flags (From: Marc Poirier <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.