Jamoma API  0.6.0.a19
Rose3D.cpp
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup dspTrajectoryLib
4  *
5  * @brief Rose Function Unit in 3D for Jamoma DSP
6  *
7  * @details see http://mathworld.wolfram.com/Rose.html 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 "Rose3D.h"
17 
18 #define thisTTClass Rose3D
19 #define thisTTClassName "rose.3D"
20 #define thisTTClassTags "audio, trajectory"
21 
22 
23 TT_AUDIO_CONSTRUCTOR
30 
31  setAttributeValue(TT("a"), 0.0);
32  setAttributeValue(TT("b"), 0.5);
33  setAttributeValue(TT("c"), 0.2);
34  setAttributeValue(TT("deltaX"), kTTPi/2);
35  setAttributeValue(TT("deltaY"), 0.0);
36  setAttributeValue(TT("deltaZ"), 0.0);
37 
38  setProcessMethod(processAudio);
39 // setCalculateMethod(calculateValue);
40 }
41 
42 
43 Rose3D::~Rose3D()
44 {
45  ;
46 }
47 
48 TTErr Rose3D::setA(const TTValue& newValue)
49 {
50  mA = newValue;
51  return kTTErrNone;
52 }
53 
54 TTErr Rose3D::setB(const TTValue& newValue)
55 {
56  mB = newValue;
57  return kTTErrNone;
58 }
59 
60 TTErr Rose3D::setC(const TTValue& newValue)
61 {
62  mC = newValue;
63  return kTTErrNone;
64 }
65 
66 TTErr Rose3D::setDeltaX(const TTValue& newValue)
67 {
68  mDeltaX = newValue;
69  return kTTErrNone;
70 }
71 
72 TTErr Rose3D::setDeltaY(const TTValue& newValue)
73 {
74  mDeltaY = newValue;
75  return kTTErrNone;
76 }
77 
78 TTErr Rose3D::setDeltaZ(const TTValue& newValue)
79 {
80  mDeltaZ = newValue;
81  return kTTErrNone;
82 }
83 
84 
85 //TTErr Rose3D::calculateValue(const TTFloat64& x, TTFloat64& y, TTPtrSizedInt data)
86 //{
87 // y = x;
88 // return kTTErrNone;
89 //}
90 
91 
92 TTErr Rose3D::processAudio(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
93 {
94  TTAudioSignal& out = outputs->getSignal(0);
95  TTChannelCount numOutputChannels = out.getNumChannelsAsInt();
96 
97  if (numOutputChannels != 3) {
98  TTValue v = 3;
99  out.setMaxNumChannels(v);
100  out.setNumChannels(v);
101  }
102 
103  TTAudioSignal& in0 = inputs->getSignal(0);
104  TTAudioSignal& in1 = inputs->getSignal(1);
105  TTAudioSignal& in2 = inputs->getSignal(2);
106 
107  TTUInt16 vs = in0.getVectorSizeAsInt();
108 
109  TTSampleValuePtr inSampleX = in0.mSampleVectors[0];
110  TTSampleValuePtr inSampleY = in1.mSampleVectors[0];
111  TTSampleValuePtr inSampleZ = in2.mSampleVectors[0];
112  TTSampleValuePtr outSampleX = out.mSampleVectors[0];
113  TTSampleValuePtr outSampleY = out.mSampleVectors[1];
114  TTSampleValuePtr outSampleZ = out.mSampleVectors[2];
115 
116  for (int i=0; i<vs; i++) {
117  outSampleX[i] = cos(((inSampleX[i]-1.0 + mDeltaX) * mA) * kTTTwoPi);
118  outSampleY[i] = cos( (inSampleY[i]-1.0) * mB * kTTTwoPi);
119  outSampleZ[i] = cos( (inSampleZ[i]-1.0) * mC * kTTTwoPi);
120  }
121 return kTTErrNone;
122 }
123 
124 
125 
std::uint16_t TTUInt16
16 bit unsigned integer
Definition: TTBase.h:176
TTFOUNDATION_EXPORT const TTFloat64 kTTTwoPi
Pre-calculated value of pi * 2.
Definition: TTBase.cpp:24
#define setProcessMethod(methodName)
A convenience macro to be used by subclasses for setting the process method.
#define TT
This macro is defined as a shortcut for doing a lookup in the symbol table.
Definition: TTSymbol.h:155
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
Rose Function Unit in 3D for Jamoma DSP.
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34