Jamoma API  0.6.0.a19
Linear2D.cpp
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup dspTrajectoryLib
4  *
5  * @brief Linear Function Unit in 2D for Jamoma DSP
6  *
7  * @details a simple linear function in two dimensions @n
8  *
9  * @authors Nils Peters
10  *
11  * @copyright Copyright © 2011 by Nils Peters @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 #include "Linear2D.h"
18 
19 
20 #define thisTTClass Linear2D
21 #define thisTTClassName "linear.2D"
22 #define thisTTClassTags "audio, trajectory, 2D"
23 
24 
25 TT_AUDIO_CONSTRUCTOR
27  setProcessMethod(processAudio);
28 // setCalculateMethod(calculateValue);
29 }
30 
31 
32 Linear2D::~Linear2D()
33 {
34  ;
35 }
36 
38 {
39  TTAudioSignal& out = outputs->getSignal(0);
40  TTChannelCount numOutputChannels = out.getNumChannelsAsInt();
41 
42  if (numOutputChannels != 2) {
43  TTValue v = 2;
44  out.setMaxNumChannels(v);
45  out.setNumChannels(v);
46  }
47 
48  TTAudioSignal& in0 = inputs->getSignal(0);
49  TTUInt16 vs = in0.getVectorSizeAsInt();
50 
51  TTSampleValuePtr inSampleX = in0.mSampleVectors[0];
52  TTSampleValuePtr outSampleX = out.mSampleVectors[0];
53  TTSampleValuePtr outSampleY = out.mSampleVectors[1];
54 
55  for (int i=0; i<vs; i++) {
56  outSampleX[i] = inSampleX[i]-1.0; //Phasor runs from 0 .. 2
57  outSampleY[i] = mA * outSampleX[i];
58  }
59  return kTTErrNone;
60 }
std::uint16_t TTUInt16
16 bit unsigned integer
Definition: TTBase.h:176
#define addAttribute(name, type)
A convenience macro to be used by subclasses for registering attributes with a custom getter...
Definition: TTAttribute.h:29
#define setProcessMethod(methodName)
A convenience macro to be used by subclasses for setting the process method.
Linear Function Unit in 2D for Jamoma DSP.
TTErr setMaxNumChannels(const TTValue &newMaxNumChannels)
Attribute accessor.
64-bit floating point
Definition: TTBase.h:272
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
TTErr processAudio(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
A standard audio processing method as used by Jamoma DSP objects.
Definition: Linear2D.cpp:37
No Error.
Definition: TTBase.h:343
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34