| AAX SDK 2.8.0 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-2024 Avid Technology, Inc.
5 * All rights reserved.
6 *
7 * This file is part of the Avid AAX SDK.
8 *
9 * The AAX SDK is subject to commercial or open-source licensing.
10 *
11 * By using the AAX SDK, you agree to the terms of both the Avid AAX SDK License
12 * Agreement and Avid Privacy Policy.
13 *
14 * AAX SDK License: https://developer.avid.com/aax
15 * Privacy Policy: https://www.avid.com/legal/privacy-policy-statement
16 *
17 * Or: You may also use this code under the terms of the GPL v3 (see
18 * www.gnu.org/licenses).
19 *
20 * THE AAX SDK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
21 * EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
22 * DISCLAIMED.
23 *
24 */
25
32/*================================================================================================*/
33
34
35#ifndef AAX_CSTATETAPERDELEGATE_H
36#define AAX_CSTATETAPERDELEGATE_H
37
38#include "AAX_ITaperDelegate.h"
39#include "AAX.h" //for types
40
41#include <cmath> //for floor()
42
43
55 template <typename T>
56 class AAX_CStateTaperDelegate : public AAX_ITaperDelegate<T>
57{
58 public:
66 AAX_CStateTaperDelegate(T minValue=0, T maxValue=1);
67
68 //Virtual Overrides
69 AAX_CStateTaperDelegate<T>* Clone() const AAX_OVERRIDE;
70 T GetMinimumValue() const AAX_OVERRIDE { return mMinValue; }
71 T GetMaximumValue() const AAX_OVERRIDE { return mMaxValue; }
72 T ConstrainRealValue(T value) const AAX_OVERRIDE;
73 T NormalizedToReal(double normalizedValue) const AAX_OVERRIDE;
74 double RealToNormalized(T realValue) const AAX_OVERRIDE;
75
76 private:
77 T mMinValue;
78 T mMaxValue;
79};
80
81 template <typename T>
82 AAX_CStateTaperDelegate<T>::AAX_CStateTaperDelegate(T minValue, T maxValue) : AAX_ITaperDelegate<T>(),
83 mMinValue(minValue),
84 mMaxValue(maxValue)
85{
86
87}
88
89 template <typename T>
90 AAX_CStateTaperDelegate<T>* AAX_CStateTaperDelegate<T>::Clone() const
91{
92 return new AAX_CStateTaperDelegate(*this);
93}
94
95 template <typename T>
96T AAX_CStateTaperDelegate<T>::ConstrainRealValue(T value) const
97{
98 if (mMinValue == mMaxValue)
99 return mMinValue;
100
101 const T& highValue = mMaxValue > mMinValue ? mMaxValue : mMinValue;
102 const T& lowValue = mMaxValue > mMinValue ? mMinValue : mMaxValue;
103
104 if (value > highValue)
105 return highValue;
106 if (value < lowValue)
107 return lowValue;
108
109 return value;
110}
111
112 template <typename T>
113T AAX_CStateTaperDelegate<T>::NormalizedToReal(double normalizedValue) const
114{
115 double doubleRealValue = normalizedValue * (double(mMaxValue) - double(mMinValue)) + double(mMinValue);
116 if ( doubleRealValue >= 0 )
117 doubleRealValue += 0.5;
118 else doubleRealValue -= 0.5;
119 return ConstrainRealValue(static_cast<T>(doubleRealValue));
120}
121
122 template <typename T>
123 double AAX_CStateTaperDelegate<T>::RealToNormalized(T realValue) const
124{
125 realValue = ConstrainRealValue(realValue);
126 double normalizedValue = (mMaxValue == mMinValue) ? 0.5 : (double(realValue) - double(mMinValue)) / (double(mMaxValue) - double(mMinValue));
127 return normalizedValue;
128}
129
130
131
132
133#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:164
AAX_CStateTaperDelegate
A linear taper conforming to AAX_ITaperDelegate.
Definition: AAX_CStateTaperDelegate.h:57
AAX_CStateTaperDelegate::NormalizedToReal
T NormalizedToReal(double normalizedValue) const AAX_OVERRIDE
Converts a normalized value to a real value.
Definition: AAX_CStateTaperDelegate.h:113
AAX_CStateTaperDelegate::GetMinimumValue
T GetMinimumValue() const AAX_OVERRIDE
Returns the taper's minimum real value.
Definition: AAX_CStateTaperDelegate.h:70
AAX_CStateTaperDelegate::Clone
AAX_CStateTaperDelegate< T > * Clone() const AAX_OVERRIDE
Constructs and returns a copy of the taper delegate.
Definition: AAX_CStateTaperDelegate.h:90
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:96
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:82
AAX_CStateTaperDelegate::GetMaximumValue
T GetMaximumValue() const AAX_OVERRIDE
Returns the taper's maximum real value.
Definition: AAX_CStateTaperDelegate.h:71
AAX_CStateTaperDelegate::RealToNormalized
double RealToNormalized(T realValue) const AAX_OVERRIDE
Normalizes a real parameter value.
Definition: AAX_CStateTaperDelegate.h:123
AAX_ITaperDelegate
Definition: AAX_ITaperDelegate.h:99