Jamoma API  0.6.0.a19
TTAudioGraphJoin.h
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup audioGraphUtilityLib
4  *
5  * @brief join≈: merge multichannel signals
6  *
7  * @details
8  *
9  * @authors Timothy Place
10  *
11  * @copyright Copyright © 2008 by 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_JOIN_H__
18 #define __TT_JOIN_H__
19 
20 #include "TTDSP.h"
21 
22 
23 /** The join≈ object takes N input signals and combines them
24  into a single signal with all of the channels present.
25  */
28 
29 protected:
30 
31  TTErr processAudio(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
32  {
33  TTChannelCount numSignals = inputs->numAudioSignals;
34  TTChannelCount numAccumulatedChannels = 0;
35  TTAudioSignal& out = outputs->getSignal(0);
36 
37  // 1. figure out our total number of channels
38  for (TTChannelCount i=0; i<numSignals; i++) {
39  TTAudioSignal& in = inputs->getSignal(i);
40  numAccumulatedChannels += in.getNumChannelsAsInt();
41  }
42 
43  // 2. setup our output buffer for the correct number of channels
44  // TODO: check if a resize is necessary
45  out.setMaxNumChannels(numAccumulatedChannels);
46  out.setNumChannels(numAccumulatedChannels);
47 
48  // 3. copy the data to the output buffer
49  numAccumulatedChannels = 0;
50  for (TTChannelCount i=0; i<numSignals; i++) {
51  TTAudioSignal& in = inputs->getSignal(i);
52  TTAudioSignal::copyDirty(in, out, numAccumulatedChannels);
53  numAccumulatedChannels += in.getNumChannelsAsInt();
54  }
55  return kTTErrNone;
56  }
57 
58 };
59 
60 
61 
62 
63 #endif // __TT_JOIN_H__
TTAudioObjectBase is the base class for all audio generating and processing objects in Jamoma DSP...
static TTErr copyDirty(const TTAudioSignal &source, TTAudioSignal &dest, TTChannelCount channelOffset=0)
Copy the audio from one signal into another, but not taking care to zero channels that aren't used...
Jamoma DSP Library.
#define TTCLASS_SETUP(className)
TODO Doxygen: need more comments here.
Definition: TTFoundation.h:54
TTErr setMaxNumChannels(const TTValue &newMaxNumChannels)
Attribute accessor.
The TTAudioSignal class represents N vectors of audio samples for M channels.
Definition: TTAudioSignal.h:57
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.
The join≈ object takes N input signals and combines them into a single signal with all of the channe...
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
Definition: TTBase.h:342
No Error.
Definition: TTBase.h:343
TTChannelCount numAudioSignals
The number of audio signal pointers which are actually valid.