Jamoma API  0.6.0.a19
TTExpodecWindow.cpp
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup dspWindowFunctionLib
4  *
5  * @brief Expodec (Exponential Decay) Window Function Unit for Jamoma DSP
6  *
7  * @details This implements an exponential decay window that applies principles described here: @n
8  * http://en.wikipedia.org/wiki/Exponential_decay @n
9  * @n
10  * This window is intended for microsound applications as described by Roads (2001 p 88-90).
11  * Ratio variable allows this single class to produce BOTH expodec and rexpodec windows with options between.
12  * Lambda variable is set so that the quietest point in the decay will be -60 dB.
13  * @n
14  * Where 0. <= x <= 1. and 0. <= mRatio <= 1.: @n
15  * y = e^ ( ( 1 - ( x / mRatio ) ) * lambda ) : for the attack (approaching peak) @n
16  * = e^ ( ((x - mRatio) / (1 - mRatio)) * lambda ) : for the release (leaving peak)
17  *
18  * @authors Nathan Wolek, Tim Place, Trond Lossius
19  *
20  * @copyright © 2011 by Nathan Wolek @n
21  * This code is licensed under the terms of the "New BSD License" @n
22  * http://creativecommons.org/licenses/BSD/
23  */
24 
25 #include "TTExpodecWindow.h"
26 
27 #define thisTTClass ExpodecWindow
28 #define thisTTClassName "expodec"
29 #define thisTTClassTags "dspWindowFunctionLib, audio, processor, function, window"
30 
31 
32 TT_AUDIO_CONSTRUCTOR
33 {
34  // Register Attributes...
35  addAttribute(Ratio, kTypeFloat64);
36  addAttributeProperty(Ratio, range, TTValue(kTTEpsilon, 1.0)); // Avoid dividing by 0
37  addAttributeProperty(Ratio, rangeChecking, TT("clip"));
38 
39  // Set Defaults:
40  setAttributeValue(TT("ratio"), 0.);
41 
42  setProcessMethod(processAudio);
43  setCalculateMethod(calculateValue);
44 }
45 
46 
47 ExpodecWindow::~ExpodecWindow()
48 {
49  ;
50 }
51 
52 
54 {
55  TTFloat64 lambda = log(0.001); // window will begin/end at -60 dB, could eventually be controlled attribute
56 
57  if ( x <= mRatio ) { // attack portion
58 
59  y = exp( ( 1 - ( x / mRatio ) ) * lambda );
60 
61 
62  } else { // decay portion
63 
64  y = exp( ((x - mRatio) / (1 - mRatio)) * lambda );
65 
66  }
67 
68  TTLimit(y, 0.0, 1.0 ); // just in case
69 
70  return kTTErrNone;
71 }
72 
73 
75 {
76  TT_WRAP_CALCULATE_METHOD(calculateValue);
77 }
78 
TTErr calculateValue(const TTFloat64 &x, TTFloat64 &y, TTPtrSizedInt data)
Calculate y = f(x) for a single value.
Expodec (Exponential Decay) Window Function Unit for Jamoma DSP.
#define addAttribute(name, type)
A convenience macro to be used by subclasses for registering attributes with a custom getter...
Definition: TTAttribute.h:29
#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 TT
This macro is defined as a shortcut for doing a lookup in the symbol table.
Definition: TTSymbol.h:155
#define setCalculateMethod(methodName)
A convenience macro to be used by subclasses for setting the calculate method.
64-bit floating point
Definition: TTBase.h:272
#define addAttributeProperty(attributeName, propertyName, initialValue)
A convenience macro to be used for registering properties of attributes.
Definition: TTAttribute.h:68
A simple container for an array of TTAudioSignal pointers.
TTFloat64 mRatio
ratio expresses where to place the loudest sample 0 <= ratio <= 1., 0 = no attack, 1 = no release
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 processAudio(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
A standard audio processing method as used by TTBlue objects.
No Error.
Definition: TTBase.h:343
TTFOUNDATION_EXPORT const TTFloat64 kTTEpsilon
A very very small value, used for float equality comaprisments.
Definition: TTBase.cpp:31
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34