Jamoma API  0.6.0.a19
TTBandrejectButterworth2.h
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup dspFilterLib
4  *
5  * @brief #TTBandrejectButterworth2 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_BANDREJECT_BUTTERWORTH_2_H__
20 #define __TT_BANDREJECT_BUTTERWORTH_2_H__
21 
22 #include "TTDSP.h"
23 
24 
25 /** 2nd order Butterworth band reject 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, mA1, mA2, mB1, mB2; ///< filter coefficients.
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_BANDREJECT_BUTTERWORTH_2_H__
TTAudioObjectBase is the base class for all audio generating and processing objects in Jamoma DSP...
2nd order Butterworth band reject filter; Butterworth filters have maximum flat frequency response in...
virtual TTErr test(TTValue &returnedTestInfo)
This algorithm uses an IIR filter, meaning that it relies on feedback.
TTErr updateMaxNumChannels(const TTValue &oldMaxNumChannels, TTValue &)
Receives notifications when there are changes to the inherited mMaxNumChannels attribute.
TTSampleVector mY2
Output sample n-2.
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.
TTErr processAudio(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
Standard audio processing method as used by TTBlue objects.
TTFloat64 mFrequency
filter cutoff frequency
std::vector< TTSampleValue > TTSampleVector
A TTSampleVector is simply a pointer to the first of an array of TTSampleValues.
Definition: TTBase.h:233
TTFloat64 mB2
filter coefficients.
TTFloat64 mQ
filter resonance
TTSampleVector mX1
Input sample n-1.
A simple container for an array of TTAudioSignal pointers.
TTSampleVector mX2
Input sample n-2.
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
TTErr setFrequency(const TTValue &value)
Setter for the frequency attribute.
TTSampleVector mY1
Output sample n-1.
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34