Jamoma API  0.6.0.a19
TTMixer.h
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup dspMathLib
4  *
5  * @brief #TTMixer is a Jamoma DSP Audio Mixer Object
6  *
7  * @details
8  *
9  * @authors Tim Place, Nathan Wolek, 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_MIXER_H__
18 #define __TT_MIXER_H__
19 
20 #include "TTDSP.h"
21 
22 
23 /** TTMixer mixes N input channels of a signal to M output channels of a signal. */
26 
27 protected:
28 
29  TTMatrix mGainMatrix; ///< A NxM matrix of mixing coefficients.
30  TTBoolean mInterpolated; ///< A flag determine if we will be interpolating towards new matrix values whenever a gain value is being updated.
31  TTMatrix oldGainMatrix; ///< Required for the process of resizing when changing the number of inputs or outputs.
32  TTMatrix tempGainMatrix; ///< Required for the process of resizing when changing the number of inputs or outputs.
33  TTChannelCount mNumInputs; ///< The number of audio inputs.
34  TTChannelCount mNumOutputs; ///< The number of audio outputs.
35 
36  ///// Attributes ///
37 
38  /** Set the number of audio input channels to the mixer.
39  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
40  */
41  TTErr setNumInputs(const TTValue& newValue);
42 
43 
44  /** Set the number of audio output channels from the mixer.
45  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
46  */
47  TTErr setNumOutputs(const TTValue& newValue);
48 
49 
50  /** Check what the current mixer size is.
51  @param x The current number of audio input signals
52  @param y The current number of audio output signals
53  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
54  */
56 
57  //TTErr setInterpolated(const TTValue& newValue);
58 
59 
60  ///// Messages /////
61 
62  /** Clear the matrix by setting all gain coefficients to 0.
63  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
64  */
65  TTErr clear();
66 
67 
68  /** Restore matrix coefficients.
69  @details This method is used when the matrix is being resized.
70  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
71  */
73 
74 
75  /** Set the gain as desibel for one inlet to one outlet.
76  @param newValue An array of three values is expected:
77  -# The audio inlet.
78  -# The audio outlet.
79  -# New gain value in desibel for this inlet-outlet pair
80  @param
81  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
82  */
83  TTErr setGain(const TTValue& newValue, TTValue&);
84 
85 
86  /** Set the gain as linear amplitude for one inlet to one outlet.
87  @param newValue An array of three values is expected:
88  -# The audio inlet.
89  -# The audio outlet.
90  -# New gain value as linear amplitude for this inlet-outlet pair
91  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
92  */
93  TTErr setLinearGain(const TTValue& newValue, TTValue&);
94 
95 
96  /** Set the gain as midi value for one inlet to one outlet.
97  @param newValue An array of three values is expected:
98  -# The audio inlet.
99  -# The audio outlet.
100  -# New gain value as MIDI value for this inlet-outlet pair
101  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
102  */
103  TTErr setMidiGain(const TTValue& newValue, TTValue&);
104 
105  ///// Audio /////
106 
107  /** Process audio.
108  @details This version of the processing method is the simpler and more efficient. It will be used
109  whenever no gain values have been recently changes. If the #mInterpolated flag is NOT set,
110  it will also be used when gain coefficients change. This saves CPU as compared to the more expensive
111  #processAudioInterpolated method, but at the risk of audible clicks and discontinuities.
112  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
113  */
115 
116 
117  /** Process audio with interpolation.
118  @details If a gain coefficient has been updated, and the #mInterpolated flag is set,
119  this method will be used for the next vector to be processed, and will ensure that matrix coefficients
120  ramp (interpolate) to their new values over the duration of the next vector.
121  Upon completion, this unit will be set to use the simpler and more efficient #processAudio method again,
122  until next time a matrix gain coefficient is changed.
123  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
124  */
126 };
127 
128 
129 #endif // __TT_MIXER_H__
bool TTBoolean
Boolean flag, same as Boolean on the Mac.
Definition: TTBase.h:167
TTErr setNumOutputs(const TTValue &newValue)
Set the number of audio output channels from the mixer.
Definition: TTMixer.cpp:82
TTAudioObjectBase is the base class for all audio generating and processing objects in Jamoma DSP...
TTBoolean mInterpolated
A flag determine if we will be interpolating towards new matrix values whenever a gain value is being...
Definition: TTMixer.h:30
TTErr setLinearGain(const TTValue &newValue, TTValue &)
Set the gain as linear amplitude for one inlet to one outlet.
Definition: TTMixer.cpp:167
TTMatrix oldGainMatrix
Required for the process of resizing when changing the number of inputs or outputs.
Definition: TTMixer.h:31
Jamoma DSP Library.
TTErr restoreMatrix()
Restore matrix coefficients.
Definition: TTMixer.cpp:98
#define TTCLASS_SETUP(className)
TODO Doxygen: need more comments here.
Definition: TTFoundation.h:54
TTErr checkMatrixSize(const TTChannelCount x, const TTChannelCount y)
Check what the current mixer size is.
Definition: TTMixer.cpp:126
TTMatrix mGainMatrix
A NxM matrix of mixing coefficients.
Definition: TTMixer.h:29
TTUInt16 TTChannelCount
Data type used when counting the number of channels in multi-channel audio signals and processes...
Definition: TTAudioSignal.h:31
Wrap TTMatrixBase instances.
Definition: TTMatrix.h:27
A simple container for an array of TTAudioSignal pointers.
TTChannelCount mNumInputs
The number of audio inputs.
Definition: TTMixer.h:33
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
Definition: TTBase.h:342
TTErr processAudioInterpolated(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
Process audio with interpolation.
Definition: TTMixer.cpp:257
TTChannelCount mNumOutputs
The number of audio outputs.
Definition: TTMixer.h:34
TTErr setGain(const TTValue &newValue, TTValue &)
Set the gain as desibel for one inlet to one outlet.
Definition: TTMixer.cpp:144
TTErr processAudio(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
Process audio.
Definition: TTMixer.cpp:212
TTErr setNumInputs(const TTValue &newValue)
Set the number of audio input channels to the mixer.
Definition: TTMixer.cpp:65
TTErr clear()
Clear the matrix by setting all gain coefficients to 0.
Definition: TTMixer.cpp:119
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34
TTMixer mixes N input channels of a signal to M output channels of a signal.
Definition: TTMixer.h:24
TTMatrix tempGainMatrix
Required for the process of resizing when changing the number of inputs or outputs.
Definition: TTMixer.h:32
TTErr setMidiGain(const TTValue &newValue, TTValue &)
Set the gain as midi value for one inlet to one outlet.
Definition: TTMixer.cpp:189