Jamoma API  0.6.0.a19
TTLowpassButterworth1.h
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup dspFilterLib
4  *
5  * @brief #TTLowpassButterworth1 is a first-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_1_H__
25 #define __TT_LOWPASS_BUTTERWORTH_1_H__
26 
27 #include "TTDSP.h"
28 
29 
30 /** 1rst 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, mRadians; ///< filter coefficients
47  TTFloat64 mA0, mA1, mB1; ///< filter coefficients
48  TTSampleVector mX1; ///< Input sample n-1
49  TTSampleVector mY1; ///< Output sample n-1
50 
51  /** Receives notifications when there are changes to the inherited
52  mMaxNumChannels attribute. This allocates memory for xm1 and ym1
53  so that each channel's previous values are remembered. */
54  TTErr updateMaxNumChannels(const TTValue& oldMaxNumChannels, TTValue&);
55  TTErr updateSampleRate(const TTValue& oldSampleRate, TTValue&);
56 
57  /** This algorithm uses an IIR filter, meaning that it relies on feedback. If the filter should
58  * not be producing any signal (such as turning audio off and then back on in a host) or if the
59  * feedback has become corrupted (such as might happen if a NaN is fed in) then it may be
60  * neccesary to clear the filter by calling this method.
61  * @return Returns a TTErr error code. */
62  TTErr clear();
63 
64  void calculateCoefficients();
65 
66  /** Standard single value calculate method as used by DSP objects. */
67  inline TTErr calculateValue(const TTFloat64& x, TTFloat64& y, TTPtrSizedInt channel);
68 
69  /** Standard audio processing method as used by TTBlue objects. */
71 
72  /** Setter for the frequency attribute. */
73  TTErr setFrequency(const TTValue& value);
74 
75 
76  /** Unit Tests
77  @param returnedTestInfo Used to return test information
78  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
79  */
80  virtual TTErr test(TTValue& returnedTestInfo);
81 };
82 
83 
84 
85 #endif // __TT_LOWPASS_BUTTERWORTH_1_H__
TTErr processAudio(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
Standard audio processing method as used by TTBlue objects.
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...
virtual TTErr test(TTValue &returnedTestInfo)
Unit Tests.
Jamoma DSP Library.
double TTFloat64
64 bit floating point number
Definition: TTBase.h:188
TTErr calculateValue(const TTFloat64 &x, TTFloat64 &y, TTPtrSizedInt channel)
Standard single value calculate method as used by DSP objects.
#define TTCLASS_SETUP(className)
TODO Doxygen: need more comments here.
Definition: TTFoundation.h:54
std::vector< TTSampleValue > TTSampleVector
A TTSampleVector is simply a pointer to the first of an array of TTSampleValues.
Definition: TTBase.h:233
TTFloat64 mB1
filter coefficients
TTFloat64 mFrequency
filter cutoff frequency
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 setFrequency(const TTValue &value)
Setter for the frequency attribute.
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
Definition: TTBase.h:342
1rst order Butterworth lowpass filter; Butterworth filters have maximum flat frequency response in th...
TTErr updateMaxNumChannels(const TTValue &oldMaxNumChannels, TTValue &)
Receives notifications when there are changes to the inherited mMaxNumChannels attribute.
TTFloat64 mRadians
filter coefficients
TTSampleVector mY1
Output sample n-1.
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34