Jamoma API  0.6.0.a19
TTAllpass1c.cpp
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup dspFilterLib
4  *
5  * @brief #TTAllpass1c is a first-order building-block allpass filter.
6  *
7  * @details This allpass filter uses a fixed delay of 1 sample.
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 "TTAllpass1c.h"
18 
19 #define thisTTClass TTAllpass1c
20 #define thisTTClassName "allpass.1c"
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 TTAllpass1c::~TTAllpass1c()
43 {
44  ;
45 }
46 
47 
48 TTErr TTAllpass1c::updateMaxNumChannels(const TTValue& oldMaxNumChannels, TTValue&)
49 {
50  mX1.resize(mMaxNumChannels);
51  mY1.resize(mMaxNumChannels);
52  clear();
53  return kTTErrNone;
54 }
55 
56 
57 TTErr TTAllpass1c::clear()
58 {
59  mX1.assign(mMaxNumChannels, 0.0);
60  mY1.assign(mMaxNumChannels, 0.0);
61  return kTTErrNone;
62 }
63 
64 
65 TTErr TTAllpass1c::calculateValue(const TTFloat64& x, TTFloat64& y, TTPtrSizedInt channel)
66 {
67  y = -mX1[channel] - mAlpha * (x + mY1[channel]);
68  TTZeroDenormal(y);
69  mX1[channel] = x;
70  mY1[channel] = y;
71 
72  return kTTErrNone;
73 }
74 
75 
76 TTErr TTAllpass1c::processAudio(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
77 {
78  TT_WRAP_CALCULATE_METHOD(calculateValue);
79 }
80 
TTSampleVector mX1
previous input sample (n-1) for each channel
Definition: TTAllpass1c.h:31
TTSampleVector mY1
previous output sample (n-1) for each channel
Definition: TTAllpass1c.h:32
#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
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.
TTAllpass1c is a first-order building-block allpass filter.
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
#define addMessage(name)
A convenience macro to be used by subclasses for registering messages.
Definition: TTMessage.h:19
No Error.
Definition: TTBase.h:343
TTFloat64 mAlpha
single coefficient for the first-order allpass
Definition: TTAllpass1c.h:30
[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