Jamoma API  0.6.0.a19
Lissajous2D.cpp
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup dspTrajectoryLib
4  *
5  * @brief Lissajous Knot Function Unit in 2D for Jamoma DSP
6  *
7  * @details see http://en.wikipedia.org/wiki/Lissajous_knot for details @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 #include "Lissajous2D.h"
17 #
18 
19 #define thisTTClass Lissajous2D
20 #define thisTTClassName "lissajous.2D"
21 #define thisTTClassTags "audio, trajectory, 2D"
22 
23 
24 TT_AUDIO_CONSTRUCTOR
26  addAttribute(DeltaX, kTypeFloat64);
27 
28  setProcessMethod(processAudio);
29 // setCalculateMethod(calculateValue);
30 }
31 
32 
33 Lissajous2D::~Lissajous2D()
34 {
35  ;
36 }
37 
38 //TTErr Lissajous2D::calculateValue(const TTFloat64& x, TTFloat64& y, TTPtrSizedInt data)
39 //{
40 // y = x;
41 // return kTTErrNone;
42 //}
43 
44 TTErr Lissajous2D::setA(const TTValue& newValue)
45 {
46  mA = newValue;
47  if (mA > 0){
48  mAa = mA;
49  mAb = mAa + 1.0;
50  }
51  else{
52  mAa = -1.0 * mA;
53  mAb = mAa - 1.0;
54  }
55  return kTTErrNone;
56 }
57 
58 TTErr Lissajous2D::processAudio(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
59 {
60  TTAudioSignal& out = outputs->getSignal(0);
61  TTChannelCount numOutputChannels = out.getNumChannelsAsInt();
62 
63  if (numOutputChannels != 2) {
64  TTValue v = 2;
65  out.setMaxNumChannels(v);
66  out.setNumChannels(v);
67  }
68 
69  TTAudioSignal& in0 = inputs->getSignal(0);
70  TTUInt16 vs = in0.getVectorSizeAsInt();
71 
72  TTSampleValuePtr inSampleX = in0.mSampleVectors[0];
73  TTSampleValuePtr outSampleX = out.mSampleVectors[0];
74  TTSampleValuePtr outSampleY = out.mSampleVectors[1];
75  TTFloat64 omega;
76 
77  for (int i=0; i<vs; i++) {
78  omega = inSampleX[i] * kTTPi;
79 
80  outSampleX[i] = sin(omega * mAa + mDeltaX);
81  outSampleY[i] = sin(omega * mAb);
82  }
83 return kTTErrNone;
84 }
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.
double TTFloat64
64 bit floating point number
Definition: TTBase.h:188
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
Lissajous Knot Function Unit in 2D for Jamoma DSP.
#define addAttributeWithSetter(name, type)
A convenience macro to be used by subclasses for registering attributes with a custom setter...
Definition: TTAttribute.h:47
No Error.
Definition: TTBase.h:343
TTFOUNDATION_EXPORT const TTFloat64 kTTPi
[doxygenAppendixC_constExample]
Definition: TTBase.cpp:23
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34