Jamoma API  0.6.0.a19
TTAudioGraphSource.cpp
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 is an upstream connection from a #TTAudioGraphInlet of a #TTAudioGraphObject to a "TTAudioGraphOutlet of an upstream #TTAudioGraphObject.
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 #include "TTAudioGraphObject.h"
24 #include "TTAudioGraphInlet.h"
25 #include "TTCallback.h"
26 
27 
28 // C Callback from any AudioGraph Source objects we are observing
29 void TTAudioGraphSourceObserverCallback(TTAudioGraphSourcePtr self, TTValue& arg)
30 {
31  // at the moment we only receive one callback, which is for the object being deleted
32  self->mSourceObject = NULL;
33  self->mOutletNumber = 0;
34  if (self->mOwner)
35  self->mOwner->drop(*self);
36 }
37 
38 
39 // Implementation for AudioGraph Source class
40 
42  mSourceObject(NULL),
43  mOutletNumber(0),
44  mCallbackHandler("callback"),
45  mOwner(NULL)
46 {
47  create();
48 }
49 
50 
52  mSourceObject(NULL),
53  mOutletNumber(0),
54  mCallbackHandler("callback"),
55  mOwner(NULL)
56 {
57  create();
58  mOwner = original.mOwner;
59 
60  // NOTE: See notes below in TTAudioGraphInlet copy constructor...
61  // NOTE: When vector of sources is resized, it is possible for an object to be created and immediately copied -- prior to a 'connect' method call
62  // NOTE: Are we ever called after connecting? If so, then we need to set up the connection...
63 
64  if (original.mSourceObject)
65  connect(original.mSourceObject, original.mOutletNumber);
66 }
67 
68 
69 
71 {
72  if (mSourceObject)
74 
75  mSourceObject = NULL;
76  mOutletNumber = 0;
77 }
78 
79 
81 {
82  mCallbackHandler.set("function", TTPtr(&TTAudioGraphSourceObserverCallback));
83  mCallbackHandler.set("baton", TTPtr(this));
84  mCallbackHandler.set("notification", TTSymbol("objectFreeing"));
85 }
86 
87 
89 {
90  mOwner = theOwningInlet;
91 }
92 
93 
95 {
96  mSourceObject = NULL;
97  mOutletNumber = 0;
98  mOwner = NULL;
99 
100  create();
101  mOwner = original.mOwner;
102 
103  if (original.mSourceObject && original.mSourceObject->valid)
104  connect(original.mSourceObject, original.mOutletNumber);
105 
106  return *this;
107 }
108 
109 
111 {
112  mSourceObject = anObject;
113  mOutletNumber = fromOutletNumber;
114 
115  // tell the source that is passed in that we want to watch it
117 }
std::uint16_t TTUInt16
16 bit unsigned integer
Definition: TTBase.h:176
~TTAudioGraphSource()
Destructor.
TTErr registerObserverForNotifications(const TTObject &observingObject)
Register an observer.
TTErr unregisterObserverForNotifications(const TTObject &observingObject)
Unregister an observer for notifications.
void setOwner(TTAudioGraphInlet *theOwningInlet)
Set the owning inlet of this source.
TTUInt16 mOutletNumber
The outlet of the upstream object that we pull samples from. This is zero-based.
void connect(TTAudioGraphObjectBasePtr anObject, TTUInt16 fromOutletNumber)
Create a source (a connection or a link) to an outlet of an upstream object.
Defines a single 'inlet' from an individual AudioGraph object.
TTBoolean valid
If the object isn't completely built, or is in the process of freeing, this will be false...
Definition: TTObjectBase.h:124
void * TTPtr
A generic pointer.
Definition: TTBase.h:248
void create()
Create a link to a source.
This class is used to create a backward communication channel to notify a client that something chang...
TTAudioGraphObjectBasePtr mSourceObject
The object from which we pull samples.
TTErr set(const TTSymbol aName, T aValue)
Set an attribute value for an object.
The TTSymbol class is used to represent a string and efficiently pass and compare that string...
Definition: TTSymbol.h:26
TTObject mCallbackHandler
TODO.
This object represents a single 'inlet' to a TTAudioGraphObject.
Wraps an object from Jamoma DSP to function within AudioGraph.
TTAudioGraphInlet * mOwner
The owning inlet.
The TTAudioGraphObjectBase wraps a TTDSP object such that it is possible to build a dynamic graph of ...
TTAudioGraphSource represents one link from a TTAudioGraphInlet of a TTAudioGraphObjectBase to a TTAu...
TTAudioGraphSource()
Constructor.
[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...