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