Jamoma API  0.6.0.a19
TTOperator.h
1 /*
2  * Jamoma DSP Operator Object
3  * Copyright © 2008, Timothy Place
4  *
5  * License: This code is licensed under the terms of the "New BSD License"
6  * http://creativecommons.org/licenses/BSD/
7  */
8 
9 #ifndef __TT_OPERATOR_H__
10 #define __TT_OPERATOR_H__
11 
12 #include "TTDSP.h"
13 
14 
15 /** TTOperator performs basic mathematical operations on an input signal, or a pair of input signals */
18 
19 protected:
20 
21  TTSymbol mOperator; ///< The type of calculation to perform
22  TTFloat64 mOperand; ///< The right-hand value of the calculation
23  TTBoolean mOperandIsInteger; ///< Set to true if there is no fractional part
24  TTBoolean mOperandIsPowerOfTwo; ///< Set to true is the operand is a power of two to optimize some operations
25 
26 
27  TTErr calculateAdd(const TTFloat64& x, TTFloat64& y, TTPtrSizedInt data);
28  TTErr calculateSubtract(const TTFloat64& x, TTFloat64& y, TTPtrSizedInt data);
29  TTErr calculateMultiply(const TTFloat64& x, TTFloat64& y, TTPtrSizedInt data);
30  TTErr calculateDivide(const TTFloat64& x, TTFloat64& y, TTPtrSizedInt data);
31  TTErr calculateModulo(const TTFloat64& x, TTFloat64& y, TTPtrSizedInt data);
32  TTErr calculateSqrt(const TTFloat64& x, TTFloat64& y, TTPtrSizedInt data);
33  TTErr calculateFabs(const TTFloat64& x, TTFloat64& y, TTPtrSizedInt data);
34  TTErr calculateEqual(const TTFloat64& x, TTFloat64& y, TTPtrSizedInt data);
35  TTErr calculateNotEqual(const TTFloat64& x, TTFloat64& y, TTPtrSizedInt data);
36  TTErr calculateGreaterEqual(const TTFloat64& x, TTFloat64& y, TTPtrSizedInt data);
37  TTErr calculateGreater(const TTFloat64& x, TTFloat64& y, TTPtrSizedInt data);
38  TTErr calculateSmallerEqual(const TTFloat64& x, TTFloat64& y, TTPtrSizedInt data);
39  TTErr calculateSmaller(const TTFloat64& x, TTFloat64& y, TTPtrSizedInt data);
40 
41  /** A standard audio processing method as used by TTBlue objects. */
43  TTErr processAddSignal (TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs);
44 
45  TTErr processSubtract (TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs);
46  TTErr processSubtractSignal (TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs);
47 
48  TTErr processMultiply (TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs);
49  TTErr processMultiplySignal (TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs);
50 
51  TTErr processDivide (TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs);
52  TTErr processDivideSignal (TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs);
53 
54  TTErr processModulo (TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs);
55  TTErr processModuloSignal (TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs);
56 
57  TTErr processSqrt (TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs);
58 
59  TTErr processFabs (TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs);
60 
61  TTErr processEqual (TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs);
62  TTErr processEqualSignal (TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs);
63 
64  TTErr processNotEqual (TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs);
65  TTErr processNotEqualSignal (TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs);
66 
67  TTErr processGreater (TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs);
68  TTErr processGreaterSignal (TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs);
69 
70  TTErr processGreaterEqual (TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs);
71  TTErr processGreaterEqualSignal (TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs);
72 
73  TTErr processSmaller (TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs);
74  TTErr processSmallerSignal (TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs);
75 
76  TTErr processSmallerEqual (TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs);
77  TTErr processSmallerEqualSignal (TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs);
78 
79 #define WRAP_C_FUNCTION_AS_TTOp_METHODS(cName, methodName) \
80  TTErr calculate ## methodName (const TTFloat64& x, TTFloat64& y, TTPtrSizedInt data)\
81  {\
82  y = cName (x);\
83  return kTTErrNone;\
84  }\
85  \
86  TTErr process ## methodName (TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)\
87  {\
88  TT_WRAP_CALCULATE_METHOD(calculateFabs);\
89  }\
90 
91  WRAP_C_FUNCTION_AS_TTOp_METHODS(acos, Acos)
92  WRAP_C_FUNCTION_AS_TTOp_METHODS(asin, Asin)
93  WRAP_C_FUNCTION_AS_TTOp_METHODS(atan, Atan)
94  //WRAP_C_FUNCTION_AS_TTOp_METHODS(atan2, Atan2) // TODO: this one requires 2 args
95  WRAP_C_FUNCTION_AS_TTOp_METHODS(ceil, Ceil)
96  WRAP_C_FUNCTION_AS_TTOp_METHODS(cos, Cos)
97  WRAP_C_FUNCTION_AS_TTOp_METHODS(cosh, Cosh)
98  WRAP_C_FUNCTION_AS_TTOp_METHODS(exp, Exp)
99  WRAP_C_FUNCTION_AS_TTOp_METHODS(floor, Floor)
100  WRAP_C_FUNCTION_AS_TTOp_METHODS(log, Log)
101  WRAP_C_FUNCTION_AS_TTOp_METHODS(log10, Log10)
102  WRAP_C_FUNCTION_AS_TTOp_METHODS(sin, Sin)
103  WRAP_C_FUNCTION_AS_TTOp_METHODS(sinh, Sinh)
104  WRAP_C_FUNCTION_AS_TTOp_METHODS(tan, Tan)
105  WRAP_C_FUNCTION_AS_TTOp_METHODS(tanh, Tanh)
106 
107 
108 public:
109 
110  /** setter for the operator attribute. */
111  TTErr setOperator(const TTValue& newValue);
112 
113  /** setter for the operand attribute. */
114  TTErr setOperand(const TTValue& newValue);
115 };
116 
117 
118 #endif // __TT_OPERATOR_H__
bool TTBoolean
Boolean flag, same as Boolean on the Mac.
Definition: TTBase.h:167
TTSymbol mOperator
The type of calculation to perform.
Definition: TTOperator.h:21
TTOperator performs basic mathematical operations on an input signal, or a pair of input signals...
Definition: TTOperator.h:16
TTAudioObjectBase is the base class for all audio generating and processing objects in Jamoma DSP...
Jamoma DSP Library.
TTBoolean mOperandIsInteger
Set to true if there is no fractional part.
Definition: TTOperator.h:23
double TTFloat64
64 bit floating point number
Definition: TTBase.h:188
TTErr processAdd(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
A standard audio processing method as used by TTBlue objects.
Definition: TTOperator.cpp:191
#define TTCLASS_SETUP(className)
TODO Doxygen: need more comments here.
Definition: TTFoundation.h:54
TTErr setOperator(const TTValue &newValue)
setter for the operator attribute.
Definition: TTOperator.cpp:33
TTBoolean mOperandIsPowerOfTwo
Set to true is the operand is a power of two to optimize some operations.
Definition: TTOperator.h:24
The TTSymbol class is used to represent a string and efficiently pass and compare that string...
Definition: TTSymbol.h:26
TTFloat64 mOperand
The right-hand value of the calculation.
Definition: TTOperator.h:22
A simple container for an array of TTAudioSignal pointers.
long TTPtrSizedInt
An integer that is the same size as a pointer.
Definition: TTBase.h:240
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
Definition: TTBase.h:342
TTErr setOperand(const TTValue &newValue)
setter for the operand attribute.
Definition: TTOperator.cpp:116
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34