Jamoma API  0.6.0.a19
TTBalance.h
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup dspEffectsLib
4  *
5  * @brief #TTBalance balance the gain level according to a side band signal.
6  *
7  * @details Based on an algorithm from Dodge & Jerse (1997): Computer Music -
8  Synthesis, Composition, and Performance. 2nd edition. Schirmer.@n
9  @n
10  In fact, this processor can work on a number of channels, provided that the number of input channels is twice the number of output channels. In this case the first N/2 input channels are considered as the A source and the last N/2 input channels are considered the B source.
11  *
12  * @authors Trond Lossius
13  *
14  * @copyright Copyright © 2008, Trond Lossius @n
15  * This code is licensed under the terms of the "New BSD License" @n
16  * http://creativecommons.org/licenses/BSD/
17  */
18 
19 
20 #ifndef __TT_BALANCE_H__
21 #define __TT_BALANCE_H__
22 
23 #include "TTDSP.h"
24 
25 
26 /** Use signal B to balance gain levels of signal A
27  Based on an algorithm from Dodge & Jerse (1997): Computer Music -
28  Synthesis, Composition, and Performance. 2nd edition. Schirmer.
29 
30  In fact, this processor can work on a number of channels, provided that the number of input
31  channels is twice the number of output channels. In this case the first N/2 input channels are
32  considered as the A source and the last N/2 input channels are considered the B source.
33  */
34 class TTBalance : public TTAudioObjectBase {
36 
37 protected:
38 
39  TTFloat64 mFrequency; ///< filter cutoff frequency of inherent lowpass filter
40  TTFloat64 c, a0, a1, a2, b1, b2; ///< filter coefficients
41  TTSampleVector xm1A, xm2A, ym1A, ym2A; ///< previous input and output values of signal to be balanced
42  TTSampleVector xm1B, xm2B, ym1B, ym2B; ///< previous input and output values of signal to be compared with
43 
44  /** Receives notifications when there are changes to the inherited
45  maxNumChannels attribute. This allocates memory for xm1, xm2, ym1, and ym2
46  so that each channel's previous values are remembered. */
47  TTErr updateMaxNumChannels(const TTValue& oldMaxNumChannels, TTValue&);
48 
49  /** Receives notifications when there are changes to the inherited
50  sr attribute. */
51  TTErr updateSampleRate(const TTValue& oldSampleRate, TTValue&);
52 
53  /** Standard audio processing method as used by TTBlue objects. */
55 
56  /** Setter for the frequency attribute. */
57  TTErr setFrequency(const TTValue& value);
58 
59  /** This algorithm depends on the use of an IIR filter, meaning that it relies on feedback. If the filter should
60  * not be producing any signal (such as turning audio off and then back on in a host) or if the
61  * feedback has become corrupted (such as might happen if a NaN is fed in) then it may be
62  * neccesary to clear the filter by calling this method.
63  * @return Returns a TTErr error code. */
64  TTErr clear();
65 };
66 
67 
68 #endif // __TT_BALANCE_H__
TTErr clear()
This algorithm depends on the use of an IIR filter, meaning that it relies on feedback.
Definition: TTBalance.cpp:73
Use signal B to balance gain levels of signal A Based on an algorithm from Dodge & Jerse (1997): Comp...
Definition: TTBalance.h:34
TTErr processAudio(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
Standard audio processing method as used by TTBlue objects.
Definition: TTBalance.cpp:102
TTAudioObjectBase is the base class for all audio generating and processing objects in Jamoma DSP...
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
TTErr updateMaxNumChannels(const TTValue &oldMaxNumChannels, TTValue &)
Receives notifications when there are changes to the inherited maxNumChannels attribute.
Definition: TTBalance.cpp:52
std::vector< TTSampleValue > TTSampleVector
A TTSampleVector is simply a pointer to the first of an array of TTSampleValues.
Definition: TTBase.h:233
TTErr setFrequency(const TTValue &value)
Setter for the frequency attribute.
Definition: TTBalance.cpp:87
TTSampleVector ym2B
previous input and output values of signal to be compared with
Definition: TTBalance.h:42
TTSampleVector ym2A
previous input and output values of signal to be balanced
Definition: TTBalance.h:41
A simple container for an array of TTAudioSignal pointers.
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
Definition: TTBase.h:342
TTErr updateSampleRate(const TTValue &oldSampleRate, TTValue &)
Receives notifications when there are changes to the inherited sr attribute.
Definition: TTBalance.cpp:66
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34
TTFloat64 mFrequency
filter cutoff frequency of inherent lowpass filter
Definition: TTBalance.h:39
TTFloat64 b2
filter coefficients
Definition: TTBalance.h:40