19 #define MAX_MESS_SIZE 2048
21 typedef struct _oscinstance{
26 void *outlet_overflow;
49 t_class *oscinstance_class;
55 int JAMOMA_EXPORT_MAXOBJ
main(
void)
60 common_symbols_init();
62 c = class_new(
"j.oscinstance",(method)
oscinstance_new, (method)0L,
sizeof(t_oscinstance), (method)0L, A_GIMME, 0);
68 class_addmethod(c, (method)oscinstance_symbol,
"anything", A_GIMME, 0L);
70 class_addmethod(c, (method)object_obex_dumpout,
"dumpout", A_CANT,0);
73 class_register(CLASS_BOX, c);
74 oscinstance_class = c;
84 t_oscinstance *x = (t_oscinstance *)object_alloc(oscinstance_class);
87 x->outlet_overflow = outlet_new(x, 0);
88 object_obex_store((
void *)x, _sym_dumpout, (
object *)x->outlet_overflow);
89 x->outlet2 = outlet_new(x, 0);
90 x->outlet1 = outlet_new(x, 0);
91 x->outlet0 = outlet_new(x, 0);
104 strcpy(dst,
"Input");
107 strcpy(dst,
"OSC message with instance info stripped");
109 strcpy(dst,
"OSC instance number or ID");
111 strcpy(dst,
"parameter value");
113 strcpy(dst,
"dumpout / overflow from non-matching input");
120 outlet_bang(x->outlet_overflow);
127 outlet_int(x->outlet_overflow, n);
134 outlet_float(x->outlet_overflow, f);
141 char input[MAX_MESS_SIZE];
142 char *input2 = input;
148 t_symbol *
osc = NULL;
152 strcpy(input, msg->s_name);
163 leadingSlash = *input2 ==
'/';
167 dot = strchr(input2,
'.');
171 slash = strchr(input2,
'/');
175 osc = gensym(input2 - leadingSlash);
176 instance = gensym(dot+1);
183 instance = gensym(dot+1);
185 strcat(input, slash);
186 osc = gensym(input2 - leadingSlash);
194 outlet_bang(x->outlet2);
199 if (argv->a_type==A_LONG)
200 outlet_int(x->outlet2,argv->a_w.w_long);
202 else if (argv->a_type==A_FLOAT)
203 outlet_float(x->outlet2,argv->a_w.w_float);
205 else if (argv->a_type==A_SYM)
206 outlet_anything(x->outlet2,argv->a_w.w_sym,0,0);
210 if (argv->a_type==A_SYM) {
211 output = argv->a_w.w_sym;
217 outlet_anything(x->outlet2, output, argc , argv);
221 i = strtol (instance->s_name,&instanceEnd,10);
222 if (instance->s_name[0] !=
'\n' && (*instanceEnd ==
'\n' || *instanceEnd ==
'\0'))
223 outlet_int(x->outlet1, i);
225 outlet_anything(x->outlet1, instance, NULL, 0L);
228 outlet_anything(x->outlet0, osc, NULL, 0L);
232 outlet_anything(x->outlet_overflow, msg, argc , argv);
void oscinstance_symbol(t_oscinstance *x, t_symbol *msg, long argc, t_atom *argv)
Method for anything else, including OSC messages.
void * oscinstance_new(t_symbol *s, long argc, t_atom *argv)
The j.oscinstance constructor.
void oscinstance_bang(t_oscinstance *x)
Method for bang input.
void oscinstance_assist(t_oscinstance *x, void *b, long msg, long arg, char *dst)
Provide assistance strings in the patcher window.
void oscinstance_float(t_oscinstance *x, double f)
Method for int float.
int JAMOMA_EXPORT_MAXOBJ main(void)
Set up this class as a Max external the first time an object of this kind is instantiated.
void oscinstance_int(t_oscinstance *x, long n)
Method for int input.