Jamoma API  0.6.0.a19
TTLowpassButterworth2.h
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup dspFilterLib
4  *
5  * @brief #TTLowpassButterworth2 is a second-order Butterworth lowpass filter.
6  *
7  * @details Butterworth filters have maximum flat frequency response in the pass band.
8  * Based on an algorithm from Dodge & Jerse (1997): Computer Music -
9  * Synthesis, Composition, and Performance. 2nd edition. Schirmer.
10  *
11  * @authors Trond Lossius, Timothy Place,
12  *
13  * @copyright Copyright © 2008, Trond Lossius @n
14  * This code is licensed under the terms of the "New BSD License" @n
15  * http://creativecommons.org/licenses/BSD/
16  */
17 
18 
19 #ifndef __TT_LOWPASS_BUTTERWORTH_2_H__
20 #define __TT_LOWPASS_BUTTERWORTH_2_H__
21 
22 #include "TTDSP.h"
23 
24 
25 /** 2nd order Butterworth lowpass filter; Butterworth filters have maximum flat frequency response in the pass band.
26  * Based on an algorithm from Dodge & Jerse (1997): Computer Music -
27  * Synthesis, Composition, and Performance. 2nd edition. Schirmer.
28  */
31 
32 protected:
33 
34  TTFloat64 mFrequency; ///< filter cutoff frequency
35  TTFloat64 mC, mCSquared, mA0, mA1, mB1, mB2; ///< filter coefficients.
36  TTSampleVector mX1; ///< Input sample n-1
37  TTSampleVector mX2; ///< Input sample n-2
38  TTSampleVector mY1; ///< Output sample n-1
39  TTSampleVector mY2; ///< Output sample n-2
40 
41  /** Receives notifications when there are changes to the inherited
42  mMaxNumChannels attribute. This allocates memory for xm1, xm2, ym1, and ym2
43  so that each channel's previous values are remembered. */
44  TTErr updateMaxNumChannels(const TTValue& oldMaxNumChannels, TTValue&);
45  TTErr updateSampleRate(const TTValue& oldSampleRate, TTValue&);
46 
47  /** This algorithm uses an IIR filter, meaning that it relies on feedback. If the filter should
48  * not be producing any signal (such as turning audio off and then back on in a host) or if the
49  * feedback has become corrupted (such as might happen if a NaN is fed in) then it may be
50  * neccesary to clear the filter by calling this method.
51  * @return Returns a TTErr error code. */
52  TTErr clear();
53 
54  void calculateCoefficients();
55 
56  /** Standard single value calculate method as used by DSP objects. */
57  inline TTErr calculateValue(const TTFloat64& x, TTFloat64& y, TTPtrSizedInt channel);
58 
59  /** Standard audio processing method as used by TTBlue objects. */
61 
62  /** Setter for the frequency attribute. */
63  TTErr setFrequency(const TTValue& value);
64 
65 
66  /** Unit Tests
67  @param returnedTestInfo Used to return test information
68  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
69  */
70  virtual TTErr test(TTValue& returnedTestInfo);
71 };
72 
73 
74 #endif // __TT_LOWPASS_BUTTERWORTH_2_H__
2nd order Butterworth lowpass filter; Butterworth filters have maximum flat frequency response in the...
TTErr processAudio(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
Standard audio processing method as used by TTBlue objects.
TTErr calculateValue(const TTFloat64 &x, TTFloat64 &y, TTPtrSizedInt channel)
Standard single value calculate method as used by DSP objects.
TTAudioObjectBase is the base class for all audio generating and processing objects in Jamoma DSP...
TTSampleVector mX2
Input sample n-2.
Jamoma DSP Library.
TTSampleVector mY1
Output sample n-1.
double TTFloat64
64 bit floating point number
Definition: TTBase.h:188
TTErr setFrequency(const TTValue &value)
Setter for the frequency attribute.
#define TTCLASS_SETUP(className)
TODO Doxygen: need more comments here.
Definition: TTFoundation.h:54
TTSampleVector mY2
Output sample n-2.
std::vector< TTSampleValue > TTSampleVector
A TTSampleVector is simply a pointer to the first of an array of TTSampleValues.
Definition: TTBase.h:233
TTFloat64 mFrequency
filter cutoff frequency
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 mB2
filter coefficients.
TTSampleVector mX1
Input sample n-1.
TTErr updateMaxNumChannels(const TTValue &oldMaxNumChannels, TTValue &)
Receives notifications when there are changes to the inherited mMaxNumChannels attribute.
virtual TTErr test(TTValue &returnedTestInfo)
Unit Tests.
TTErr clear()
This algorithm uses an IIR filter, meaning that it relies on feedback.
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34