Jamoma API  0.6.0.a19
TTSpatBaseRenderer.cpp
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup dspSpatLib
4  *
5  * @brief TODO
6  *
7  * @details TODO @n
8  *
9  * @authors Trond Lossius, Nils Peters, Timothy Place
10  *
11  * @copyright Copyright © 2011 by Trond Lossius, Nils Peters, and 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 #include "TTSpatBaseRenderer.h"
17 
18 
19 
20 /// Methods for TTSpatSnapRenderer: //////////////////////
21 
23 mMixerMatrixCoefficients(NULL)
24 {
26 }
27 
28 
30 {
32 }
33 
34 
36 {
37  TTAudioSignal& in = inputs->getSignal(0);
38  TTAudioSignal& out = outputs->getSignal(0);
39  TTUInt16 vs = in.getVectorSizeAsInt();
40  TTSampleValuePtr inSample;
41  TTSampleValuePtr outSample;
42  TTChannelCount numInputChannels = in.getNumChannelsAsInt();
43  TTChannelCount numOutputChannels = out.getNumChannelsAsInt();
44  TTChannelCount outChannel;
45  TTChannelCount inChannel;
46  TTSampleValue gainValue;
47 
50 
51  // If the input signal has more channels than we have sources, the additional channels are ignored.
52  if (numInputChannels > sourceCount) {
53  numInputChannels = sourceCount;
54  }
55 
56  // Force the right number of sinks
57  if ( numOutputChannels != sinkCount ) {
58  TTValue v = sinkCount;
59 
60  out.setMaxNumChannels(v);
61  out.setNumChannels(v);
62  numOutputChannels = sinkCount;
63  }
64  // Setting all output signals to zero.
65  out.clear();
66 
67  // TODO: Make sure that when we iterate over the matrix, this is done in an efficient way.
68 
69  for (outChannel=0; outChannel<numOutputChannels; outChannel++) {
70  outSample = out.mSampleVectors[outChannel];
71  for (inChannel=0; inChannel<numInputChannels; inChannel++) {
72 
73  mMixerMatrixCoefficients->get2d(inChannel, outChannel, gainValue);
74 
75  if (gainValue != 0.0){
76  inSample = in.mSampleVectors[inChannel];
77  for (int i=0; i<vs; i++) {
78  outSample[i] += inSample[i] * gainValue;
79  }
80  }
81  }
82  }
83  return kTTErrNone;
84 
85 }
86 
std::uint16_t TTUInt16
16 bit unsigned integer
Definition: TTBase.h:176
TTErr TTObjectBaseRelease(TTObjectBasePtr *anObject)
DEPRECATED.
virtual TTErr processAudio(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
A standard matrix-based audio processing method which may be used for matrix-based spatialization alg...
A basic proof-of-concept spatial renderer where the audio of a source will snap to the nearest sink...
TTColumnID getColumnCount()
Simple data accessor.
Definition: TTMatrixBase.h:154
Base class for all first-class Jamoma objects.
Definition: TTObjectBase.h:109
TTErr get2d(TTRowID i, TTColumnID j, T &data) const
Get the value of a component located at (i,j) in a 2-dimensional matrix.
Definition: TTMatrixBase.h:422
virtual ~TTSpatBaseRenderer()
Destructor.
std::int16_t TTInt16
16 bit signed integer
Definition: TTBase.h:175
TTRowID getRowCount()
Simple data accessor.
Definition: TTMatrixBase.h:147
TTErr clear()
Zero out all of the sample values in the audio signal.
TTErr setMaxNumChannels(const TTValue &newMaxNumChannels)
Attribute accessor.
TTSampleMatrixPtr mMixerMatrixCoefficients
A matrix holding all coefficient for matrix-based mixing of sources to sinks.
TTErr TTObjectBaseInstantiate(const TTSymbol className, TTObjectBasePtr *returnedObjectPtr, const TTValue arguments)
DEPRECATED.
TTSpatBaseRenderer()
Constructor.
The TTAudioSignal class represents N vectors of audio samples for M channels.
Definition: TTAudioSignal.h:57
TTSampleValue ** mSampleVectors
An array of pointers to the first sample in each vector. Declared Public for fast access...
Definition: TTAudioSignal.h:74
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.
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
TTFloat64 TTSampleValue
A value representing a single audio sample.
Definition: TTBase.h:230
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34