Jamoma API  0.6.0.a19
TTGaussWindow.cpp
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup dspWindowFunctionLib
4  *
5  * @brief Gauss Window Function Unit for Jamoma DSP
6  *
7  * @details This implements the Gauss window function described here: @n
8  http://en.wikipedia.org/wiki/File:Window_function_(gauss).png @n
9  Be aware that when higher values are used for mSigma, minimum sample value will approach -17 dB @n
10  @n
11  Where 0. <= x <= 1. and 0. <= mSigma <= 0.5: @n
12  superscript = -0.5 * ( ( (2 * x) - 1 ) / mSigma )^2 @n
13  y = e^ superscript @n
14  *
15  * @authors Nathan Wolek, Tim Place, Trond Lossius
16  *
17  * @copyright © 2011 by Nathan Wolek @n
18  * This code is licensed under the terms of the "New BSD License" @n
19  * http://creativecommons.org/licenses/BSD/
20  */
21 
22 #include "TTGaussWindow.h"
23 
24 #define thisTTClass GaussWindow
25 #define thisTTClassName "gauss"
26 #define thisTTClassTags "dspWindowFunctionLib, audio, processor, function, window"
27 
28 
29 TT_AUDIO_CONSTRUCTOR
30 {
31  // Register Attributes...
32  addAttribute(Sigma, kTypeFloat64);
33  addAttributeProperty(Sigma, range, TTValue(kTTEpsilon, 0.5)); // Avoid dividing by 0
34  addAttributeProperty(Sigma, rangeChecking, TT("clip"));
35 
36  // Set Defaults:
37  setAttributeValue(TT("sigma"), 0.4);
38 
39  setProcessMethod(processAudio);
40  setCalculateMethod(calculateValue);
41 
42 }
43 
44 GaussWindow::~GaussWindow()
45 {
46  ;
47 }
48 
50 {
51  TTFloat64 superscript = -0.5 * pow( ( (2. * x) - 1. ) / mSigma, 2 );
52 
53  y = exp(superscript);
54 
55  TTLimit(y, 0.0, 1.0 ); // just in case
56 
57  return kTTErrNone;
58 }
59 
61 {
62  TT_WRAP_CALCULATE_METHOD(calculateValue);
63 }
TTErr processAudio(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
A standard audio processing method as used by TTBlue objects.
#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
Gauss Window Function Unit for Jamoma DSP.
#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.
TTErr calculateValue(const TTFloat64 &x, TTFloat64 &y, TTPtrSizedInt data)
Calculate y = f(x) for a single value.
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.
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
TTFloat64 mSigma
sigma effects the width of the Gaussion window. 0. <= sigma <= 0.5
Definition: TTGaussWindow.h:42
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