Jamoma API  0.6.0.a19
TTBounceEaseInOutFunction.cpp
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup dspFunctionLib
4  *
5  * @brief #TTBounceEaseInOutFunction Unit for Jamoms DSP
6  *
7  * @details @n
8  * @n
9  * Derived from Sam Hocevar's public domain C/C++ implementation of
10  * Robert Penner easing functions
11  *
12  * @authors Trond Lossius
13  *
14  * @copyright Copyright © 2014 by Trond Lossius @n
15  * This code is licensed under the terms of the "New BSD License" @n
16  * http://creativecommons.org/licenses/BSD/
17  */
18 
19 
21 
22 #define thisTTClass TTBounceEaseInOutFunction
23 #define thisTTClassName "easeInOutBounce"
24 #define thisTTClassTags "dspFunctionLib, audio, processor, function"
25 
26 
27 TT_AUDIO_CONSTRUCTOR
28 {
29  setProcessMethod(processAudio);
30  setCalculateMethod(calculateValue);
31 }
32 
33 
34 TTBounceEaseInOutFunction::~TTBounceEaseInOutFunction()
35 {
36  ;
37 }
38 
39 
41 {
42  /*
43  if(x < 0.5)
44  {
45  y = 0.5 * BounceEaseIn(x*2);
46  }
47  else
48  {
49  y = 0.5 * BounceEaseOut(x * 2 - 1) + 0.5;
50  }
51  */
52 
53  if(x < 0.5)
54  {
55  TTFloat64 f = 1 - 2 * x;
56 
57  if (f < 4/11.0)
58  {
59  y = (121 * f * f)/16.0;
60  }
61  else if (f < 8/11.0)
62  {
63  y = (363/40.0 * f * f) - (99/10.0 * f) + 17/5.0;
64  }
65  else if (f < 9/10.0)
66  {
67  y = (4356/361.0 * f * f) - (35442/1805.0 * f) + 16061/1805.0;
68  }
69  else
70  {
71  y = (54/5.0 * f * f) - (513/25.0 * f) + 268/25.0;
72  }
73 
74  y = 0.5 * (1 - y);
75  }
76  else
77  {
78  TTFloat64 f = x * 2 - 1;
79  if (f < 4/11.0)
80  {
81  y = (121 * f * f)/16.0;
82  }
83  else if (f < 8/11.0)
84  {
85  y = (363/40.0 * f * f) - (99/10.0 * f) + 17/5.0;
86  }
87  else if (f < 9/10.0)
88  {
89  y = (4356/361.0 * f * f) - (35442/1805.0 * f) + 16061/1805.0;
90  }
91  else
92  {
93  y = (54/5.0 * f * f) - (513/25.0 * f) + 268/25.0;
94  }
95  y = 0.5 * y + 0.5;
96  }
97  return kTTErrNone;
98 }
99 
100 
102 {
103  TT_WRAP_CALCULATE_METHOD(calculateValue);
104 }
105 
TTBounceEaseInOutFunction Unit for Jamoms DSP
#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.
TTErr calculateValue(const TTFloat64 &x, TTFloat64 &y, TTPtrSizedInt data)
y = f(x) for a single value
TTErr processAudio(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
A standard audio processing method as used by TTBlue objects.
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