Jamoma API  0.6.0.a19
TTAllpass1aCascade2.cpp
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup dspFilterLib
4  *
5  * @brief #TTAllpass1aCascade2 is a first-order filter cascade
6  *
7  * @details
8  *
9  * @authors Timothy Place, Trond Lossius
10  *
11  * @copyright Copyright © 2010, Timothy Place @n
12  * This code is licensed under the terms of the "New BSD License" @n
13  * http://creativecommons.org/licenses/BSD/
14  */
15 
16 
17 #include "TTAllpass1aCascade2.h"
18 
19 #define thisTTClass TTAllpass1aCascade2
20 #define thisTTClassName "allpass.1a.cascade2"
21 #define thisTTClassTags "dspFilterLib, audio, processor, filter, allpass, cascade"
22 
23 #ifdef TT_PLATFORM_WIN
24 #include <Algorithm>
25 #endif
26 
27 TT_AUDIO_CONSTRUCTOR,
28  mAlpha0(0),
29  mAlpha1(0)
30 {
31  TTChannelCount initialMaxNumChannels = arguments;
32 
33  addAttribute(Alpha0, kTypeFloat64);
34  addAttribute(Alpha1, kTypeFloat64);
35 
36  addMessage(clear);
37  addUpdates(MaxNumChannels);
38 
39  setAttributeValue(kTTSym_maxNumChannels, initialMaxNumChannels);
40  setProcessMethod(processAudio);
41 }
42 
43 
44 TTAllpass1aCascade2::~TTAllpass1aCascade2()
45 {
46  ;
47 }
48 
49 
50 TTErr TTAllpass1aCascade2::updateMaxNumChannels(const TTValue& oldMaxNumChannels, TTValue&)
51 {
52  mX1.resize(mMaxNumChannels);
53  mD2.resize(mMaxNumChannels);
54  mY1.resize(mMaxNumChannels);
55  clear();
56  return kTTErrNone;
57 }
58 
59 
60 TTErr TTAllpass1aCascade2::clear()
61 {
62  mX1.assign(mMaxNumChannels, 0.0);
63  mD2.assign(mMaxNumChannels, 0.0);
64  mY1.assign(mMaxNumChannels, 0.0);
65  return kTTErrNone;
66 }
67 
68 
69 TTErr TTAllpass1aCascade2::calculateValue(const TTFloat64& x, TTFloat64& y, TTPtrSizedInt channel)
70 {
71  TTFloat64 p;
72 
73  p = mX1[channel] + mAlpha0 * (x - mD2[channel]);
74  y = mD2[channel] + mAlpha1 * (p - mY1[channel]);
75 
76  TTZeroDenormal(y);
77  TTZeroDenormal(p);
78  mY1[channel] = y;
79  mD2[channel] = p;
80  mX1[channel] = x;
81 
82  return kTTErrNone;
83 }
84 
85 
86 TTErr TTAllpass1aCascade2::processAudio(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
87 {
88  TT_WRAP_CALCULATE_METHOD(calculateValue);
89 }
90 
TTSampleVector mX1
previous input sample (n-1) for each channel of the cascade
TTAllpass1aCascade2 is a first-order filter cascade
#define addAttribute(name, type)
A convenience macro to be used by subclasses for registering attributes with a custom getter...
Definition: TTAttribute.h:29
TTChannelCount mMaxNumChannels
This is the maximum number of channels that can be guaranteed to work.
TTSampleVector mY1
previous output sample (n-1) for each channel of the cascade
#define setProcessMethod(methodName)
A convenience macro to be used by subclasses for setting the process method.
double TTFloat64
64 bit floating point number
Definition: TTBase.h:188
64-bit floating point
Definition: TTBase.h:272
TTFloat64 mAlpha1
coefficient for filter 1
TTUInt16 TTChannelCount
Data type used when counting the number of channels in multi-channel audio signals and processes...
Definition: TTAudioSignal.h:31
TTSampleVector mD2
previous output sample for each channel of the first stage, and previous input sample for each channe...
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 mAlpha0
coefficient for filter 0
#define addMessage(name)
A convenience macro to be used by subclasses for registering messages.
Definition: TTMessage.h:19
No Error.
Definition: TTBase.h:343
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34
#define addUpdates(updateName)
An 'update' is a message sent to a subclass instance from its parent class.
Definition: TTMessage.h:44