Jamoma API  0.6.0.a19
TTAllpass1b.cpp
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup dspFilterLib
4  *
5  * @brief #TTAllpass1b is a first-order building-block allpass filter.
6  *
7  * @details This allpass filter uses a fixed delay of 2 samples (M=2).
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 "TTAllpass1b.h"
18 
19 #define thisTTClass TTAllpass1b
20 #define thisTTClassName "allpass.1b"
21 #define thisTTClassTags "dspFilterLib, audio, processor, filter, allpass"
22 
23 #ifdef TT_PLATFORM_WIN
24 #include <Algorithm>
25 #endif
26 
27 TT_AUDIO_CONSTRUCTOR,
28  mAlpha(0)
29 {
30  TTChannelCount initialMaxNumChannels = arguments;
31 
32  addAttribute(Alpha, kTypeFloat64);
33 
34  addMessage(clear);
35  addUpdates(MaxNumChannels);
36 
37  setAttributeValue(kTTSym_maxNumChannels, initialMaxNumChannels);
38  setProcessMethod(processAudio);
39 }
40 
41 
42 TTAllpass1b::~TTAllpass1b()
43 {
44  ;
45 }
46 
47 
48 TTErr TTAllpass1b::updateMaxNumChannels(const TTValue& oldMaxNumChannels, TTValue&)
49 {
50  mX1.resize(mMaxNumChannels);
51  mX2.resize(mMaxNumChannels);
52  mY1.resize(mMaxNumChannels);
53  mY2.resize(mMaxNumChannels);
54  clear();
55  return kTTErrNone;
56 }
57 
58 
59 TTErr TTAllpass1b::clear()
60 {
61  mX1.assign(mMaxNumChannels, 0.0);
62  mX2.assign(mMaxNumChannels, 0.0);
63  mY2.assign(mMaxNumChannels, 0.0);
64  mY1.assign(mMaxNumChannels, 0.0);
65  return kTTErrNone;
66 }
67 
68 
69 TTErr TTAllpass1b::calculateValue(const TTFloat64& x, TTFloat64& y, TTPtrSizedInt channel)
70 {
71  y = mX2[channel] + mAlpha * (x - mY2[channel]);
72  TTZeroDenormal(y);
73  mX2[channel] = mX1[channel];
74  mY2[channel] = mY1[channel];
75  mX1[channel] = x;
76  mY1[channel] = y;
77 
78  return kTTErrNone;
79 }
80 
81 
82 TTErr TTAllpass1b::processAudio(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
83 {
84  TT_WRAP_CALCULATE_METHOD(calculateValue);
85 }
86 
#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.
#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 mAlpha
single coefficient for the first-order allpass
Definition: TTAllpass1b.h:30
TTSampleVector mX1
previous input sample (n-1) for each channel
Definition: TTAllpass1b.h:31
TTUInt16 TTChannelCount
Data type used when counting the number of channels in multi-channel audio signals and processes...
Definition: TTAudioSignal.h:31
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 mY2
previous output sample (n-2) for each channel
Definition: TTAllpass1b.h:34
TTSampleVector mY1
previous output sample (n-1) for each channel
Definition: TTAllpass1b.h:33
#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
TTSampleVector mX2
previous input sample (n-2) for each channel
Definition: TTAllpass1b.h:32
TTAllpass1b is a first-order building-block allpass filter.
#define addUpdates(updateName)
An 'update' is a message sent to a subclass instance from its parent class.
Definition: TTMessage.h:44