19#ifndef __VOLTOCTAVETAPERDELEGATE_H
20#define __VOLTOCTAVETAPERDELEGATE_H
22#include "AAX_ITaperDelegate.h"
23#include "AAX_UtilsNative.h"
28template <
typename T,
int32_t RealPrecision=1000>
52 T GetMinimumValue()
const {
return mMinValue; }
53 T GetMaximumValue()
const {
return mMaxValue; }
54 T ConstrainRealValue(T value)
const;
55 T NormalizedToReal(
double normalizedValue)
const;
56 double RealToNormalized(T realValue)
const;
59 T Round(
double iValue)
const;
62 inline double calcVoltOctaveParameter(
double fCookedParam)
const
64 double dOctaves = log2(getMax()/getMin());
65 return log2( fCookedParam/getMin() )/dOctaves;
70 inline double calcVoltOctavePluginValue(
double fPluginValue)
const
72 double dOctaves = log2(getMax()/getMin());
73 float fDisplay = getMin()*exp2(fPluginValue*dOctaves);
74 float fDiff = getMax() - getMin();
75 return (fDisplay - getMin())/fDiff;
78 double getMin()
const {
return (
double)mMinValue;}
79 double getMax()
const {
return (
double)mMaxValue;}
86template <
typename T,
int32_t RealPrecision>
89 double precision = RealPrecision;
91 return static_cast<T
>(floor(iValue * precision + 0.5) / precision);
92 return static_cast<T
>(iValue);
95template <
typename T,
int32_t RealPrecision>
103template <
typename T,
int32_t RealPrecision>
109template <
typename T,
int32_t RealPrecision>
113 value = Round(value);
115 if (value > mMaxValue)
117 if (value < mMinValue)
122template <
typename T,
int32_t RealPrecision>
125 normalizedValue = calcVoltOctavePluginValue(normalizedValue);
126 double doubleRealValue = normalizedValue*(mMaxValue - mMinValue) + mMinValue;
127 T realValue = (T) doubleRealValue;
129 return ConstrainRealValue(realValue);
132template <
typename T,
int32_t RealPrecision>
135 return calcVoltOctaveParameter(realValue);
Definition: VoltOctaveTaperDelegate.h:46