Jamoma API  0.6.0.a19
TTOnePole.h
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup dspFilterLib
4  *
5  * @brief #TTOnePole is a 1-pole filter.
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 #ifndef __TT_ONEPOLE_H__
18 #define __TT_ONEPOLE_H__
19 
20 #include "TTDSP.h"
21 
22 
23 /** The simplest of lowpass filters: a single-pole, no-zero algorithm. */
24 class TTOnePole : public TTAudioObjectBase {
26 
27 protected:
28 
29  TTSymbol mMode; ///< filter mode: 'lowpass' or 'highpass'
30  TTFloat64 mFrequency; ///< filter cutoff frequency
31 
32  TTFloat64 mLowpassCoefficient; ///< filter coefficients
33  TTFloat64 mOneMinusLowpassCoefficient; ///< filter coefficients
34  TTFloat64 mHighpassCoefficient; ///< filter coefficients
35  TTFloat64 mOneMinusHighpassCoefficient; ///< filter coefficients
36  TTSampleVector mFeedback; ///< previous output sample for each channel
37 
38 
39  /** Receives notifications when there are changes to the inherited
40  mMaxNumChannels attribute. */
41  TTErr updateMaxNumChannels(const TTValue& oldMaxNumChannels, TTValue&);
42 
43 
44  /** Receives notifications when there are changes to the inherited
45  sr attribute. */
46  TTErr updateSampleRate(const TTValue& oldSampleRate, TTValue&);
47 
48 
49  /** This algorithm uses an IIR filter, meaning that it relies on feedback. If the filter should
50  * not be producing any signal (such as turning audio off and then back on in a host) or if the
51  * feedback has become corrupted (such as might happen if a NaN is fed in) then it may be
52  * neccesary to clear the filter by calling this method.
53  * @return Returns a TTErr error code. */
54  TTErr clear();
55 
56 
57  /** Setter for the mode attribute.
58  This also sets the audio processing method. */
59  TTErr setMode(const TTValue& value);
60 
61  /** Setter for the frequency attribute. */
62  TTErr setFrequency(const TTValue& value);
63  TTErr setCoefficient(const TTValue& newValue);
64  TTErr getCoefficient(TTValue& returnedValue);
65 
66 
67  // Single-sample Value Calculation Methods
68  inline TTErr calculateLowpass(const TTFloat64& x, TTFloat64& y, TTPtrSizedInt channel);
69  inline TTErr calculateHighpass(const TTFloat64& x, TTFloat64& y, TTPtrSizedInt channel);
70 
71 
72  // Block-based Audio Processing Methods
73  TTErr processLowpass(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs);
74  TTErr processHighpass(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs);
75 
76 
77  /** Unit Tests
78  @param returnedTestInfo Used to return test information
79  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
80  */
81  virtual TTErr test(TTValue& returnedTestInfo);
82 };
83 
84 
85 #endif // __TT_ONEPOLE_H__
The simplest of lowpass filters: a single-pole, no-zero algorithm.
Definition: TTOnePole.h:24
TTAudioObjectBase is the base class for all audio generating and processing objects in Jamoma DSP...
TTFloat64 mHighpassCoefficient
filter coefficients
Definition: TTOnePole.h:34
TTFloat64 mFrequency
filter cutoff frequency
Definition: TTOnePole.h:30
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.
std::vector< TTSampleValue > TTSampleVector
A TTSampleVector is simply a pointer to the first of an array of TTSampleValues.
Definition: TTBase.h:233
The TTSymbol class is used to represent a string and efficiently pass and compare that string...
Definition: TTSymbol.h:26
TTErr updateSampleRate(const TTValue &oldSampleRate, TTValue &)
Receives notifications when there are changes to the inherited sr attribute.
Definition: TTOnePole.cpp:67
TTErr updateMaxNumChannels(const TTValue &oldMaxNumChannels, TTValue &)
Receives notifications when there are changes to the inherited mMaxNumChannels attribute.
Definition: TTOnePole.cpp:59
TTErr setFrequency(const TTValue &value)
Setter for the frequency attribute.
Definition: TTOnePole.cpp:105
TTFloat64 mLowpassCoefficient
filter coefficients
Definition: TTOnePole.h:32
A simple container for an array of TTAudioSignal pointers.
TTSampleVector mFeedback
previous output sample for each channel
Definition: TTOnePole.h:36
TTErr clear()
This algorithm uses an IIR filter, meaning that it relies on feedback.
Definition: TTOnePole.cpp:74
long TTPtrSizedInt
An integer that is the same size as a pointer.
Definition: TTBase.h:240
TTFloat64 mOneMinusHighpassCoefficient
filter coefficients
Definition: TTOnePole.h:35
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
Definition: TTBase.h:342
TTSymbol mMode
filter mode: 'lowpass' or 'highpass'
Definition: TTOnePole.h:29
TTErr setMode(const TTValue &value)
Setter for the mode attribute.
Definition: TTOnePole.cpp:83
TTFloat64 mOneMinusLowpassCoefficient
filter coefficients
Definition: TTOnePole.h:33
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34