AAX SDK  2.1.1
Avid Audio Extensions Development Kit
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AAX_CStateTaperDelegate.h
Go to the documentation of this file.
1 /*================================================================================================*/
2 /*
3  *
4  * Copyright (c) 2009 Avid Technology, Inc.
5  * All rights reserved.
6  *
7  * CONFIDENTIAL: This document contains confidential information. Do not
8  * read or examine this document unless you are an Avid Technology employee
9  * or have signed a non-disclosure agreement with Avid Technology which protects
10  * the confidentiality of this document. DO NOT DISCLOSE ANY INFORMATION
11  * CONTAINED IN THIS DOCUMENT TO ANY THIRD-PARTY WITHOUT THE PRIOR WRITTEN CONSENT
12  * OF Avid Technolgy, INC.
13  *
14  */
15 
22 /*================================================================================================*/
23 
24 
25 #ifndef AAX_CSTATETAPERDELEGATE_H
26 #define AAX_CSTATETAPERDELEGATE_H
27 
28 #include "AAX_ITaperDelegate.h"
29 #include "AAX.h" //for types
30 
31 #include <cmath> //for floor()
32 
33 
45 template <typename T>
47 {
48 public:
56  AAX_CStateTaperDelegate(T minValue=0, T maxValue=1);
57 
58  //Virtual Overrides
60  T GetMinimumValue() const { return mMinValue; }
61  T GetMaximumValue() const { return mMaxValue; }
62  T ConstrainRealValue(T value) const;
63  T NormalizedToReal(double normalizedValue) const;
64  double RealToNormalized(T realValue) const;
65 
66 private:
67  T mMinValue;
68  T mMaxValue;
69 };
70 
71 template <typename T>
73  mMinValue(minValue),
74  mMaxValue(maxValue)
75 {
76 
77 }
78 
79 template <typename T>
81 {
82  return new AAX_CStateTaperDelegate(*this);
83 }
84 
85 template <typename T>
87 {
88  if (value > mMaxValue)
89  return mMaxValue;
90  if (value < mMinValue)
91  return mMinValue;
92  return value;
93 }
94 
95 template <typename T>
96 T AAX_CStateTaperDelegate<T>::NormalizedToReal(double normalizedValue) const
97 {
98  double doubleRealValue = normalizedValue * (double(mMaxValue) - double(mMinValue)) + double(mMinValue);
99  if ( doubleRealValue >= 0 )
100  doubleRealValue += 0.5;
101  else doubleRealValue -= 0.5;
102  return ConstrainRealValue(static_cast<T>(doubleRealValue));
103 }
104 
105 template <typename T>
107 {
108  realValue = ConstrainRealValue(realValue);
109  double normalizedValue = (double(realValue) - double(mMinValue)) / (double(mMaxValue) - double(mMinValue));
110  return normalizedValue;
111 }
112 
113 
114 
115 
116 #endif //AAX_CSTATETAPERDELEGATE_H
AAX_CStateTaperDelegate(T minValue=0, T maxValue=1)
Constructs a State Taper with specified minimum and maximum values.
Definition: AAX_CStateTaperDelegate.h:72
T GetMinimumValue() const
Returns the taper&#39;s minimum real value.
Definition: AAX_CStateTaperDelegate.h:60
AAX_CStateTaperDelegate< T > * Clone() const
Constructs and returns a copy of the taper delegate.
Definition: AAX_CStateTaperDelegate.h:80
Various utility definitions for AAX.
T GetMaximumValue() const
Returns the taper&#39;s maximum real value.
Definition: AAX_CStateTaperDelegate.h:61
Defines the taper conversion behavior for a parameter.
T ConstrainRealValue(T value) const
Applies a contraint to the value and returns the constrained value.
Definition: AAX_CStateTaperDelegate.h:86
T NormalizedToReal(double normalizedValue) const
Converts a normalized value to a real value.
Definition: AAX_CStateTaperDelegate.h:96
Classes for conversion to and from normalized parameter values.
Definition: AAX_ITaperDelegate.h:88
double RealToNormalized(T realValue) const
Normalizes a real parameter value.
Definition: AAX_CStateTaperDelegate.h:106
A linear taper conforming to AAX_ITaperDelegate.
Definition: AAX_CStateTaperDelegate.h:46