Jamoma API  0.6.0.a19
TTLowpassLinkwitzRiley2.h
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup dspFilterLib
4  *
5  * @brief #TTLowpassLinkwitzRiley2 is a second-order Linkwitz-Riley lowpass filter.
6  *
7  * @details Filter equations from: @n
8  * @n
9  * Second-order IIR Filters will support cascade implementations @n
10  * By Rusty Allred, Texas Instruments, Dallas @n
11  * July 01, 2003 @n
12  * http://www.planetanalog.com/article/printableArticle.jhtml?articleID=12802683
13  *
14  * @authors Trond Lossius, Timothy Place,
15  *
16  * @copyright Copyright © 2008, Trond Lossius @n
17  * This code is licensed under the terms of the "New BSD License" @n
18  * http://creativecommons.org/licenses/BSD/
19  */
20 
21 
22 #ifndef __TT_LOWPASS_LINKWITZ_RILEY_2_H__
23 #define __TT_LOWPASS_LINKWITZ_RILEY_2_H__
24 
25 #include "TTDSP.h"
26 
27 
28 /** 2nd order Linkwitz Riley Lowpass Filter
29  *
30  * Filter equations from
31  *
32  * Second-order IIR Filters will support cascade implementations
33  * By Rusty Allred, Texas Instruments, Dallas
34  * July 01, 2003
35  * http://www.planetanalog.com/article/printableArticle.jhtml?articleID=12802683
36  *
37  * 4th order Linkwitz-Riley filters are typically used as crossover filters, with the following properties:
38  *
39  * 1. Absolutely flat amplitude response throughout the passband with a 12 dB/octave rolloff rate after the crossover point.
40  * 2. The acoustic sum of the two driver responses is unity at crossover. (Amplitude response of each is -6 dB at crossover, i.e., there is no peaking in the summed acoustic output.)
41  * 3. Zero phase difference between drivers at crossover. (Lobing error equals zero, i.e., no tilt to the polar radiation pattern.) In addition, the phase difference of zero degrees through crossover places the lobe of the summed acoustic output on axis at all frequencies.
42  * 4. The low pass and high pass outputs are everywhere in phase. (This guarantees symmetry of the polar response about the crossover point.)
43  * 5. All drivers are always wired the same (in phase).
44  *
45  */
48 
49 protected:
50 
51  TTFloat64 mFrequency; ///< filter cutoff frequency
52  TTFloat64 mK, mRadians, mKSquared, mRadiansSquared;
53  TTFloat64 mA0, mA1, mA2; ///< filter coefficients for input samples
54  TTFloat64 mB1, mB2; ///< filter coefficients for output samples
55  TTSampleVector mX1; ///< Input sample n-1
56  TTSampleVector mX2; ///< Input sample n-2
57  TTSampleVector mY1; ///< Output sample n-1
58  TTSampleVector mY2; ///< Output sample n-2
59 
60  /** Receives notifications when there are changes to the inherited
61  mMaxNumChannels attribute. This allocates memory for xm1, xm2, ym1, and ym2
62  so that each channel's previous values are remembered. */
63  TTErr updateMaxNumChannels(const TTValue& oldMaxNumChannels, TTValue&);
64  TTErr updateSampleRate(const TTValue& oldSampleRate, TTValue&);
65 
66  /** This algorithm uses an IIR filter, meaning that it relies on feedback. If the filter should
67  * not be producing any signal (such as turning audio off and then back on in a host) or if the
68  * feedback has become corrupted (such as might happen if a NaN is fed in) then it may be
69  * neccesary to clear the filter by calling this method.
70  * @return Returns a TTErr error code. */
71  TTErr clear();
72 
73  void calculateCoefficients();
74 
75  /** Standard single value calculate method as used by DSP objects. */
76  inline TTErr calculateValue(const TTFloat64& x, TTFloat64& y, TTPtrSizedInt channel);
77 
78  /** Standard audio processing method as used by TTBlue objects. */
80 
81  /** Setter for the frequency attribute. */
82  TTErr setFrequency(const TTValue& value);
83 
84 
85  /** Unit Tests
86  @param returnedTestInfo Used to return test information
87  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
88  */
89  virtual TTErr test(TTValue& returnedTestInfo);
90 };
91 
92 
93 
94 #endif // __TT_LOWPASS_LINKWITZ_RILEY_2_H__
TTErr clear()
This algorithm uses an IIR filter, meaning that it relies on feedback.
TTFloat64 mFrequency
filter cutoff frequency
TTAudioObjectBase is the base class for all audio generating and processing objects in Jamoma DSP...
2nd order Linkwitz Riley Lowpass Filter
TTSampleVector mY2
Output sample n-2.
TTErr processAudio(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
Standard audio processing method as used by TTBlue objects.
Jamoma DSP Library.
double TTFloat64
64 bit floating point number
Definition: TTBase.h:188
TTSampleVector mX2
Input sample n-2.
TTFloat64 mB2
filter coefficients for output samples
#define TTCLASS_SETUP(className)
TODO Doxygen: need more comments here.
Definition: TTFoundation.h:54
TTSampleVector mX1
Input sample n-1.
TTErr updateMaxNumChannels(const TTValue &oldMaxNumChannels, TTValue &)
Receives notifications when there are changes to the inherited mMaxNumChannels attribute.
std::vector< TTSampleValue > TTSampleVector
A TTSampleVector is simply a pointer to the first of an array of TTSampleValues.
Definition: TTBase.h:233
virtual TTErr test(TTValue &returnedTestInfo)
Unit Tests.
TTErr setFrequency(const TTValue &value)
Setter for the frequency attribute.
A simple container for an array of TTAudioSignal pointers.
TTFloat64 mA2
filter coefficients for input samples
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 mY1
Output sample n-1.
TTErr calculateValue(const TTFloat64 &x, TTFloat64 &y, TTPtrSizedInt channel)
Standard single value calculate method as used by DSP objects.
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34