Jamoma API  0.6.0.a19
TTDSP.h
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup dspLibrary
4  *
5  * @brief Jamoma DSP Library
6  *
7  * @details
8  *
9  * @authors Tim Place, Trond Lossius
10  *
11  * @copyright Copyright © 2008 by 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 
17 #ifndef __TTDSP_H__
18 #define __TTDSP_H__
19 
20 
21 #define TTDSP_VERSION_STRING "0.6"
22 
23 
24 #ifdef TT_PLATFORM_WIN
25  #ifdef TTDSP_EXPORTS
26  #define TTDSP_EXPORT __declspec(dllexport)
27  #else
28  #ifdef TTSTATIC
29  #define TTDSP_EXPORT
30  #else
31  #define TTDSP_EXPORT __declspec(dllimport)
32  #endif
33  #endif // _DLL_EXPORT
34 
35 #else // TT_PLATFORM_MAC
36  #ifdef TTDSP_EXPORTS
37  #define TTDSP_EXPORT __attribute__((visibility("default")))
38  #else
39  #define TTDSP_EXPORT
40  #endif
41 #endif
42 
43 #include "TTFoundationAPI.h"
44 #include "TTAudioObjectBase.h"
45 #include "TTAudioSignal.h"
46 #include "TTAudioSignalArray.h"
47 #include "TTAudioObject.h"
48 
49 
50 
51 // Macros
52 
53 #define TT_AUDIO_CONSTRUCTOR \
54 TTObjectBasePtr thisTTClass :: instantiate (TTSymbol name, TTValue arguments) {return new thisTTClass (arguments);} \
55 \
56 extern "C" void thisTTClass :: registerClass () {TTClassRegister( thisTTClassName, thisTTClassTags, thisTTClass :: instantiate );} \
57 \
58 thisTTClass :: thisTTClass (const TTValue& arguments) : TTAudioObjectBase(arguments)
59 
60 
61 
62 #define TT_AUDIO_CONSTRUCTOR_EXPORT(theBinaryFileName) \
63  \
64  extern "C" TT_EXTENSION_EXPORT TTErr TTLoadJamomaExtension_ ## theBinaryFileName (void);\
65  TTErr TTLoadJamomaExtension_ ## theBinaryFileName (void)\
66  {\
67  TTDSPInit();\
68  thisTTClass :: registerClass(); \
69  return kTTErrNone;\
70  }\
71  \
72  TT_AUDIO_CONSTRUCTOR
73 
74 
75 /** A macro for setting up the class binding to the library in extension classes.
76  @ingroup macros
77  @param strname A C-string that names the object as it should be listed in the environment.
78  @param tags The tags associated with the class.
79  @param className The name of the class.
80  */
81 #define TT_AUDIO_CLASS_SETUP(strname, tags, className)\
82  \
83  extern "C" TT_EXTENSION_EXPORT TTObjectBase* instantiate ## className (const TTSymbol&, TTValue& arguments); \
84  \
85  TTObjectBase* instantiate ## className (TTSymbol&, TTValue& arguments) \
86  {\
87  return new className (arguments);\
88  }\
89  \
90  extern "C" TT_EXTENSION_EXPORT TTErr TTLoadJamomaExtension_ ## className (void);\
91  TTErr TTLoadJamomaExtension_ ## className (void)\
92  {\
93  TTFoundationInit();\
94  TTClassRegister(strname, tags, & instantiate ## className);\
95  return kTTErrNone;\
96  }
97 
98 
99 
100 // Prototypes
101 
102 /** Initialise the Jamoma DSP library, as well as Jamoma Foundation foundation if needed.
103  @param pathToBinaries The file path to the location of the binaries.
104  */
105 void TTDSP_EXPORT TTDSPInit(const char* pathToBinaries = NULL);
106 
107 
108 
109 ///// Convenience methods so that casting is not a worry: /////
110 
111 /** Instantiate an object.
112  @param className The name of the class of the object
113  @param returnedObjectPtr Pointer to the newly instantiated object
114  @param arguments Additional arguments
115  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
116  */
117 TTErr TTDSP_EXPORT TTObjectBaseInstantiate(const TTSymbol& className, TTAudioObjectBasePtr* returnedObjectPtr, TTValue& arguments);
118 TTErr TTDSP_EXPORT TTObjectBaseInstantiate(const TTSymbol& className, TTAudioSignalPtr* returnedObjectPtr, TTValue& arguments);
119 TTErr TTDSP_EXPORT TTObjectBaseInstantiate(const TTSymbol& className, TTAudioObjectBasePtr* returnedObjectPtr, const TTValue& arguments);
120 TTErr TTDSP_EXPORT TTObjectBaseInstantiate(const TTSymbol& className, TTAudioSignalPtr* returnedObjectPtr, const TTValue& arguments);
121 TTErr TTDSP_EXPORT TTObjectBaseInstantiate(const TTSymbol& className, TTAudioObjectBasePtr* returnedObjectPtr, const TTUInt16 arguments);
122 TTErr TTDSP_EXPORT TTObjectBaseInstantiate(const TTSymbol& className, TTAudioSignalPtr* returnedObjectPtr, const TTUInt16 arguments);
123 
124 
125 /** Create a reference to an object.
126  @param anObject The object that we want to reference.
127  @return Pointer to the object.
128  */
131 
132 
133 /** Release (destroy) an object.
134  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
135  */
136 TTErr TTDSP_EXPORT TTObjectBaseRelease(TTAudioObjectBasePtr* anObject);
137 TTErr TTDSP_EXPORT TTObjectBaseRelease(TTAudioSignalPtr* anObject);
138 
139 
140 
141 
142 // TODO: WHy are the following two methods declared in Jamoma DSP rather than Jamoma Foundation?
143 // This seems to be the kind of low-leven non-fun stuff that Foundation is supposed to take care of? [TL]
144 
145 /** Allocate memory with 16-byte alignment. This memory must be freed using TTFree16()
146  @param numBytes The number of bytes to be allocated.
147  @return Pointer to the allocated memory.
148  */
149 TTPtr TTMalloc16(size_t numBytes);
150 
151 
152 /** Free 16-byte aligned memory alloc'd by TTMalloc16().
153  @param ptr Pointer to the memory to be freed.
154  */
155 void TTFree16(TTPtr ptr);
156 
157 
158 #endif // __TTDSP_H__
std::uint16_t TTUInt16
16 bit unsigned integer
Definition: TTBase.h:176
TTPtr TTMalloc16(size_t numBytes)
Allocate memory with 16-byte alignment.
Definition: TTBase.cpp:641
TTAudioObjectBase is the base class for all audio generating and processing objects in Jamoma DSP...
TTErr TTDSP_EXPORT TTObjectBaseInstantiate(const TTSymbol &className, TTAudioObjectBasePtr *returnedObjectPtr, TTValue &arguments)
Instantiate an object.
Definition: TTDSP.cpp:88
void TTFree16(TTPtr ptr)
Free 16-byte aligned memory alloc'd by TTMalloc16().
Definition: TTBase.cpp:647
TTAudioObjectBase is the Jamoma DSP Audio Object Base Class
TTAudioObjectBasePtr TTDSP_EXPORT TTObjectBaseReference(TTAudioObjectBasePtr anObject)
Create a reference to an object.
Definition: TTDSP.cpp:128
void * TTPtr
A generic pointer.
Definition: TTBase.h:248
The TTSymbol class is used to represent a string and efficiently pass and compare that string...
Definition: TTSymbol.h:26
Container for an array of TTAudioSignal pointers.
The TTAudioSignal class represents N vectors of audio samples for M channels.
Definition: TTAudioSignal.h:57
void TTDSP_EXPORT TTDSPInit(const char *pathToBinaries=NULL)
Initialise the Jamoma DSP library, as well as Jamoma Foundation foundation if needed.
Definition: TTDSP.cpp:30
Represents M channels containing N vectors of audio samples.
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
Definition: TTBase.h:342
TTErr TTDSP_EXPORT TTObjectBaseRelease(TTAudioObjectBasePtr *anObject)
Release (destroy) an object.
Definition: TTDSP.cpp:142
TTAudioObjectBase is the Jamoma DSP Audio Object Base Class
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34