29 t_symbol* attrOperator;
36 OpPtr OpNew (t_symbol* msg,
long argc, t_atom* argv);
37 void OpFree (OpPtr
self);
38 void OpAssist (OpPtr
self,
void* b,
long msg,
long arg,
char* dst);
39 TTErr OpResetAudio (OpPtr
self,
long vectorSize);
40 TTErr OpSetupAudio (OpPtr
self);
43 TTErr OpDropAudio (OpPtr
self,
long inletNumber, t_object* sourceMaxObject,
long sourceOutletNumber);
44 t_max_err OpSetOperator (OpPtr
self,
void* attr,
long argc, t_atom* argv);
45 t_max_err OpGetOperator (OpPtr
self, t_object* attr,
long* argc, t_atom** argv);
46 t_max_err OpSetOperand (OpPtr
self,
void* attr,
long argc, t_atom* argv);
47 t_max_err OpGetOperand (OpPtr
self, t_object* attr,
long* argc, t_atom** argv);
51 static t_class* sOpClass;
62 common_symbols_init();
64 c = class_new(
"j.op=", (method)OpNew, (method)OpFree,
sizeof(Op), (method)0L, A_GIMME, 0);
66 class_addmethod(c, (method)OpResetAudio,
"audio.reset", A_CANT, 0);
67 class_addmethod(c, (method)OpSetupAudio,
"audio.setup", A_CANT, 0);
68 class_addmethod(c, (method)OpConnectAudio,
"audio.connect", A_OBJ, A_LONG, 0);
69 class_addmethod(c, (method)OpDropAudio,
"audio.drop", A_CANT, 0);
73 class_addmethod(c, (method)MaxGraphConnect,
"graph.connect", A_OBJ, A_LONG, 0);
74 class_addmethod(c, (method)MaxGraphDrop,
"graph.drop", A_CANT, 0);
75 class_addmethod(c, (method)MaxGraphObject,
"graph.object", A_CANT, 0);
76 class_addmethod(c, (method)OpAssist,
"assist", A_CANT, 0);
77 class_addmethod(c, (method)object_obex_dumpout,
"dumpout", A_CANT, 0);
79 CLASS_ATTR_SYM(c,
"operator", 0, Op, attrOperator);
80 CLASS_ATTR_ACCESSORS(c,
"operator", OpGetOperator, OpSetOperator);
81 CLASS_ATTR_ENUM(c,
"operator", 0,
"+ - * / % > >= == != <= < abs acos asin atan ceil cos cosh exp floor log log10 sin sinh sqrt tan tanh");
83 CLASS_ATTR_FLOAT(c,
"operand", 0, Op, attrOperand);
84 CLASS_ATTR_ACCESSORS(c,
"operand", OpGetOperand, OpSetOperand);
86 class_register(_sym_box, c);
95 OpPtr OpNew(t_symbol* msg,
long argc, t_atom* argv)
101 self = OpPtr(object_alloc(sOpClass));
103 object_obex_store((
void*)
self, _sym_dumpout, (t_object*)outlet_new(
self, NULL));
104 self->outlet = outlet_new(
self,
"audio.connect");
105 self->inlet = proxy_new(
self, 1, &self->inletnum);
112 if (!self->audioGraphObject->getUnitGenerator().valid()) {
113 object_error(SELF,
"cannot load Jamoma DSP object");
117 attr_args_process(
self, argc, argv);
124 void OpFree(OpPtr
self)
127 object_free(self->inlet);
135 void OpAssist(OpPtr
self,
void* b,
long msg,
long arg,
char* dst)
138 strcpy (dst,
"multichannel input and control messages");
141 strcpy(dst,
"multichannel output");
143 strcpy(dst,
"dumpout");
150 TTErr OpResetAudio(OpPtr
self,
long vectorSize)
152 self->audioGraphObject->setAttributeValue(
TT(
"numAudioInlets"), 1);
153 return self->audioGraphObject->resetAudio();
157 TTErr OpSetupAudio(OpPtr
self)
161 atom_setobj(a+0, (t_object*)(self->audioGraphObject));
162 atom_setlong(a+1, 0);
163 outlet_anything(self->outlet, gensym(
"audio.connect"), 2, a);
187 long inletNumber = proxy_getinlet(SELF);
189 if (inletNumber == 1)
190 self->audioGraphObject->setAttributeValue(
TT(
"numAudioInlets"), 2);
191 return self->audioGraphObject->connectAudio(audioSourceObject, sourceOutletNumber, inletNumber);
195 TTErr OpDropAudio(OpPtr
self,
long inletNumber, t_object* sourceMaxObject,
long sourceOutletNumber)
200 if (inletNumber == 1)
202 err = (
TTErr)
TTPtrSizedInt(object_method(sourceMaxObject, gensym(
"audio.object"), &sourceObject));
203 if (self->audioGraphObject && sourceObject && !err)
204 err =
self->audioGraphObject->dropAudio(sourceObject, sourceOutletNumber, inletNumber);
211 t_max_err OpSetOperator(OpPtr
self,
void* attr,
long argc, t_atom* argv)
214 self->attrOperator = atom_getsym(argv);
215 self->audioGraphObject->getUnitGenerator().set(
TT(
"operator"),
TT(self->attrOperator->s_name));
221 t_max_err OpGetOperator(OpPtr
self, t_object* attr,
long* argc, t_atom** argv)
225 self->audioGraphObject->getUnitGenerator().
get(
TT(
"operator"), v);
229 *argv = (t_atom *)sysmem_newptr(
sizeof(t_atom) * v.
size());
235 atom_setfloat(*argv+i, value);
240 atom_setsym(*argv+i, gensym((
char*)value.
c_str()));
245 atom_setlong(*argv+i, value);
251 t_max_err OpSetOperand(OpPtr
self,
void* attr,
long argc, t_atom* argv)
254 self->attrOperand = atom_getfloat(argv);
255 self->audioGraphObject->getUnitGenerator().set(
TT(
"operand"), self->attrOperand);
261 t_max_err OpGetOperand(OpPtr
self, t_object* attr,
long* argc, t_atom** argv)
265 self->audioGraphObject->getUnitGenerator().
get(
TT(
"operand"), v);
269 *argv = (t_atom *)sysmem_newptr(
sizeof(t_atom) * v.
size());
275 atom_setfloat(*argv+i, value);
280 atom_setsym(*argv+i, gensym((
char*)value.
c_str()));
285 atom_setlong(*argv+i, value);
TTErr TTObjectBaseRelease(TTObjectBasePtr *anObject)
DEPRECATED.
TTErr MaxAudioGraphReset(t_object *x, long vectorSize)
Clear the list of source objects from which this object will try to pull audio.
size_type size() const noexcept
Return the number of elements.
Base class for all first-class Jamoma objects.
TTErr setAttributeValue(const TTSymbol name, TTValue &value)
Set an attribute value for an object.
double TTFloat64
64 bit floating point number
#define TT
This macro is defined as a shortcut for doing a lookup in the symbol table.
void * TTPtr
A generic pointer.
The TTSymbol class is used to represent a string and efficiently pass and compare that string...
float TTFloat32
32 bit floating point number
TTErr TTObjectBaseInstantiate(const TTSymbol className, TTObjectBasePtr *returnedObjectPtr, const TTValue arguments)
DEPRECATED.
void get(const TTUInt16 index, T &returnedElementValue) const
DEPRECATED.
const char * c_str() const
Return a pointer to the internal string as a C-string.
std::int32_t TTInt32
32 bit signed integer
A thin wrapper of Jamoma AudioGraph for use in the Cycling '74 Max/MSP environment.
TTErr MaxAudioGraphObject(t_object *x, TTAudioGraphObjectBasePtr *returnedAudioGraphObject)
Returns a pointer to the Jamoma Audio Graph object that is wrapped by this Max object.
long TTPtrSizedInt
An integer that is the same size as a pointer.
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
The TTAudioGraphObjectBase wraps a TTDSP object such that it is possible to build a dynamic graph of ...
std::uint32_t TTUInt32
32 bit unsigned integer
int C74_EXPORT main(void)
Set up this class as a Max external the first time an object of this kind is instantiated.
void resize(size_type n)
Change the number of elements.
[doxygenAppendixC_copyExample]