Jamoma API  0.6.0.a19
TTLowpassButterworth3.h
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup dspFilterLib
4  *
5  * @brief #TTLowpassButterworth3 is a third-order Butterworth lowpass filter.
6  *
7  * @details Butterworth filters have maximum flat frequency response in the pass band.
8  * @n
9  * Filter equations from: @n
10  * @n
11  * Second-order IIR Filters will support cascade implementations @n
12  * By Rusty Allred, Texas Instruments, Dallas @n
13  * July 01, 2003 @n
14  * http://www.planetanalog.com/article/printableArticle.jhtml?articleID=12802683
15  *
16  * @authors Trond Lossius, Timothy Place,
17  *
18  * @copyright Copyright © 2008, Trond Lossius @n
19  * This code is licensed under the terms of the "New BSD License" @n
20  * http://creativecommons.org/licenses/BSD/
21  */
22 
23 
24 #ifndef __TT_LOWPASS_BUTTERWORTH_3_H__
25 #define __TT_LOWPASS_BUTTERWORTH_3_H__
26 
27 #include "TTDSP.h"
28 
29 
30 /** 3rd order Butterworth lowpass filter; Butterworth filters have maximum flat frequency response in the pass band.
31  *
32  * Filter equations from:
33  *
34  * Second-order IIR Filters will support cascade implementations
35  * By Rusty Allred, Texas Instruments, Dallas
36  * July 01, 2003
37  * http://www.planetanalog.com/article/printableArticle.jhtml?articleID=12802683
38  *
39  */
42 
43 protected:
44 
45  TTFloat64 mFrequency; ///< filter cutoff frequency
46  TTFloat64 mK,mKSquared,mKCubic, mRadians, mRadiansSquared, mRadiansCubic; ///< filter coefficients
47  TTFloat64 mA0, mA1, mA2, mA3; ///< filter coefficients for input samples
48  TTFloat64 mB1, mB2, mB3; ///< filter coefficients for output samples
49  TTSampleVector mX1; ///< Input sample n-1
50  TTSampleVector mX2; ///< Input sample n-2
51  TTSampleVector mX3; ///< Input sample n-3
52  TTSampleVector mY1; ///< Output sample n-1
53  TTSampleVector mY2; ///< Output sample n-2
54  TTSampleVector mY3; ///< Output sample n-3
55 
56 
57  /** Receives notifications when there are changes to the inherited
58  mMaxNumChannels attribute. This allocates memory for xm1, xm2, ym1, and ym2
59  so that each channel's previous values are remembered. */
60  TTErr updateMaxNumChannels(const TTValue& oldMaxNumChannels, TTValue&);
61  TTErr updateSampleRate(const TTValue& oldSampleRate, TTValue&);
62 
63  /** This algorithm uses an IIR filter, meaning that it relies on feedback. If the filter should
64  * not be producing any signal (such as turning audio off and then back on in a host) or if the
65  * feedback has become corrupted (such as might happen if a NaN is fed in) then it may be
66  * neccesary to clear the filter by calling this method.
67  * @return Returns a TTErr error code. */
68  TTErr clear();
69 
70  void calculateCoefficients();
71 
72  /** Standard single value calculate method as used by DSP objects. */
73  inline TTErr calculateValue(const TTFloat64& x, TTFloat64& y, TTPtrSizedInt channel);
74 
75  /** Standard audio processing method as used by TTBlue objects. */
77 
78  /** Setter for the frequency attribute. */
79  TTErr setFrequency(const TTValue& value);
80 
81 
82  /** Unit Tests
83  @param returnedTestInfo Used to return test information
84  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
85  */
86  virtual TTErr test(TTValue& returnedTestInfo);
87 };
88 
89 
90 
91 #endif // __TT_LOWPASS_BUTTERWORTH_3_H__
TTFloat64 mB3
filter coefficients for output samples
TTErr clear()
This algorithm uses an IIR filter, meaning that it relies on feedback.
TTAudioObjectBase is the base class for all audio generating and processing objects in Jamoma DSP...
TTSampleVector mX2
Input sample n-2.
virtual TTErr test(TTValue &returnedTestInfo)
Unit Tests.
TTSampleVector mX3
Input sample n-3.
3rd order Butterworth lowpass filter; Butterworth filters have maximum flat frequency response in the...
TTErr setFrequency(const TTValue &value)
Setter for the frequency attribute.
TTSampleVector mY1
Output sample n-1.
Jamoma DSP Library.
double TTFloat64
64 bit floating point number
Definition: TTBase.h:188
#define TTCLASS_SETUP(className)
TODO Doxygen: need more comments here.
Definition: TTFoundation.h:54
TTErr calculateValue(const TTFloat64 &x, TTFloat64 &y, TTPtrSizedInt channel)
Standard single value calculate method as used by DSP objects.
TTSampleVector mY3
Output sample n-3.
std::vector< TTSampleValue > TTSampleVector
A TTSampleVector is simply a pointer to the first of an array of TTSampleValues.
Definition: TTBase.h:233
TTFloat64 mA3
filter coefficients for input samples
TTErr processAudio(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
Standard audio processing method as used by TTBlue objects.
TTErr updateMaxNumChannels(const TTValue &oldMaxNumChannels, TTValue &)
Receives notifications when there are changes to the inherited mMaxNumChannels attribute.
TTSampleVector mY2
Output sample n-2.
TTSampleVector mX1
Input sample n-1.
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 mFrequency
filter cutoff frequency
TTFloat64 mRadiansCubic
filter coefficients
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34