24 TTPtr graphOutlets[2];
27 t_object* patcherview;
30 typedef MidiIn* MidiInPtr;
34 MidiInPtr MidiInNew (t_symbol* msg,
long argc, t_atom* argv);
35 void MidiInFree (MidiInPtr
self);
36 void PackStartTracking (MidiInPtr
self);
37 t_max_err PackNotify (MidiInPtr
self, t_symbol* s, t_symbol* msg, t_object* sender,
TTPtr data);
38 void PackQFn (MidiInPtr
self);
39 void MidiInAssist (MidiInPtr
self,
void* b,
long msg,
long arg,
char* dst);
40 void MidiInGetDeviceNames (MidiInPtr
self);
42 t_max_err MidiInSetDevice (MidiInPtr
self,
void* attr,
long argc, t_atom* argv);
43 t_max_err MidiInGetDevice (MidiInPtr
self,
void* attr,
long* argc, t_atom** argv);
47 static t_class* sMidiInClass;
58 common_symbols_init();
60 c = class_new(
"j.midi.in-", (method)MidiInNew, (method)MidiInFree,
sizeof(MidiIn), (method)0L, A_GIMME, 0);
62 class_addmethod(c, (method)MidiInGetDeviceNames,
"getAvailableDeviceNames", 0);
63 class_addmethod(c, (method)MaxGraphReset,
"graph.reset", A_CANT, 0);
64 class_addmethod(c, (method)MaxGraphSetup,
"graph.setup", A_CANT, 0);
65 class_addmethod(c, (method)MaxGraphDrop,
"graph.drop", A_CANT, 0);
66 class_addmethod(c, (method)MaxGraphObject,
"graph.object", A_CANT, 0);
67 class_addmethod(c, (method)PackNotify,
"notify", A_CANT, 0);
68 class_addmethod(c, (method)MidiInAssist,
"assist", A_CANT, 0);
69 class_addmethod(c, (method)object_obex_dumpout,
"dumpout", A_CANT, 0);
71 CLASS_ATTR_SYM(c,
"device", 0, MidiIn, obj);
72 CLASS_ATTR_ACCESSORS(c,
"device", MidiInGetDevice, MidiInSetDevice);
74 class_register(_sym_box, c);
83 MidiInPtr MidiInNew(t_symbol* msg,
long argc, t_atom* argv)
85 MidiInPtr
self = MidiInPtr(object_alloc(sMidiInClass));
90 object_obex_store((
void*)
self, _sym_dumpout, (t_object*)outlet_new(
self, NULL));
91 self->graphOutlets[0] = outlet_new(
self,
"graph.connect");
97 self->graphObject->mKernel.set(
TT(
"owner"),
TTPtr(self->graphObject));
99 if (!self->graphObject->mKernel.valid()) {
100 object_error(SELF,
"cannot load Jamoma object");
106 self->graphDictionary->append(
TT(
"outlet"), 0);
108 attr_args_process(
self, argc, argv);
110 self->qelem = qelem_new(
self, (method)PackQFn);
111 defer_low(
self, (method)PackStartTracking, NULL, 0, NULL);
117 void MidiInFree(MidiInPtr
self)
120 qelem_free(self->qelem);
130 t_max_err PackNotify(MidiInPtr
self, t_symbol* s, t_symbol* msg, t_object* sender,
TTPtr data)
132 if (sender == self->patcherview) {
133 if (msg == _sym_attr_modified) {
134 t_symbol* name = (t_symbol*)object_method((t_object*)data, _sym_getname);
135 if (name == _sym_dirty) {
136 qelem_set(self->qelem);
139 else if (msg == _sym_free)
140 self->patcherview = NULL;
143 if (msg == _sym_free) {
145 t_object* sourceObject;
148 t_object* destObject;
151 #ifdef DEBUG_NOTIFICATIONS
152 object_post(SELF,
"patch line deleted");
153 #endif // DEBUG_NOTIFICATIONS
156 sourceBox = jpatchline_get_box1(sender);
160 sourceObject = jbox_get_object(sourceBox);
161 sourceOutlet = jpatchline_get_outletnum(sender);
162 destBox = jpatchline_get_box2(sender);
165 destObject = jbox_get_object(destBox);
166 destInlet = jpatchline_get_inletnum(sender);
169 if ( zgetfn(sourceObject, gensym(
"graph.object")) && zgetfn(destObject, gensym(
"graph.object")) ) {
170 #ifdef DEBUG_NOTIFICATIONS
171 object_post(SELF,
"deleting graph patchline!");
172 #endif // DEBUG_NOTIFICATIONS
174 object_method(destObject, gensym(
"graph.drop"), destInlet, sourceObject, sourceOutlet);
184 void PackIterateResetCallback(MidiInPtr
self, t_object* obj)
186 t_max_err err = MAX_ERR_NONE;
187 method graphResetMethod = zgetfn(obj, gensym(
"graph.reset"));
189 if (graphResetMethod)
190 err = (t_max_err)graphResetMethod(obj);
194 void PackIterateSetupCallback(MidiInPtr
self, t_object* obj)
196 t_max_err err = MAX_ERR_NONE;
197 method graphSetupMethod = zgetfn(obj, gensym(
"graph.setup"));
199 if (graphSetupMethod)
200 err = (t_max_err)graphSetupMethod(obj);
204 void PackAttachToPatchlinesForPatcher(MidiInPtr
self, t_object* patcher)
206 t_object* patchline = object_attr_getobj(patcher, _sym_firstline);
207 t_object* box = jpatcher_get_firstobject(patcher);
210 object_attach_byptr_register(
self, patchline, _sym_nobox);
211 patchline = object_attr_getobj(patchline, _sym_nextline);
215 t_symbol* classname = jbox_get_maxclass(box);
217 if (classname == _sym_jpatcher) {
218 t_object* subpatcher = jbox_get_object(box);
220 PackAttachToPatchlinesForPatcher(
self, subpatcher);
222 box = jbox_get_nextobject(box);
228 void PackQFn(MidiInPtr
self)
232 #ifdef DEBUG_NOTIFICATIONS
233 object_post(SELF,
"patcher dirtied");
234 #endif // DEBUG_NOTIFICATIONS
236 object_method(self->patcher, gensym(
"iterate"), (method)PackIterateSetupCallback,
self, PI_DEEP, &result);
240 PackAttachToPatchlinesForPatcher(
self, self->patcher);
245 void PackStartTracking(MidiInPtr
self)
247 t_object* patcher = NULL;
248 t_object* parent = NULL;
249 t_object* patcherview = NULL;
254 err = object_obex_lookup(
self, gensym(
"#P"), &patcher);
258 parent = object_attr_getobj(patcher, _sym_parentpatcher);
262 object_method(patcher, gensym(
"iterate"), (method)PackIterateResetCallback,
self, PI_DEEP, &result);
263 object_method(patcher, gensym(
"iterate"), (method)PackIterateSetupCallback,
self, PI_DEEP, &result);
268 if (!self->patcherview) {
269 patcherview = jpatcher_get_firstview(patcher);
270 self->patcherview = patcherview;
271 self->patcher = patcher;
272 object_attach_byptr_register(
self, patcherview, _sym_nobox);
277 PackAttachToPatchlinesForPatcher(
self, self->patcher);
284 void MidiInAssist(MidiInPtr
self,
void* b,
long msg,
long arg,
char* dst)
287 strcpy(dst,
"multichannel audio connection and control messages");
290 strcpy(dst,
"stats on DSP graph");
292 strcpy(dst,
"dumpout");
298 void MidiInGetDeviceNames(MidiInPtr
self)
306 err =
self->graphObject->mKernel.send(
TT(
"getAvailableDeviceNames"), none, v);
311 for (
long i=0; i<ac; i++) {
313 atom_setsym(ap+i, gensym((
char*)name.
c_str()));
315 object_obex_dumpout(
self, gensym(
"getAvailableDeviceNames"), ac, ap);
321 t_max_err MidiInSetDevice(MidiInPtr
self,
void* attr,
long argc, t_atom* argv)
324 t_symbol* s = atom_getsym(argv);
325 self->graphObject->mKernel.set(
TT(
"device"),
TT(s->s_name));
331 t_max_err MidiInGetDevice(MidiInPtr
self,
void* attr,
long* argc, t_atom** argv)
336 self->graphObject->mKernel.get(
TT(
"device"), v);
339 return MAX_ERR_GENERIC;
343 *argv = (t_atom *)sysmem_newptr(
sizeof(t_atom));
344 atom_setsym(*argv, gensym((
char*)s.
c_str()));
The TTGraphObjectBase wraps a TTDSP object such that it is possible to build a dynamic graph of audio...
TTErr TTObjectBaseRelease(TTObjectBasePtr *anObject)
DEPRECATED.
size_type size() const noexcept
Return the number of elements.
Base class for all first-class Jamoma objects.
int C74_EXPORT main(void)
Set up this class as a Max external the first time an object of this kind is instantiated.
#define TT
This macro is defined as a shortcut for doing a lookup in the symbol table.
A type that represents the key as a C-String and the value as a pointer to the matching TTSymbol obje...
void * TTPtr
A generic pointer.
The TTSymbol class is used to represent a string and efficiently pass and compare that string...
TTErr TTObjectBaseInstantiate(const TTSymbol className, TTObjectBasePtr *returnedObjectPtr, const TTValue arguments)
DEPRECATED.
const char * c_str() const
Return a pointer to the internal string as a C-string.
TTErr setSchema(const TTSymbol aSchemaName)
TODO: Add documentation schemaName TODO: Add documentation.
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
void resize(size_type n)
Change the number of elements.
[doxygenAppendixC_copyExample]