Jamoma API
0.6.0.a19
|
To create an instance of a Jamoma object, create a TTObject. Internally this will look up the class in Jamoma’s registry of objects and create an instance.
An example below creates a stereo instance of an allpass filter, and two stereo audio signals. They are stereo because the argument given when instantiating these types of objects define the initial number of audio channels as two. You can safely ignore the fact that one of the variables is a TTAudioObjectPtr instead of a TTObjectPtr. TTAudioObject is simply a specialized version of TTObject for processing audio signals. TTAudio is also a specialized version of TTObject to represent the audio signals.
When you are all done using the objects, you need to release them. If you have allocated the objects on the stack, as we did in the example above, this is taken care of for you.
TTObject’s are reference counted. This means that you can create references to existing objects, and the object will not be freed until all references have been released. This is demonstrated in the following example:
As alluded to in section 3.1, Jamoma Foundation maintains a registry of available classes that may be instantiated by name. Some of these classes are implemented internally in the Jamoma libraries, and some are implemented externally as Jamoma Extensions. The registry does not differentiate between these, but simply provides a list of everything that is loaded in the system.
To obtain a list of all class in the Foundation's registry, you call the TTObject::GetRegisteredClassNames() function as in the following example:
In addition to retrieving all class names, it is also useful to be able to retrieve a limited number of class names based on criteria that you specify. For example, you may wish to only list classes that generate their own audio. Or perhaps only those class which implement some sort of lowpass filter.
In this case we call TTObject::GetRegisteredClassNamesForTags(), and process the results in the same manner as we did for TTObject::GetRegisteredClassNames(). This is demonstrated in the example below:
For a list of common tags and what they mean in Jamoma see Appendix B. To get a list of all tags in use at any time, call TTObject::GetRegisteredTags().
Here is an example that searches based on tags for a lowpass filter using a Butterworth algorithm, and then creates an instance of that class.
Having created an instance of an object, we must now do something with that object. We do things with objects by sending them messages. A message defines an action to be performed.
Given the Butterworth filter example in Tag Searching and Instantiation in Action, we can now send the filter the 'clear' message to zero its sample history
Some messages, like the 'clear' message for the Butterworth filter, require no additional information to perform the requested action. Other messages, however, do require additional information. This information can be provided using an optional arguments to the send() method. Here are some samples:
Sending messages is great for performing actions, however these actions do not represent the state of the object. The state of the object is represented as the object's 'attributes'.
Not all objects can process audio, however, objects that have the tag ‘audio’ associated with them are able process audio. These objects derive from TTAudioObjectBase, a subclass of TTObjectBase which implements the “process” method.