Jamoma API  0.6.0.a19
TTInputAudio.cpp
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup modularLibrary
4  *
5  * @brief An audio input component for Jamoma models.
6  *
7  * @details
8  *
9  * @authors Timothy Place
10  *
11  * @copyright © 2013, Timothy Place @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 "TTInputAudio.h"
17 
18 #define thisTTClass TTInputAudio
19 #define thisTTClassName "Input.audio"
20 #define thisTTClassTags "input"
21 
22 
23 TTObjectBasePtr TTInputAudio::instantiate (TTSymbol name, TTValue arguments)
24 {
25  return new TTInputAudio(arguments);
26 }
27 
28 
29 extern "C" void TTInputAudio::registerClass()
30 {
31  TTClassRegister(TTSymbol("Input.audio"), thisTTClassTags, TTInputAudio::instantiate);
32 }
33 
34 
35 TTInputAudio :: TTInputAudio (const TTValue& arguments) :
36 TTInput(arguments)
37 {
38  mType = "audio";
39 
40  mSignalIn = TTObject(kTTSym_audiosignal, 1);
41  mSignalOut = TTObject(kTTSym_audiosignal, 1);
42  mSignalZero = TTObject(kTTSym_audiosignal, 1);
43 }
44 
45 
46 TTInputAudio::~TTInputAudio()
47 {
48  ;
49 }
50 
51 
52 void TTInputAudio::process(TTSampleValue* anInputSampleVector, TTSampleValue* anOutputSampleVector, TTUInt16 aVectorSize)
53 {
54  // Store the input from the inlets
55  TTAudioSignalPtr(mSignalIn.instance())->setVector64Copy(0, aVectorSize, anInputSampleVector);
56 
57  // Sum signal from j.send~ objects
58  for (mSignalCache.begin(); mSignalCache.end(); mSignalCache.next()) {
59  TTObject o = mSignalCache.current()[0];
60  TTAudioSignalPtr sentSignal = TTAudioSignalPtr(o.instance());
61 
62  if (sentSignal)
63  *TTAudioSignalPtr(mSignalIn.instance()) += *sentSignal;
64  }
65 
66  // if signal is bypassed or muted, send a zero signal to the algorithm
67  if (mBypass || mMute)
68  TTAudioSignal::copy(*TTAudioSignalPtr(mSignalZero.instance()), *TTAudioSignalPtr(mSignalOut.instance()));
69 
70  // else copy in to out
71  else
72  TTAudioSignal::copy(*TTAudioSignalPtr(mSignalIn.instance()), *TTAudioSignalPtr(mSignalOut.instance()));
73 
74  // clear the signal cache
75  mSignalCache.clear();
76 
77  // Send the input on to the outlets for the algorithm, if desired
78  if (anOutputSampleVector)
79  TTAudioSignalPtr(mSignalOut.instance())->getVectorCopy(0, aVectorSize, anOutputSampleVector);
80 }
81 
std::uint16_t TTUInt16
16 bit unsigned integer
Definition: TTBase.h:176
void process(TTSampleValue *anInputSampleVector, TTSampleValue *anOutputSampleVector, TTUInt16 aVectorSize)
Called by the perform method in j.in~ to pass the samples in from the outside world Will also be call...
Create and use Jamoma object instances.
Definition: TTObject.h:29
Base class for all first-class Jamoma objects.
Definition: TTObjectBase.h:109
The TTSymbol class is used to represent a string and efficiently pass and compare that string...
Definition: TTSymbol.h:26
The TTAudioSignal class represents N vectors of audio samples for M channels.
Definition: TTAudioSignal.h:57
An audio input component for Jamoma models.
TTObjectBase * instance() const
Return a direct pointer to the internal instance.
Definition: TTObject.cpp:105
static TTErr copy(const TTAudioSignal &source, TTAudioSignal &dest, TTChannelCount channelOffset=0)
Copy the audio from one signal into another.
TTFloat64 TTSampleValue
A value representing a single audio sample.
Definition: TTBase.h:230
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34
An audio input component for Jamoma models.
Definition: TTInputAudio.h:23