Jamoma API  0.6.0.a19
TTMapper.h
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup modularLibrary
4  *
5  * @brief A Mapper Object
6  *
7  * @details
8  *
9  * @authors Théo de la Hogue
10  *
11  * @copyright © 2010, Théo de la Hogue @n
12  * This code is licensed under the terms of the "New BSD License" @n
13  * http://creativecommons.org/licenses/BSD/
14  */
15 
16 
17 #ifndef __TT_MAPPER_H__
18 #define __TT_MAPPER_H__
19 
20 #include "TTModularIncludes.h"
21 
22 /** TTMapper ... TODO : an explanation
23 
24 
25  */
26 
27 class TTReceiver;
28 typedef TTReceiver* TTReceiverPtr;
29 
30 class TTSender;
31 typedef TTSender* TTSenderPtr;
32 
33 class TTMODULAR_EXPORT TTMapper : public TTObjectBase
34 {
35  TTCLASS_SETUP(TTMapper)
36 
37 private:
38 
39  TTAddress mInput; ///< ATTRIBUTE : address of the data for the incoming value
40 
41  TTFloat64 mInputMin; ///< ATTRIBUTE : lower boundary of input value
42  TTFloat64 mInputMax; ///< ATTRIBUTE : upper boundery of input value
43  TTUInt32 mInputIndex; ///< ATTRIBUTE : select an index of the input value to map (0 means to take the whole value)
44  TTFloat64 mInputThresholdDown; ///< ATTRIBUTE :
45  TTFloat64 mInputThresholdUp; ///< ATTRIBUTE :
46  TTBoolean mInputGoingDown; ///< memorize last state to filter repetitions
47  TTBoolean mInputGoingUp; ///< memorize last state to filter repetitions
48 
49  TTAddress mOutput; ///< ATTRIBUTE : address of the data for the value to control
50 
51  TTFloat64 mOutputMin; ///< ATTRIBUTE : lower boundary of mapped (output) value
52  TTFloat64 mOutputMax; ///< ATTRIBUTE : upper boundary of mapped (output) value
53  TTFloat64 mOutputThresholdDown; ///< ATTRIBUTE :
54  TTFloat64 mOutputThresholdUp; ///< ATTRIBUTE :
55  TTBoolean mOutputGoingDown; ///< memorize last state to filter repetitions
56  TTBoolean mOutputGoingUp; ///< memorize last state to filter repetitions
57 
58  TTBoolean mActive; ///< ATTRIBUTE : does it observe Input value ?
59 
60  TTBoolean mInverse; ///< ATTRIBUTE : to make the output equal to mOutputMax - result
61 #ifndef TT_NO_DSP
62  TTValue mFunctionLibrary; ///< ATTRIBUTE : names of all available function from FunctionLib
63  TTSymbol mFunction; ///< ATTRIBUTE : name of the map function
64  TTValue mFunctionParameters; ///< ATTRIBUTE : names of parameter's function
65  TTValue mFunctionSamples; ///< ATTRIBUTE : an overview of the mapping (each value between [map(InputMin) :: map(InputMax)])
66 #endif
67  TTUInt32 mRamp; ///< ATTRIBUTE : a ramp time to pass to the output data
68 
69  TTSymbol mClipmode; ///< ATTRIBUTE: what clip mode to apply if proposed value is outside the range set by #mRangeBounds. Implemented options are none, both, low or high.
70 
71  TTObject mReceiver; ///< the receiver which binds on In data(s)
72  TTObject mSender; ///< the sender which binds on Out data(s)
73 
74  TTObject mInputObserver; ///< the receiver which observe the input address creation/destruction
75  TTObject mOutputObserver; ///< the receiver which observe the output address creation/destruction
76 
77  TTObject mInputRangeObserver; ///< the receiver which observe the input rangeBounds attribute
78  TTObject mOutputRangeObserver; ///< the receiver which observe the output rangeBounds attribute
79  TTBoolean mObserveInputRange; ///< do observe Input rangeBounds attribute ?
80  ///< Set to true if there are a setting Input address
81  ///< Set to false if there are a setting of Input Min/Max value
82  TTBoolean mObserveOutputRange; ///< do observe Output rangeBounds attribute ?
83  ///< Set to true if there are a setting Output address
84  ///< Set to false if there are a setting of Output Min/Max value
85 
86  TTObject mReturnValueCallback; ///< a way to return back value to the owner of this mapper
87 
88  TTObject mReturnInputGoingDownCallback;///< a way to return back if the input value is lower than or equal to the down threshold
89  TTObject mReturnInputGoingUpCallback;///< a way to return back if the input value is greater than or equal to the up threshold
90 
91  TTObject mReturnOutputGoingDownCallback;///< a way to return back if the output value is lower than or equal to the down threshold
92  TTObject mReturnOutputGoingUpCallback;///< a way to return back if the output value is greater than or equal to the up threshold
93 
94  TTFloat64 mA, mB, mC, mD; //< Coefficients used for normalizing input(A, B) and output (C, D)
95 #ifndef TT_NO_DSP
96  TTObject mFunctionUnit;
97  TTBoolean mValid; //< true if the functionUnit can be used
98 #endif
99 
100  /** process mapping */
101  TTErr Map(TTValue& inputValue, TTValue& outputValue);
102 #ifndef TT_NO_DSP
103  /** */
104  TTErr getFunctionLibrary(TTValue& value);
105 
106  /** */
107  TTErr getFunctionSamples(TTValue& value);
108 #endif
109  /** set the input address and set InputMin and InputMax using RangeBounds attributes */
110  TTErr setInput(const TTValue& value);
111  TTErr observeInput();
112  TTErr observeInputRange();
113 
114  /** set the output address and set OutputMin and OutputMax using RangeBounds attributes */
115  TTErr setOutput(const TTValue& value);
116  TTErr observeOutput();
117  TTErr observeOutputRange();
118 
119  /** */
120  TTErr setInputMin(const TTValue& value);
121 
122  /** */
123  TTErr setInputMax(const TTValue& value);
124 
125  /** */
126  TTErr setOutputMin(const TTValue& value);
127 
128  /** */
129  TTErr setOutputMax(const TTValue& value);
130 
131  /** */
132  TTErr setActive(const TTValue& value);
133 #ifndef TT_NO_DSP
134  /** set the function unit and set datas name extending attributes of the unit */
135  TTErr setFunction(const TTValue& value);
136 #endif
137  /** process mapping */
138  TTErr processMapping(const TTValue& inputValue, TTValue& outputValue);
139 
140  /** */
141  TTErr scaleInput();
142 
143  /** */
144  TTErr scaleOutput();
145 
146  /** Setter for mRangeClipmode attribute. */
147  TTErr setClipmode(const TTValue& value);
148 
149  /** */
150  TTErr notifyObservers(TTSymbol attrName, const TTValue& value);
151 
152  friend TTErr TTMODULAR_EXPORT TTMapperInputCreationCallback(const TTValue& baton, const TTValue& data);
153  friend TTErr TTMODULAR_EXPORT TTMapperOutputCreationCallback(const TTValue& baton, const TTValue& data);
154  friend TTErr TTMODULAR_EXPORT TTMapperInputRangeCallback(const TTValue& baton, const TTValue& data);
155  friend TTErr TTMODULAR_EXPORT TTMapperOutputRangeCallback(const TTValue& baton, const TTValue& data);
156  friend TTErr TTMODULAR_EXPORT TTMapperReceiveValueCallback(const TTValue& baton, const TTValue& data);
157 };
158 
159 typedef TTMapper* TTMapperPtr;
160 
161 /**
162  @param baton ..
163  @param data ..
164  @return an error code */
165 TTErr TTMODULAR_EXPORT TTMapperInputCreationCallback(const TTValue& baton, const TTValue& data);
166 
167 /**
168  @param baton ..
169  @param data ..
170  @return an error code */
171 TTErr TTMODULAR_EXPORT TTMapperOutputCreationCallback(const TTValue& baton, const TTValue& data);
172 
173 /**
174  @param baton ..
175  @param data ..
176  @return an error code */
177 TTErr TTMODULAR_EXPORT TTMapperInputRangeCallback(const TTValue& baton, const TTValue& data);
178 
179 /**
180  @param baton ..
181  @param data ..
182  @return an error code */
183 TTErr TTMODULAR_EXPORT TTMapperOutputRangeCallback(const TTValue& baton, const TTValue& data);
184 
185 /**
186  @param baton ..
187  @param data ..
188  @return an error code */
189 TTErr TTMODULAR_EXPORT TTMapperReceiveValueCallback(const TTValue& baton, const TTValue& data);
190 
191 #endif // __TT_MAPPER_H__
bool TTBoolean
Boolean flag, same as Boolean on the Mac.
Definition: TTBase.h:167
TTModular Library.
TTErr TTMODULAR_EXPORT TTMapperInputCreationCallback(const TTValue &baton, const TTValue &data)
Definition: TTMapper.cpp:724
TTReceiver ...
Definition: TTReceiver.h:27
The TTAddress class is used to represent a string and efficiently pass and compare that string...
Definition: TTAddress.h:29
Create and use Jamoma object instances.
Definition: TTObject.h:29
TTErr TTMODULAR_EXPORT TTMapperOutputRangeCallback(const TTValue &baton, const TTValue &data)
Definition: TTMapper.cpp:844
Base class for all first-class Jamoma objects.
Definition: TTObjectBase.h:109
double TTFloat64
64 bit floating point number
Definition: TTBase.h:188
#define TTCLASS_SETUP(className)
TODO Doxygen: need more comments here.
Definition: TTFoundation.h:54
The TTSymbol class is used to represent a string and efficiently pass and compare that string...
Definition: TTSymbol.h:26
TTErr TTMODULAR_EXPORT TTMapperOutputCreationCallback(const TTValue &baton, const TTValue &data)
Definition: TTMapper.cpp:773
TTErr TTMODULAR_EXPORT TTMapperInputRangeCallback(const TTValue &baton, const TTValue &data)
Definition: TTMapper.cpp:822
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
Definition: TTBase.h:342
TTErr TTMODULAR_EXPORT TTMapperReceiveValueCallback(const TTValue &baton, const TTValue &data)
Definition: TTMapper.cpp:866
std::uint32_t TTUInt32
32 bit unsigned integer
Definition: TTBase.h:178
TTSender ...
Definition: TTSender.h:27
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34