-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathexample.cpp
More file actions
42 lines (37 loc) · 1.07 KB
/
example.cpp
File metadata and controls
42 lines (37 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "../maxcpp/maxcpp6.h"
class Example : public MaxCpp6<Example> {
public:
Example(t_symbol * sym, long ac, t_atom * av) {
setupIO(2, 2); // inlets / outlets
}
~Example() {}
// methods:
void bang(long inlet) {
outlet_bang(m_outlets[0]);
}
void assist(void *b, long m, long a, char *s) //inlet-outlet assistant
{
if (m == ASSIST_INLET) // inlet
sprintf(s, "input %i", a);
else // outlet
sprintf(s, "output");
}
void testfloat(long inlet, double v) {
outlet_float(m_outlets[0], v);
}
void testint(long inlet, long v) {
outlet_int(m_outlets[0], v);
}
void test(long inlet, t_symbol * s, long ac, t_atom * av) {
outlet_anything(m_outlets[1], gensym("test"), ac, av);
}
};
C74_EXPORT int main(void) {
// create a class with the given name:
Example::makeMaxClass("example");
REGISTER_METHOD(Example, bang);
REGISTER_METHOD_ASSIST(Example, assist);
REGISTER_METHOD_FLOAT(Example, testfloat);
REGISTER_METHOD_LONG(Example, testint);
REGISTER_METHOD_GIMME(Example, test);
}