Jamoma API  0.6.0.a19
TTAudioGraphInput.cpp
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup audioGraphLibrary
4  *
5  * @brief Defines input interface at the top of an AudioGraph
6  *
7  * @details TTAudioGraphInput is an audio object functioning as a source at the top of the #TTAudioGraph graph, providing sound signals from an external audio input device to the graph for further downstream processing. In Jamoma AudioGraph audio processing is driven from a from a ‘terminal object’ or ‘sink’ at the bottom of the chain.
8  * Hence TTAudioGraphInput objects are not driving the audio graph processing, they simply provides audio signals for further downstream processing
9  * For example sources may provide audio input tio the graph from the hosting environment, read sound frok disk or be used for sound synthesis.
10  * Sources may have other #TTAudioGraphObjects connected downstream, but can not be connected to further upstream TTAudioGraphObjects.
11  *
12  * @authors Timothy Place, Trond Lossius
13  *
14  * @copyright Copyright © 2010, Timothy Place @n
15  * This code is licensed under the terms of the "New BSD License" @n
16  * http://creativecommons.org/licenses/BSD/
17  */
18 
19 
20 // TODO: Why are this files included here rather than in the head file?
21 #include "TTAudioGraphObject.h"
22 #include "TTAudioGraphInlet.h" // required for windows build
23 #include "TTAudioGraphInput.h"
24 //#include "TTAudioEngine.h"
25 
26 #define thisTTClass TTAudioGraphInput
27 #define thisTTClassName "adc"
28 #define thisTTClassTags "audio, graph, input"
29 
30 TT_AUDIO_CONSTRUCTOR
31 {
32  TTDictionary d("j@m0m@_audioengine");
33  TTPtr engine = NULL;
34 
35  d.getValue(engine);
36 
37  mAudioEngine = (TTAudioObjectBase*)engine;
38 
39  TTValue dummy;
40  TTValue buffer;
41  mAudioEngine->sendMessage("getInputSignalReference", dummy, buffer);
42  mBuffer = (TTAudioSignalPtr)TTPtr(buffer);
43 
47 
48  addMessage(start);
49  addMessage(stop);
50  addMessageWithArguments(getAvailableDeviceNames);
51 
52  setProcessMethod(processAudio);
53 
54  setAttributeValue(kTTSym_sampleRate, 44100);
55  setAttributeValue(kTTSym_vectorSize, 512);
56 }
57 
58 
59 TTAudioGraphInput::~TTAudioGraphInput()
60 {
61  //TTAudioEngine::destroy();
63 }
64 
65 
67 {
68  return mAudioEngine->sendMessage(TT("getAvailableInputDeviceNames"), kTTValNONE, returnedDeviceNames);
69 }
70 
71 
73 {
74  mAudioEngine->sendMessage(TT("start"));
75  return kTTErrNone;
76 }
77 
78 
80 {
81  mAudioEngine->sendMessage(TT("stop"));
82  return kTTErrNone;
83 }
84 
86 {
87  return mAudioEngine->setAttributeValue(kTTSym_sampleRate, const_cast<TTValue&>(newValue));
88 }
89 
91 {
92  return mAudioEngine->getAttributeValue(kTTSym_sampleRate, returnedValue);
93 }
94 
95 
97 {
98  return mAudioEngine->setAttributeValue(kTTSym_vectorSize, const_cast<TTValue&>(newValue));
99 }
100 
102 {
103  return mAudioEngine->getAttributeValue(kTTSym_vectorSize, returnedValue);
104 }
105 
106 
108 {
109  return mAudioEngine->setAttributeValue(TT("inputDevice"), const_cast<TTValue&>(newValue));
110 }
111 
113 {
114  return mAudioEngine->getAttributeValue(TT("inputDevice"), returnedValue);
115 }
116 
117 
119 {
120  if (outputs->numAudioSignals){
121  TTAudioSignal& out = outputs->getSignal(0);
122 
123  out = *mBuffer;
124  return kTTErrNone;
125  }
126  else
127  return kTTErrBadChannelConfig;
128 }
TTErr sendMessage(const TTSymbol name)
TODO: Document this function.
TTErr processAudio(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
A standard audio processing method as used by Jamoma DSP objects.
TTErr TTObjectBaseRelease(TTObjectBasePtr *anObject)
DEPRECATED.
TTObjectBasePtr mAudioEngine
Instance of TTAudioEngine class.
TTAudioSignalPtr mBuffer
An unused audio signal that we pass.
TTErr getDevice(TTValue &returnedValue)
Get current audio input device.
TTAudioObjectBase is the base class for all audio generating and processing objects in Jamoma DSP...
TTErr setDevice(const TTValue &newValue)
Set what device to use for audio input.
TTErr getAvailableDeviceNames(const TTValue &, TTValue &returnedDeviceNames)
Get the name of available devices.
An invalid number of audio channels for a given context was encountered.
Definition: TTBase.h:353
TTErr setSampleRate(const TTValue &newValue)
Set sample rate.
#define setProcessMethod(methodName)
A convenience macro to be used by subclasses for setting the process method.
TTErr getAttributeValue(const TTSymbol name, TTValue &value)
Get an attribute value for an object.
Defines a single 'inlet' from an individual AudioGraph object.
TTErr setAttributeValue(const TTSymbol name, TTValue &value)
Set an attribute value for an object.
TTErr getValue(T &aReturnedValue) const
Get the dictionary's primary value.
Definition: TTDictionary.h:202
Symbol type.
Definition: TTBase.h:282
16-bit unsigned integer, range is 0 through 65,535.
Definition: TTBase.h:276
#define TT
This macro is defined as a shortcut for doing a lookup in the symbol table.
Definition: TTSymbol.h:155
A type that represents the key as a C-String and the value as a pointer to the matching TTSymbol obje...
Definition: TTDictionary.h:47
void * TTPtr
A generic pointer.
Definition: TTBase.h:248
TTErr stop()
Stop audio processing.
The TTAudioSignal class represents N vectors of audio samples for M channels.
Definition: TTAudioSignal.h:57
TTErr start()
Start audio processing.
#define addMessageWithArguments(name)
A convenience macro to be used by subclasses for registering messages.
Definition: TTMessage.h:27
Defines input interface at the top of an AudioGraph.
Wraps an object from Jamoma DSP to function within AudioGraph.
TTErr getVectorSize(TTValue &returnedValue)
Get current vector size.
TTErr setVectorSize(const TTValue &newValue)
Set the vector size for audio processing.
A simple container for an array of TTAudioSignal pointers.
TTErr getSampleRate(TTValue &returnedValue)
Get sample rate.
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
32-bit unsigned integer, range is 0 through 4,294,967,295.
Definition: TTBase.h:278
No Error.
Definition: TTBase.h:343
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34
TTChannelCount numAudioSignals
The number of audio signal pointers which are actually valid.
#define addAttributeWithGetterAndSetter(name, type)
A convenience macro to be used by subclasses for registering attributes with a custom getter and sett...
Definition: TTAttribute.h:57