Jamoma API  0.6.0.a19
TTHalfbandLinear33.h
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup dspFilterLib
4  *
5  * @brief #TTHalfbandLinear33 is a 33-Pole Halfband filter built up from a 2-path allpass structure.
6  *
7  * @details Same magnitude response with respect to frequency as #TTHalfband9, but with nearly linear phase response. @n
8  * @n
9  * The coefficients can be calculated using the "lineardesign_2.m" Matlab script. To generate the particular set of coefficients currently hard-coded into this filter, choose the following settings (yields a roughly -60dB stopband attenuation): @n
10  * - iterations: 100 (iterations bring the filter toward equiripple in the stopband) @n
11  * - wc = 0.2895 (this is the normalized frequency of the start of the stopband) @n
12  * - number of paths = 2 @n
13  * - number of coefficients = 8 @n
14  * @n
15  * The result is: @n
16  * @n
17  * Roots = @n
18  * @n
19  * -0.832302165608369
20  * -0.338171398434493 + 0.342959068350197i
21  * -0.338171398434493 - 0.342959068350197i
22  * -0.001794835916660 + 0.437771696086791i
23  * -0.001794835916660 - 0.437771696086791i
24  * 0.421285425003053
25  * 0.298484480776670 + 0.301855022798834i
26  * 0.298484480776670 - 0.301855022798834i
27  * @n
28  * branch 1 - type1 coefficient 0.8323021656083688 -0.4212854250030528 @n
29  * branch 1 - type2 1st coefficient 0.6763427968689864 0.003589671833320152 -0.59696896155334 @n
30  * branch 1 - type2 2nd coefficient 0.2319808172827758 0.1916472793306732 0.1802094400534031 @n
31  *
32  * The ordering of the coefficients may not be at first obvious. The first line of coefficients are the two alpha coefficients for the first two (first-order) allpass filters, F0 and F1. @n
33  * @n
34  @ The second and third lines together provide the coefficient pairs for the remaining (second-order) filters. Thus, 0.6763427968689864 and 0.2319808172827758 are the coefficient pair for the first filter 0.003589671833320152 and 0.1916472793306732 are the coefficient pair for the second filter, and so on.
35  *
36  * @authors Timothy Place, Trond Lossius
37  *
38  * @copyright Copyright © 2010, Timothy Place @n
39  * This code is licensed under the terms of the "New BSD License" @n
40  * http://creativecommons.org/licenses/BSD/
41  */
42 
43 
44 #ifndef __TT_LINEARHALFBAND33_H__
45 #define __TT_LINEARHALFBAND33_H__
46 
47 #include "TTDSP.h"
48 #include "TTAllpass1a.h"
49 #include "TTAllpass1b.h"
50 #include "TTAllpass2b.h"
51 #include "TTDelay.h"
52 
53 
54 /** A 33-pole halfband lowpass/highpass filter built-up from allpass building blocks.
55  Based on Multirate Signal Processing for Communication Systems, Chapter 10, Page 20.
56 
57  Same magnitude response with respect to frequency as TTHalfband9, but with nearly linear
58  phase response.
59 
60  The coefficients can be calculated using the "lineardesign_2.m" Matlab script.
61  To generate the particular set of coefficients currently hard-coded into this filter,
62  choose the following settings (yields a roughly -60dB stopband attenuation):
63  iterations: 100 (iterations bring the filter toward equiripple in the stopband)
64  wc = 0.2895 (this is the normalized frequency of the start of the stopband)
65  number of paths = 2
66  number of coefficients = 8
67 
68  The result is:
69  Roots =
70 
71  -0.832302165608369
72  -0.338171398434493 + 0.342959068350197i
73  -0.338171398434493 - 0.342959068350197i
74  -0.001794835916660 + 0.437771696086791i
75  -0.001794835916660 - 0.437771696086791i
76  0.421285425003053
77  0.298484480776670 + 0.301855022798834i
78  0.298484480776670 - 0.301855022798834i
79 
80  branch 1 - type1 coefficient 0.8323021656083688 -0.4212854250030528
81  branch 1 - type2 1st coefficient 0.6763427968689864 0.003589671833320152 -0.59696896155334
82  branch 1 - type2 2nd coefficient 0.2319808172827758 0.1916472793306732 0.1802094400534031
83 
84  The ordering of the coefficients may not be at first obvious. The first line of coefficients
85  are the two alpha coefficients for the first two (first-order) allpass filters, F0 and F1.
86 
87  The second and third lines together provide the coefficient pairs for the remaining (second-order)
88  filters. Thus, 0.6763427968689864 and 0.2319808172827758 are the coefficient pair for the first filter
89  0.003589671833320152 and 0.1916472793306732 are the coefficient pair for the second filter, and so on.
90  */
93 
94 protected:
95 
96  TTAudioObject mP0Delay; ///< path0, pure delay, 16 samples
97 
98  TTAudioObject mP1Delay; ///< path1
99  TTAudioObject mF0; ///< path1
100  TTAudioObject mF1; ///< path1
101  TTAudioObject mF2; ///< path1
102  TTAudioObject mF3; ///< path1
103  TTAudioObject mF4; ///< path1
104 
105  TTSymbol mMode; ///< Attribute: lowpass or highpass
106 
107  // Notifications
108  TTErr updateMaxNumChannels(const TTValue& oldMaxNumChannels, TTValue&);
109 
110  // Zero filter history
111  TTErr clear();
112 
113  // Attributes
114  TTErr setMode(const TTValue& newValue);
115 
116  // Do the processing
117  TTErr processLowpass(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs);
118  TTErr processHighpass(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs);
119 
120  inline void filterKernel(const TTFloat64& input, TTFloat64& outputPath0, TTFloat64& outputPath1, TTPtrSizedInt channel);
121 
122 
123  /** Unit Tests
124  @param returnedTestInfo Used to return test information
125  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
126  */
127  virtual TTErr test(TTValue& returnedTestInfo);
128 
129 public:
130 
131  TTErr calculateLowpass(const TTFloat64& x, TTFloat64& y, TTPtrSizedInt channel=0);
132  TTErr calculateHighpass(const TTFloat64& x, TTFloat64& y, TTPtrSizedInt channel=0);
133 
134 };
135 
136 
137 #endif // __TT_LINEARHALFBAND33_H__
TTAllpass2b is a second-order allpass filter.
TTAudioObjectBase is the base class for all audio generating and processing objects in Jamoma DSP...
TTSymbol mMode
Attribute: lowpass or highpass.
TTAudioObject mP1Delay
path1
virtual TTErr test(TTValue &returnedTestInfo)
Unit Tests.
Wrap audio objects for convenience.
TTAudioObject mF3
path1
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
TTAudioObject mF0
path1
TTAudioObject mF4
path1
The TTSymbol class is used to represent a string and efficiently pass and compare that string...
Definition: TTSymbol.h:26
TTAudioObject mF2
path1
Basic audio delay unit with 4 interpolation options.
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
TTAudioObject mF1
path1
TTAllpass1a is a first-order building-block allpass filter.
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34
A 33-pole halfband lowpass/highpass filter built-up from allpass building blocks. ...
TTAllpass1b is a first-order building-block allpass filter.
TTAudioObject mP0Delay
path0, pure delay, 16 samples