Jamoma API  0.6.0.a19
TTBandpassButterworth2.h
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup dspFilterLib
4  *
5  * @brief #TTBandpassButterworth2 is a second-order Butterworth bandpass 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_BANDPASS_BUTTERWORTH_2_H__
20 #define __TT_BANDPASS_BUTTERWORTH_2_H__
21 
22 #include "TTDSP.h"
23 
24 
25 /** 2nd order Butterworth bandpass 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 mQ; ///< filter resonance
36  TTFloat64 mC, mD, mBw, mA0, mA2, mB1, mB2; ///< filter coefficients. a1=0 and hence ignored
37  TTSampleVector mX1; ///< Input sample n-1
38  TTSampleVector mX2; ///< Input sample n-2
39  TTSampleVector mY1; ///< Output sample n-1
40  TTSampleVector mY2; ///< Output sample n-2
41 
42  /** Receives notifications when there are changes to the inherited
43  mMaxNumChannels attribute. This allocates memory for xm1, xm2, ym1, and ym2
44  so that each channel's previous values are remembered. */
45  TTErr updateMaxNumChannels(const TTValue& oldMaxNumChannels, TTValue&);
46  TTErr updateSampleRate(const TTValue& oldSampleRate, TTValue&);
47  TTErr clear();
48 
49  void calculateCoefficients();
50 
51  /** Standard single value calculate method as used by DSP objects. */
52  inline TTErr calculateValue(const TTFloat64& x, TTFloat64& y, TTPtrSizedInt channel);
53 
54  /** Standard audio processing method as used by TTBlue objects. */
56 
57  /** Setter for the frequency attribute. */
58  TTErr setFrequency(const TTValue& value);
59  TTErr setQ(const TTValue& value);
60  /** This algorithm uses an IIR filter, meaning that it relies on feedback. If the filter should
61  * not be producing any signal (such as turning audio off and then back on in a host) or if the
62  * feedback has become corrupted (such as might happen if a NaN is fed in) then it may be
63  * neccesary to clear the filter by calling this method.
64  * @return Returns a TTErr error code. */
65 
66 
67  /** Unit Tests
68  @param returnedTestInfo Used to return test information
69  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
70  */
71  virtual TTErr test(TTValue& returnedTestInfo);
72 };
73 
74 
75 #endif // __TT_BANDPASS_BUTTERWORTH_2_H__
virtual TTErr test(TTValue &returnedTestInfo)
This algorithm uses an IIR filter, meaning that it relies on feedback.
TTErr processAudio(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
Standard audio processing method as used by TTBlue objects.
TTAudioObjectBase is the base class for all audio generating and processing objects in Jamoma DSP...
TTFloat64 mB2
filter coefficients. a1=0 and hence ignored
TTErr setFrequency(const TTValue &value)
Setter for the frequency attribute.
TTErr calculateValue(const TTFloat64 &x, TTFloat64 &y, TTPtrSizedInt channel)
Standard single value calculate method as used by DSP objects.
Jamoma DSP Library.
2nd order Butterworth bandpass filter; Butterworth filters have maximum flat frequency response in th...
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
TTFloat64 mQ
filter resonance
std::vector< TTSampleValue > TTSampleVector
A TTSampleVector is simply a pointer to the first of an array of TTSampleValues.
Definition: TTBase.h:233
TTErr updateMaxNumChannels(const TTValue &oldMaxNumChannels, TTValue &)
Receives notifications when there are changes to the inherited mMaxNumChannels attribute.
TTFloat64 mFrequency
filter cutoff frequency
TTSampleVector mY2
Output sample n-2.
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
TTSampleVector mX2
Input sample n-2.
TTSampleVector mX1
Input sample n-1.
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34
TTSampleVector mY1
Output sample n-1.