Jamoma API  0.6.0.a19
PureAudioGraph.h
1 /*
2  * PureAudioGraph
3  * A thin wrapper of Jamoma AudioGraph for use in the PureData environment.
4  * Includes an automated class wrapper to make Jamoma DSP objects available as objects for Pd.
5  * Copyright © 2010 by Timothy Place
6  *
7  * License: This code is licensed under the terms of the "New BSD License"
8  * http://creativecommons.org/licenses/BSD/
9  */
10 
11 #ifndef __PURE_AUDIOGRAPH_H__
12 #define __PURE_AUDIOGRAPH_H__
13 
14 #include "m_pd.h"
15 #include "TTAudioGraphAPI.h" // Definitions for Jamoma AudioGraph
16 
17 
18 
19 // TYPE DEFINITIONS
20 
21 typedef t_class* ClassPtr;
22 typedef t_object Object;
23 typedef t_object* ObjectPtr;
24 typedef t_symbol* SymbolPtr;
25 typedef t_atom Atom;
26 typedef t_atom* AtomPtr;
27 typedef long AtomCount;
28 typedef int MaxErr;
29 #ifndef SELF
30 #define SELF ObjectPtr(self)
31 #endif
32 
33 typedef TTErr (*TTValidityCheckFunction)(const TTPtr data); ///< A type that can be used to store a pointer to a validity checking function.
34 
35 class WrappedClassOptions;
36 
37 typedef struct _wrappedClass {
38  ClassPtr maxClass; ///< The Max class pointer.
39  SymbolPtr maxClassName; ///< The name to give the Max class.
40  TTSymbolPtr ttClassName; ///< The name of the class as registered with the TTBlue framework.
41  TTValidityCheckFunction validityCheck; ///< A function to call to validate the context for an object before it is instantiated.
42  TTPtr validityCheckArgument; ///< An argument to pass to the validityCheck function when it is called.
43  WrappedClassOptions* options; ///< Additional configuration options specified for the class.
44 // t_hashtab* maxAttrNamesToTTAttrNames; ///< names may not be direct mappings, as we downcase the first letter.
45  TTHashPtr pdAttrNamesToTTAttrNames;
46 } WrappedClass;
47 
48 
49 
50 class WrappedClassOptions {
51 protected:
52  TTHash* options;
53 
54 public:
55  WrappedClassOptions()
56  {
57  options = new TTHash;
58  }
59 
60  virtual ~WrappedClassOptions()
61  {
62  delete options;
63  }
64 
65  TTErr append(const TTSymbolPtr optionName, const TTValue& optionValue)
66  {
67  return options->append(optionName, optionValue);
68  }
69 
70  /** Returns an error if the requested option doesn't exist. */
71  TTErr lookup(const TTSymbolPtr optionName, TTValue& optionValue)
72  {
73  return options->lookup(optionName, optionValue);
74  }
75 
76 };
77 
78 
79 typedef WrappedClass* WrappedClassPtr; ///< A pointer to a WrappedClass.
80 typedef WrappedClassOptions* WrappedClassOptionsPtr; ///< A pointer to WrappedClassOptions.
81 
82 
83 // FUNCTIONS
84 
85 // Wrap a Jamoma DSP class as a Max class.
86 TTErr wrapAsMaxAudioGraph(TTSymbolPtr ttClassName, char* maxClassName, WrappedClassPtr* c);
87 
88 // This version can be passed a method that is called to make sure it is legit to instantiate the class.
89 TTErr wrapAsMaxAudioGraph(TTSymbolPtr ttClassName, char* maxClassName, WrappedClassPtr* c, TTValidityCheckFunction validityCheck);
90 
91 // This version can be passed a method that is called to make sure it is legit to instantiate the class.
92 TTErr wrapAsMaxAudioGraph(TTSymbolPtr ttClassName, char* maxClassName, WrappedClassPtr* c, TTValidityCheckFunction validityCheck, TTPtr validityCheckArgument);
93 
94 
95 // These are versions of the above, but for which additional options can be specified.
96 TTErr wrapAsMaxAudioGraph(TTSymbolPtr ttblueClassName, char* maxClassName, WrappedClassPtr* c, WrappedClassOptionsPtr options);
97 TTErr wrapAsMaxAudioGraph(TTSymbolPtr ttblueClassName, char* maxClassName, WrappedClassPtr* c, TTValidityCheckFunction validityCheck, WrappedClassOptionsPtr options);
98 TTErr wrapAsMaxAudioGraph(TTSymbolPtr ttblueClassName, char* maxClassName, WrappedClassPtr* c, TTValidityCheckFunction validityCheck, TTPtr validityCheckArgument, WrappedClassOptionsPtr options);
99 
100 
101 // NOTE: DUPLICATIONS FROM THE MSP WRAPPER
102 
103 #ifdef __LP64__
104 TTInt64 AtomGetInt(AtomPtr a);
105 #else
106 int AtomGetInt(AtomPtr a);
107 #endif
108 
109 
110 #endif // __PURE_AUDIOGRAPH_H__
111 
TTErr lookup(const TTSymbol key, TTValue &value)
Find the value for the given key.
Definition: TTHash.cpp:76
Provides all necessary definitions for AudioGraph API.
TTErr wrapAsMaxAudioGraph(TTSymbol ttClassName, char *maxClassName, MaxAudioGraphWrappedClassPtr *c)
Wrap an AudioGraph class as a Max class.
Maintain a collection of TTValue objects indexed by TTSymbol pointers.
Definition: TTHash.h:36
void * TTPtr
A generic pointer.
Definition: TTBase.h:248
std::int64_t TTInt64
64 bit signed integer
Definition: TTBase.h:179
TTErr(* TTValidityCheckFunction)(const TTPtr data)
A type that can be used to store a pointer to a validity checking function.
Definition: MaxAudioGraph.h:36
TTErr append(const TTSymbol key, const TTValue &value)
Insert an item into the hash table.
Definition: TTHash.cpp:70
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
Definition: TTBase.h:342
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34