Jamoma API  0.6.0.a19
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup dspFilterLib
4  *
5  * @brief #TTSvf is a state variable filter object
6  *
7  * @details
8  *
9  * @authors Timothy Place, Trond Lossius
10  *
11  * @copyright Copyright © 2008, Timothy Place @n
12  * This code is licensed under the terms of the "New BSD License" @n
13  * http://creativecommons.org/licenses/BSD/
14  */
17 #ifndef __TT_SVF_H__
18 #define __TT_SVF_H__
20 #include "TTDSP.h"
23 /** A State Variable Filter object.
24  One of the features of a state variable filter is that it can provide all 4 filter types
25  simultaneously from the same algorithm.
27  This implementation takes a different approach which requires the selection of one of the types.
28  At some point in the future we could add a mode to get all 4 signals out of the output...
29  */
30 class TTSvf : public TTAudioObjectBase {
33 protected:
35  TTFloat64 mFrequency; ///< filter cutoff frequency
36  TTFloat64 mResonance; ///< filter resonance -- range is best between 1.0 and 16.0
37  TTSymbol mMode; ///< lowpass, highpass, bandpass, notch, or peak
38  TTFloat64 mF, mR, mDamp; // coefficients
39  TTSampleVector mLowpass_output; // feedback storage...
40  TTSampleVector mHighpass_output;
41  TTSampleVector mBandpass_output;
42  TTSampleVector mNotch_output;
43  TTSampleVector mPeak_output;
45  // Notifications
46  TTErr updateMaxNumChannels(const TTValue& oldMaxNumChannels, TTValue&);
47  TTErr updateSampleRate(const TTValue& oldSampleRate, TTValue&);
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();
56  void calculateCoefficients();
58  /** Audio processing methods. */
60  TTErr processHighpass(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs);
61  TTErr processBandpass(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs);
62  TTErr processNotch(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs);
63  TTErr processPeak(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs);
65  inline TTErr calculateLowpass(const TTFloat64& x, TTFloat64& y, TTPtrSizedInt channel);
66  inline TTErr calculateHighpass(const TTFloat64& x, TTFloat64& y, TTPtrSizedInt channel);
67  inline TTErr calculateBandpass(const TTFloat64& x, TTFloat64& y, TTPtrSizedInt channel);
68  inline TTErr calculateNotch(const TTFloat64& x, TTFloat64& y, TTPtrSizedInt channel);
69  inline TTErr calculatePeak(const TTFloat64& x, TTFloat64& y, TTPtrSizedInt channel);
71  // Attributes
72  TTErr setMode(const TTValue& newValue);
73  TTErr setFrequency(const TTValue& newValue);
74  TTErr setResonance(const TTValue& newValue);
76  /** Performs the actual SVF calculations. */
77  void tick(TTSampleValue value, TTChannelCount channel);
80  /** Unit Tests
81  @param returnedTestInfo Used to return test information
82  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
83  */
84  virtual TTErr test(TTValue& returnedTestInfo);
85 };
88 #endif // __TT_SVF_H__
TTAudioObjectBase is the base class for all audio generating and processing objects in Jamoma DSP...
TTErr processLowpass(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
Audio processing methods.
Definition: TTSvf.cpp:189
TTSymbol mMode
lowpass, highpass, bandpass, notch, or peak
Definition: TTSvf.h:37
A State Variable Filter object.
Definition: TTSvf.h:30
TTErr clear()
This algorithm uses an IIR filter, meaning that it relies on feedback.
Definition: TTSvf.cpp:75
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
void tick(TTSampleValue value, TTChannelCount channel)
Performs the actual SVF calculations.
Definition: TTSvf.cpp:154
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
virtual TTErr test(TTValue &returnedTestInfo)
Unit Tests.
Definition: TTSvf.test.cpp:20
TTUInt16 TTChannelCount
Data type used when counting the number of channels in multi-channel audio signals and processes...
Definition: TTAudioSignal.h:31
TTFloat64 mFrequency
filter cutoff frequency
Definition: TTSvf.h:35
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
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
Definition: TTBase.h:342
TTFloat64 TTSampleValue
A value representing a single audio sample.
Definition: TTBase.h:230
Definition: TTValue.h:34
TTFloat64 mResonance
filter resonance – range is best between 1.0 and 16.0
Definition: TTSvf.h:36