Jamoma API  0.6.0.a19
TTAllpass2c.h
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup dspFilterLib
4  *
5  * @brief #TTAllpass2c is a second-order building-block allpass filter.
6  *
7  * @details Essentially the same as #TTAllpass2a, but with some signs flipped.
8  * Based on Fredric J. Harris (2004): Multirate Signal Processing for Communication Systems, Prentice Hall, Chapter 10, Figure 43. @n
9  * @n
10  * Difference equation: @n
11  * @code
12  * y(n) = -e_2 x(n) - e_1 x(n-1) - x(n-2 - e_1 y(n-1) - e_2 y(n-2)
13  * @endcode
14  *
15  * Transfer function: @n
16  *
17  * @code
18  * -e_2 - e_1 Z^(-1) - Z^(-2)
19  * H(Z) = ---------------------------------
20  * 1 + e_1 Z^(-1) + e_2 Z^(-2)
21  * @endcode
22  *
23  * @authors Timothy Place, Trond Lossius
24  *
25  * @copyright Copyright © 2010, Timothy Place @n
26  * This code is licensed under the terms of the "New BSD License" @n
27  * http://creativecommons.org/licenses/BSD/
28  */
29 
30 
31 #ifndef __TT_ALLPASS2C_H__
32 #define __TT_ALLPASS2C_H__
33 
34 #include "TTDSP.h"
35 
36 
37 /** A second-order building-block allpass filter.
38  Essentially the same as TTAllpass2a, but with some signs flipped.
39  Based on Multirate Signal Processing for Communication Systems, Chapter 10, Figure 43.
40 
41  difference equation:
42  y(n) = -e_2 x(n) - e_1 x(n-1) - x(n-2 - e_1 y(n-1) - e_2 y(n-2)
43 
44  transfer function:
45  -e_2 - e_1 Z^(-1) - Z^(-2)
46  H(Z) = ---------------------------------
47  1 + e_1 Z^(-1) + e_2 Z^(-2)
48  */
51 
52 protected:
53 
54  TTFloat64 mE1; ///< first coefficient
55  TTFloat64 mE2; ///< second coefficient
56 
57  TTSampleVector mX1; ///< previous input sample (n-1) for each channel
58  TTSampleVector mX2; ///< previous input sample (n-2) for each channel
59  TTSampleVector mY1; ///< previous output sample (n-1) for each channel
60  TTSampleVector mY2; ///< previous output sample (n-2) for each channel
61 
62  // Notifications
63  TTErr updateMaxNumChannels(const TTValue& oldMaxNumChannels, TTValue&);
64 
65  // Zero filter history
66  TTErr clear();
67 
68  // Do the processing
69  TTErr processAudio(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs);
70 
71  /** Unit Tests
72  @param returnedTestInfo Used to return test information
73  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
74  */
75  virtual TTErr test(TTValue& returnedTestInfo);
76 
77 public:
78  TTErr calculateValue(const TTFloat64& x, TTFloat64& y, TTPtrSizedInt channel=0);
79 };
80 
81 
82 #endif // __TT_ALLPASS2A_H__
TTSampleVector mY2
previous output sample (n-2) for each channel
Definition: TTAllpass2c.h:60
TTFloat64 mE1
first coefficient
Definition: TTAllpass2c.h:54
TTAudioObjectBase is the base class for all audio generating and processing objects in Jamoma DSP...
TTFloat64 mE2
second coefficient
Definition: TTAllpass2c.h:55
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
virtual TTErr test(TTValue &returnedTestInfo)
Unit Tests.
TTSampleVector mX1
previous input sample (n-1) for each channel
Definition: TTAllpass2c.h:57
std::vector< TTSampleValue > TTSampleVector
A TTSampleVector is simply a pointer to the first of an array of TTSampleValues.
Definition: TTBase.h:233
A second-order building-block allpass filter.
Definition: TTAllpass2c.h:49
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
TTSampleVector mY1
previous output sample (n-1) for each channel
Definition: TTAllpass2c.h:59
TTSampleVector mX2
previous input sample (n-2) for each channel
Definition: TTAllpass2c.h:58
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34