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