Jamoma API  0.6.0.a19
TTSmoothPolynomialFunction.cpp
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup dspFunctionLib
4  *
5  * @brief #TTSmoothPolynomialFunction Unit for Jamoms DSP
6  *
7  * @details This function has the following properties: @n
8  * - It ramps from 0 to 1 @n
9  * - The 1st and 2nd derivate equals 0 at x=0 and x=1, giving a smooth start and end to the ramp @n
10  * - The start and end of the ramp should be more smooth than for cosine in #TTCosineFunction, as the 2nd order derivative of cosine do not equal 0 @n
11  * - The function is symmetrical around the point x=0.5, y=0.5
12  *
13  * @authors Trond Lossius
14  *
15  * @copyright Copyright © 2011 by Trond Lossius @n
16  * This code is licensed under the terms of the "New BSD License" @n
17  * http://creativecommons.org/licenses/BSD/
18  */
19 
20 
22 #include <math.h>
23 
24 #define thisTTClass TTSmoothPolynomialFunction
25 #define thisTTClassName "smoothPolynomial"
26 #define thisTTClassTags "dspFunctionLib, audio, processor, function"
27 
28 
29 TT_AUDIO_CONSTRUCTOR
30 {
31  setProcessMethod(processAudio);
32  setCalculateMethod(calculateValue);
33 }
34 
35 
36 TTSmoothPolynomialFunction::~TTSmoothPolynomialFunction()
37 {
38  ;
39 }
40 
41 
43 {
44  //y = 6*pow(x, 5.) - 15*pow(x, 4.) + 10*pow(x, 3.0);
45 
46  // This is an optimised version of the same:
47  y = x*x*x*(x*(6*x-15)+10);
48 
49  return kTTErrNone;
50 }
51 
52 
54 {
55  TT_WRAP_CALCULATE_METHOD(calculateValue);
56 }
57 
TTErr processAudio(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
A standard audio processing method as used by TTBlue objects.
TTErr calculateValue(const TTFloat64 &x, TTFloat64 &y, TTPtrSizedInt data)
y = f(x) for a single value
#define setProcessMethod(methodName)
A convenience macro to be used by subclasses for setting the process method.
double TTFloat64
64 bit floating point number
Definition: TTBase.h:188
#define setCalculateMethod(methodName)
A convenience macro to be used by subclasses for setting the calculate method.
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
No Error.
Definition: TTBase.h:343
TTSmoothPolynomialFunction Unit for Jamoms DSP