Jamoma API  0.6.0.a19
Epitrochoid2D.cpp
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup dspTrajectoryLib
4  *
5  * @brief Epitrochoid Function Unit for Jamoma DSP
6  *
7  * @details http://mathworld.wolfram.com/Epitrochoid.html in 2D @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 "Epitrochoid2D.h"
18 
19 
20 #define thisTTClass Epitrochoid2D
21 #define thisTTClassName "epitrochoid.2D"
22 #define thisTTClassTags "audio, trajectory, 2D"
23 
24 
25 TT_AUDIO_CONSTRUCTOR
28  setAttributeValue(TT("a"), 0.0);
29 
30 
31  setProcessMethod(processAudio);
32 // setCalculateMethod(calculateValue);
33 }
34 
35 
36 Epitrochoid2D::~Epitrochoid2D()
37 {
38  ;
39 }
40 
41 TTErr Epitrochoid2D::setA(const TTValue& newValue)
42 {
43  mA = newValue;
44  aPlusOne = mA + 1.0;
45 
46  return kTTErrNone;
47 }
48 
49 //TTErr Epitrochoid2D::calculateValue(const TTFloat64& x, TTFloat64& y, TTPtrSizedInt data)
50 //{
51 // y = x;
52 // return kTTErrNone;
53 //}
54 
55 
56 TTErr Epitrochoid2D::processAudio(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
57 {
58  TTAudioSignal& out = outputs->getSignal(0);
59  TTChannelCount numOutputChannels = out.getNumChannelsAsInt();
60 
61  if (numOutputChannels != 2) {
62  TTValue v = 2;
63  out.setMaxNumChannels(v);
64  out.setNumChannels(v);
65  }
66 
67  TTAudioSignal& in0 = inputs->getSignal(0);
68  TTUInt16 vs = in0.getVectorSizeAsInt();
69 
70  TTSampleValuePtr inSampleX = in0.mSampleVectors[0];
71  TTSampleValuePtr outSampleX = out.mSampleVectors[0];
72  TTSampleValuePtr outSampleY = out.mSampleVectors[1];
73  TTFloat64 phi;
74 
75  for (int i=0; i<vs; i++) {
76 
77  phi = inSampleX[i] * kTTPi; // 0 .. 2Pi
78 
79  outSampleX[i] = aPlusOne * cos(phi) - mB * cos(aPlusOne * phi);
80  outSampleY[i] = aPlusOne * sin(phi) - mB * sin(aPlusOne * phi);
81 
82 
83  }
84 return kTTErrNone;
85 }
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
#define TT
This macro is defined as a shortcut for doing a lookup in the symbol table.
Definition: TTSymbol.h:155
Epitrochoid Function Unit 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
#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