AAX SDK 2.6.1
Avid Audio Extensions Development Kit
Loading...
Searching...
No Matches
AAX_CStateTaperDelegate.h
Go to the documentation of this file.
1/*================================================================================================*/
2/*
3 *
4 * Copyright 2014-2017, 2019, 2023 Avid Technology, Inc.
5 * All rights reserved.
6 *
7 * CONFIDENTIAL: this document contains confidential information of Avid. Do
8 * not disclose to any third party. Use of the information contained in this
9 * document is subject to an Avid SDK license.
10 *
11 */
12
19/*================================================================================================*/
20
21
22#ifndef AAX_CSTATETAPERDELEGATE_H
23#define AAX_CSTATETAPERDELEGATE_H
24
25#include "AAX_ITaperDelegate.h"
26#include "AAX.h" //for types
27
28#include <cmath> //for floor()
29
30
42template <typename T>
44{
45public:
53 AAX_CStateTaperDelegate(T minValue=0, T maxValue=1);
54
55 //Virtual Overrides
57 T GetMinimumValue() const AAX_OVERRIDE { return mMinValue; }
58 T GetMaximumValue() const AAX_OVERRIDE { return mMaxValue; }
59 T ConstrainRealValue(T value) const AAX_OVERRIDE;
60 T NormalizedToReal(double normalizedValue) const AAX_OVERRIDE;
61 double RealToNormalized(T realValue) const AAX_OVERRIDE;
62
63private:
64 T mMinValue;
65 T mMaxValue;
66};
67
68template <typename T>
70 mMinValue(minValue),
71 mMaxValue(maxValue)
72{
73
74}
75
76template <typename T>
78{
79 return new AAX_CStateTaperDelegate(*this);
80}
81
82template <typename T>
84{
85 if (mMinValue == mMaxValue)
86 return mMinValue;
87
88 const T& highValue = mMaxValue > mMinValue ? mMaxValue : mMinValue;
89 const T& lowValue = mMaxValue > mMinValue ? mMinValue : mMaxValue;
90
91 if (value > highValue)
92 return highValue;
93 if (value < lowValue)
94 return lowValue;
95
96 return value;
97}
98
99template <typename T>
100T AAX_CStateTaperDelegate<T>::NormalizedToReal(double normalizedValue) const
101{
102 double doubleRealValue = normalizedValue * (double(mMaxValue) - double(mMinValue)) + double(mMinValue);
103 if ( doubleRealValue >= 0 )
104 doubleRealValue += 0.5;
105 else doubleRealValue -= 0.5;
106 return ConstrainRealValue(static_cast<T>(doubleRealValue));
107}
108
109template <typename T>
111{
112 realValue = ConstrainRealValue(realValue);
113 double normalizedValue = (mMaxValue == mMinValue) ? 0.5 : (double(realValue) - double(mMinValue)) / (double(mMaxValue) - double(mMinValue));
114 return normalizedValue;
115}
116
117
118
119
120#endif //AAX_CSTATETAPERDELEGATE_H
Defines the taper conversion behavior for a parameter.
Various utility definitions for AAX.
#define AAX_OVERRIDE
override keyword macro
Definition: AAX.h:151
A linear taper conforming to AAX_ITaperDelegate.
Definition: AAX_CStateTaperDelegate.h:44
T NormalizedToReal(double normalizedValue) const AAX_OVERRIDE
Converts a normalized value to a real value.
Definition: AAX_CStateTaperDelegate.h:100
T GetMinimumValue() const AAX_OVERRIDE
Returns the taper's minimum real value.
Definition: AAX_CStateTaperDelegate.h:57
AAX_CStateTaperDelegate< T > * Clone() const AAX_OVERRIDE
Constructs and returns a copy of the taper delegate.
Definition: AAX_CStateTaperDelegate.h:77
T ConstrainRealValue(T value) const AAX_OVERRIDE
Applies a contraint to the value and returns the constrained value.
Definition: AAX_CStateTaperDelegate.h:83
AAX_CStateTaperDelegate(T minValue=0, T maxValue=1)
Constructs a State Taper with specified minimum and maximum values.
Definition: AAX_CStateTaperDelegate.h:69
T GetMaximumValue() const AAX_OVERRIDE
Returns the taper's maximum real value.
Definition: AAX_CStateTaperDelegate.h:58
double RealToNormalized(T realValue) const AAX_OVERRIDE
Normalizes a real parameter value.
Definition: AAX_CStateTaperDelegate.h:110
Definition: AAX_ITaperDelegate.h:86