| AAX SDK 2.6.1 Avid Audio Extensions Development Kit

- Welcome
- Manual
- Classes
- Files
- Lists
- Support

- File List
- File Members

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
42 template <typename T>
43 class AAX_CStateTaperDelegate : public AAX_ITaperDelegate<T>
44{
45 public:
53 AAX_CStateTaperDelegate(T minValue=0, T maxValue=1);
54
55 //Virtual Overrides
56 AAX_CStateTaperDelegate<T>* Clone() const AAX_OVERRIDE;
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
63 private:
64 T mMinValue;
65 T mMaxValue;
66};
67
68 template <typename T>
69 AAX_CStateTaperDelegate<T>::AAX_CStateTaperDelegate(T minValue, T maxValue) : AAX_ITaperDelegate<T>(),
70 mMinValue(minValue),
71 mMaxValue(maxValue)
72{
73
74}
75
76 template <typename T>
77 AAX_CStateTaperDelegate<T>* AAX_CStateTaperDelegate<T>::Clone() const
78{
79 return new AAX_CStateTaperDelegate(*this);
80}
81
82 template <typename T>
83T AAX_CStateTaperDelegate<T>::ConstrainRealValue(T value) const
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
99 template <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
109 template <typename T>
110 double AAX_CStateTaperDelegate<T>::RealToNormalized(T realValue) const
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
AAX_ITaperDelegate.h
Defines the taper conversion behavior for a parameter.
AAX.h
Various utility definitions for AAX.
AAX_OVERRIDE
#define AAX_OVERRIDE
override keyword macro
Definition: AAX.h:151
AAX_CStateTaperDelegate
A linear taper conforming to AAX_ITaperDelegate.
Definition: AAX_CStateTaperDelegate.h:44
AAX_CStateTaperDelegate::NormalizedToReal
T NormalizedToReal(double normalizedValue) const AAX_OVERRIDE
Converts a normalized value to a real value.
Definition: AAX_CStateTaperDelegate.h:100
AAX_CStateTaperDelegate::GetMinimumValue
T GetMinimumValue() const AAX_OVERRIDE
Returns the taper's minimum real value.
Definition: AAX_CStateTaperDelegate.h:57
AAX_CStateTaperDelegate::Clone
AAX_CStateTaperDelegate< T > * Clone() const AAX_OVERRIDE
Constructs and returns a copy of the taper delegate.
Definition: AAX_CStateTaperDelegate.h:77
AAX_CStateTaperDelegate::ConstrainRealValue
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::AAX_CStateTaperDelegate
AAX_CStateTaperDelegate(T minValue=0, T maxValue=1)
Constructs a State Taper with specified minimum and maximum values.
Definition: AAX_CStateTaperDelegate.h:69
AAX_CStateTaperDelegate::GetMaximumValue
T GetMaximumValue() const AAX_OVERRIDE
Returns the taper's maximum real value.
Definition: AAX_CStateTaperDelegate.h:58
AAX_CStateTaperDelegate::RealToNormalized
double RealToNormalized(T realValue) const AAX_OVERRIDE
Normalizes a real parameter value.
Definition: AAX_CStateTaperDelegate.h:110
AAX_ITaperDelegate
Definition: AAX_ITaperDelegate.h:86