Jamoma API  0.6.0.a19
TTLowpassFunction.cpp
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup dspFunctionLib
4  *
5  * @brief #TTLowpassFunction Unit for Jamoms DSP
6  *
7  * @details
8  *
9  * @authors Tim Place, Trond Lossius
10  *
11  * @copyright Copyright © 2007 by Tim Place @n
12  * This code is licensed under the terms of the "New BSD License" @n
13  * http://creativecommons.org/licenses/BSD/
14  */
15 
16 
17 #include "TTLowpassFunction.h"
18 
19 #define thisTTClass TTLowpassFunction
20 #define thisTTClassName "lowpass"
21 #define thisTTClassTags "dspFunctionLib, audio, processor, function"
22 
23 
24 TT_AUDIO_CONSTRUCTOR,
25  mFeedback(NULL)
26 {
28  addMessage(clear);
29  addUpdates(MaxNumChannels);
30 
31  // Set Defaults...
32  setAttributeValue(kTTSym_maxNumChannels, arguments); // This attribute is inherited
33  setAttributeValue(TT("coefficient"), 0.75);
34  sendMessage(TT("clear"));
35 
36  setProcessMethod(processAudio);
37  setCalculateMethod(calculateValue);
38 }
39 
40 TTLowpassFunction::~TTLowpassFunction()
41 {
42  delete[] mFeedback;
43 }
44 
45 
46 TTErr TTLowpassFunction::updateMaxNumChannels(const TTValue& oldMaxNumChannels, TTValue&)
47 {
48  delete[] mFeedback;
49  mFeedback = new TTFloat64[mMaxNumChannels];
50  return clear();
51 }
52 
53 
54 TTErr TTLowpassFunction::clear()
55 {
56  for (TTChannelCount channel=0; channel<mMaxNumChannels; channel++)
57  mFeedback[channel] = 0.0;
58  return kTTErrNone;
59 }
60 
61 
62 TTErr TTLowpassFunction::setCoefficient(const TTValue& newValue)
63 {
64  mCoefficient = newValue;
65  mOneMinusCoefficient = 1.0 - mCoefficient;
66  return kTTErrNone;
67 }
68 
69 
70 
72 {
73  y = mFeedback[channel] = TTAntiDenormal((mFeedback[channel] * mCoefficient) + (x * mOneMinusCoefficient));
74  return kTTErrNone;
75 }
76 
77 
79 {
80  TT_WRAP_CALCULATE_METHOD(calculateValue);
81 }
82 
83 
TTChannelCount mMaxNumChannels
This is the maximum number of channels that can be guaranteed to work.
#define setProcessMethod(methodName)
A convenience macro to be used by subclasses for setting the process method.
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.
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
TTUInt16 TTChannelCount
Data type used when counting the number of channels in multi-channel audio signals and processes...
Definition: TTAudioSignal.h:31
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
#define addAttributeWithSetter(name, type)
A convenience macro to be used by subclasses for registering attributes with a custom setter...
Definition: TTAttribute.h:47
#define addMessage(name)
A convenience macro to be used by subclasses for registering messages.
Definition: TTMessage.h:19
No Error.
Definition: TTBase.h:343
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34
TTLowpassFunction Unit for Jamoms DSP
#define addUpdates(updateName)
An 'update' is a message sent to a subclass instance from its parent class.
Definition: TTMessage.h:44