Jamoma API  0.6.0.a19
TTCount.cpp
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup dspGeneratorLib
4  *
5  * @brief GeneratorLib: Count the number of processd samples, starting from zero.
6  *
7  * @details
8  *
9  * @authors Trond Lossius
10  *
11  * @copyright Copyright © 2012 by Trond Lossius @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 "TTCount.h"
17 
18 #define thisTTClass TTCount
19 #define thisTTClassName "count"
20 #define thisTTClassTags "dspGeneratorLib, audio, generator"
21 
22 
23 TT_AUDIO_CONSTRUCTOR
24 {
25  addMessage(reset);
26  setProcessMethod(processAudio);
27  reset();
28 }
29 
30 
31 TTCount::~TTCount()
32 {
33  ;
34 }
35 
36 
38 {
39  count = 0.;
40  return kTTErrNone;
41 }
42 
43 
45 {
46  TTAudioSignal& out = outputs->getSignal(0);
47  TTSampleValue *outSample;
48  TTChannelCount numchannels = out.getNumChannelsAsInt();
49  TTChannelCount channel;
50  TTUInt16 vs;
51  TTFloat64 thisVectorCount;
52 
53  for (channel=0; channel<numchannels; channel++) {
54  vs = out.getVectorSizeAsInt();
55  outSample = out.mSampleVectors[channel];
56  thisVectorCount = count;
57  while (vs--) {
58  *outSample++ = thisVectorCount;
59  thisVectorCount += 1.;
60  }
61  }
62 
63  count = thisVectorCount;
64  return kTTErrNone;
65 }
GeneratorLib: Count the number of processed samples, starting from zero.
std::uint16_t TTUInt16
16 bit unsigned integer
Definition: TTBase.h:176
TTErr processAudio(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
Process method.
Definition: TTCount.cpp:44
#define setProcessMethod(methodName)
A convenience macro to be used by subclasses for setting the process method.
TTErr reset()
Start counting from zero again.
Definition: TTCount.cpp:37
TTFloat64 count
Sample count.
Definition: TTCount.h:30
double TTFloat64
64 bit floating point number
Definition: TTBase.h:188
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 addMessage(name)
A convenience macro to be used by subclasses for registering messages.
Definition: TTMessage.h:19
No Error.
Definition: TTBase.h:343
TTFloat64 TTSampleValue
A value representing a single audio sample.
Definition: TTBase.h:230