Jamoma API  0.6.0.a19
TTAudioGraphSource.h
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup audioGraphLibrary
4  *
5  * @brief Represents one connection between two AudioGraph objects
6  *
7  * @details TTAudioGraphSource represents one link or connection between two AudioGraph objects. TTAudioGraphSource is an upstream connection from a #TTAudioGraphInlet of a #TTAudioGraphObjectBase to a "TTAudioGraphOutlet of an upstream #TTAudioGraphObjectBase.
8  * The relationship of a source to other parts of the audio graph hierarchy is as follows:
9  *
10  * - A graph may have many objects.
11  * - An object may have many inlets.
12  * - An inlet may have many signals (sources) connected.
13  * - A signal may have many channels.
14  *
15  * @authors Timothy Place, Trond Lossius
16  *
17  * @copyright Copyright © 2010, Timothy Place @n
18  * This code is licensed under the terms of the "New BSD License" @n
19  * http://creativecommons.org/licenses/BSD/
20  */
21 
22 
23 #ifndef __TTAUDIOGRAPH_SOURCE_H__
24 #define __TTAUDIOGRAPH_SOURCE_H__
25 
26 #include "TTAudioGraph.h"
27 #include "TTAudioGraphObject.h"
28 
29 
30 /******************************************************************************************/
31 
32 // NOTE: we don't need to keep a buffer of our own, be we just mirror the buffer of mSourceObject
33 
34 /** TTAudioGraphSource represents one link from a #TTAudioGraphInlet of a #TTAudioGraphObjectBase to a #TTAudioGraphOutlet of an upstream #TTAudioGraphObjectBase.
35  */
37  friend void TTAudioGraphSourceObserverCallback(TTAudioGraphSource* self, TTValue& arg);
38 
39 protected:
40 
41  TTAudioGraphObjectBasePtr mSourceObject; ///< The object from which we pull samples
42  TTUInt16 mOutletNumber; ///< The outlet of the upstream object that we pull samples from. This is zero-based.
44  TTAudioGraphInlet* mOwner; ///< The owning inlet
45 
46 public:
47 
48  /** Constructor */
50 
51 
52  /** Copy Constructor */
53  TTAudioGraphSource(const TTAudioGraphSource& original);
54 
55 
56  /** Destructor */
58 
59 
60  // Internal method shared/called by constructors.
61 
62  /** Create a link to a source. This establish a link between a #TTAudioGraphInlet and a #TTAudioGraphOutlet of an upstream #TTAudioGraphObjectBase.
63  */
64  void create();
65 
66 
67  /** Check to see if this source (link) is connected to the requested outlet of the requested upstream object.
68  @param anObject The upstream object that we want to check if match this source.
69  @param anOutletNumber The object outlet that we want to check if match this source.
70  @return TRUE if we have a match, else FALSE.
71  */
73  {
74  if (anObject == mSourceObject && anOutletNumber == mOutletNumber)
75  return YES;
76  else
77  return NO;
78  }
79 
80 
81  /** Set the owning inlet of this source.
82  @param theOwningInlet The inlet that will be owning this source (link).
83  */
84  void setOwner(TTAudioGraphInlet* theOwningInlet);
85 
86 
87  /** This operator is called, for example, on the Mac when dropping a source and the vector has to be re-arranged.
88  */
90 
91 
92  /** Compare two sources for equality, that is: It they are representing a connection between the same inlet/outlet pair of the same objects.
93  @param source1 The first source to be compared.
94  @param source2 The second source to be compared.
95  @return TRUE if the two sources (links or connections) are the same, else FALSE.
96  */
97  inline friend bool operator == (const TTAudioGraphSource& source1, const TTAudioGraphSource& source2)
98  {
99  if (source1.mSourceObject == source2.mSourceObject && source1.mOutletNumber == source2.mOutletNumber)
100  return true;
101  else
102  return false;
103  }
104 
105 
106  // Info Methods
107 
108  /** Prepare to describe this source (link or connection).
109  */
111  {
112  mSourceObject->prepareAudioDescription();
113  }
114 
115 
116  /** Describe this source.
117  @param desc Pointer to #TTAudioGraphDescription used for returning the description.
118  */
120  {
121  mSourceObject->getAudioDescription(desc);
122  desc.mOutletNumber = this->mOutletNumber;
123  }
124 
125  // Graph Methods
126 
127 
128  /** Create a source (a connection or a link) to an outlet of an upstream object.
129  @param anObject The upstream object that we want to connect to.
130  @param fromOutletNumber The outlet of the upstream object that we want to connect to.
131  */
132  void connect(TTAudioGraphObjectBasePtr anObject, TTUInt16 fromOutletNumber);
133 
134 
135  /** Prepare for audio processing.
136  */
138  {
139  mSourceObject->preprocess(initData);
140  }
141 
142 
143  /** Perform audio processing.
144  @details This pass a request for a buffer of processed audio to the upstream associated source.
145  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
146  */
147  TTErr process(TTAudioSignalPtr& returnedSignal, TTUInt64 sampleStamp)
148  {
149  return mSourceObject->process(returnedSignal, sampleStamp, mOutletNumber);
150  }
151 
152 };
153 
154 
155 /** Pointer to a #TTAudioGraphSource.
156  @ingroup typedefs
157  */
159 
160 
161 /** A vector of #TTAudioGraphSources
162  @ingroup typedefs
163  */
164 typedef std::vector<TTAudioGraphSource> TTAudioGraphSourceVector;
165 
166 
167 /** An iterator on TTAudioGraphSourceVector
168  @ingroup typedefs
169  */
170 typedef TTAudioGraphSourceVector::iterator TTAudioGraphSourceIter;
171 
172 
173 #endif // __TTAUDIOGRAPH_SOURCE_H__
bool TTBoolean
Boolean flag, same as Boolean on the Mac.
Definition: TTBase.h:167
std::uint16_t TTUInt16
16 bit unsigned integer
Definition: TTBase.h:176
~TTAudioGraphSource()
Destructor.
TTBoolean match(TTAudioGraphObjectBasePtr anObject, TTUInt16 anOutletNumber)
Check to see if this source (link) is connected to the requested outlet of the requested upstream obj...
std::uint64_t TTUInt64
64 bit unsigned integer
Definition: TTBase.h:180
void setOwner(TTAudioGraphInlet *theOwningInlet)
Set the owning inlet of this source.
void getAudioDescription(TTAudioGraphDescription &desc)
Describe this object as part of the action of describing a complete audio graph.
Create and use Jamoma object instances.
Definition: TTObject.h:29
TTUInt16 mOutletNumber
The outlet of the upstream object that we pull samples from. This is zero-based.
This object provides a description of a TTAudioGraphObject and its sources.
void prepareAudioDescription()
Prepare for a request to descibe all of the graph.
Registers classes for the primary AudioGraph library.
void connect(TTAudioGraphObjectBasePtr anObject, TTUInt16 fromOutletNumber)
Create a source (a connection or a link) to an outlet of an upstream object.
void create()
Create a link to a source.
TTAudioGraphObjectBasePtr mSourceObject
The object from which we pull samples.
TTObject mCallbackHandler
TODO.
This object represents a single 'inlet' to a TTAudioGraphObject.
virtual TTErr preprocess(const TTAudioGraphPreprocessData &initData)
This method is called by an object about to process audio, prior to calling getAudioOutput().
The TTAudioSignal class represents N vectors of audio samples for M channels.
Definition: TTAudioSignal.h:57
friend bool operator==(const TTAudioGraphSource &source1, const TTAudioGraphSource &source2)
Compare two sources for equality, that is: It they are representing a connection between the same inl...
void preprocess(const TTAudioGraphPreprocessData &initData)
Prepare for audio processing.
Wraps an object from Jamoma DSP to function within AudioGraph.
TTAudioGraphInlet * mOwner
The owning inlet.
TTErr process(TTAudioSignalPtr &returnedSignal, TTUInt64 sampleStamp)
Perform audio processing.
TTAudioGraphSourceVector::iterator TTAudioGraphSourceIter
An iterator on TTAudioGraphSourceVector.
virtual TTErr process(TTAudioSignalPtr &returnedSignal, TTUInt64 sampleStamp, TTUInt16 forOutletNumber=0)
This method is required to be implemented by all objects except for those existing solely as a destin...
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
Definition: TTBase.h:342
void prepareDescription()
Prepare to describe this source (link or connection).
The TTAudioGraphObjectBase wraps a TTDSP object such that it is possible to build a dynamic graph of ...
[doxygenAppendixC_bitmaskExample]
Definition: TTAudioGraph.h:81
TTAudioGraphSource * TTAudioGraphSourcePtr
Pointer to a TTAudioGraphSource.
TTAudioGraphSource represents one link from a TTAudioGraphInlet of a TTAudioGraphObjectBase to a TTAu...
TTAudioGraphSource()
Constructor.
void getDescription(TTAudioGraphDescription &desc)
Describe this source.
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34
TTAudioGraphSource & operator=(const TTAudioGraphSource &original)
This operator is called, for example, on the Mac when dropping a source and the vector has to be re-a...
std::vector< TTAudioGraphSource > TTAudioGraphSourceVector
A vector of #TTAudioGraphSources.