19 typedef struct _cubic_interp{
30 void *cubic_interpolate_new(t_symbol *msg,
long argc, t_atom *argv);
31 t_max_err cubic_interpolation_setstep(t_cubic_interp *x,
void *attr,
long argc, t_atom *argv);
32 void cubic_interpolate_bang(t_cubic_interp *x);
33 void cubic_interpolate_int(t_cubic_interp *x,
long n);
34 void cubic_interpolate_float(t_cubic_interp *x,
double f);
35 void cubic_interpolate_clear(t_cubic_interp *x);
36 void cubic_interpolate_assist(t_cubic_interp *x,
void *b,
long msg,
long arg,
char *dst);
48 int JAMOMA_EXPORT_MAXOBJ
main(
void)
54 common_symbols_init();
57 c = class_new(
"j.cubicInterpolate",(method)cubic_interpolate_new, (method)0L,
sizeof(t_cubic_interp),
58 (method)0L, A_GIMME, 0);
61 class_addmethod(c, (method)cubic_interpolate_bang,
"bang", A_CANT, 0);
62 class_addmethod(c, (method)cubic_interpolate_int,
"int", A_LONG, 0);
63 class_addmethod(c, (method)cubic_interpolate_float,
"float", A_FLOAT, 0);
64 class_addmethod(c, (method)cubic_interpolate_assist,
"assist", A_CANT, 0);
65 class_addmethod(c, (method)cubic_interpolate_clear,
"clear", 0);
66 class_addmethod(c, (method)object_obex_dumpout,
"dumpout", A_CANT, 0);
70 attr = attr_offset_new(
"step", _sym_float, attrflags,
71 (method)0L, (method)cubic_interpolation_setstep, calcoffset(t_cubic_interp, attr_step));
72 class_addattr(c, attr);
75 class_register(CLASS_BOX, c);
84 void *cubic_interpolate_new(t_symbol *msg,
long argc, t_atom *argv)
88 x = (t_cubic_interp *)object_alloc(
this_class);
91 object_obex_store((
void *)x, _sym_dumpout, (
object *)outlet_new(x,NULL));
92 x->outlet2 = bangout(x);
93 x->outlet = floatout(x);
94 cubic_interpolate_clear(x);
96 attr_args_process(x, argc, argv);
107 t_max_err cubic_interpolation_setstep(t_cubic_interp *x,
void *attr,
long argc, t_atom *argv)
111 f = atom_getfloat(argv);
120 void cubic_interpolate_bang(t_cubic_interp *x)
122 double y0, y1, y2, y3, mu, mu2;
126 outlet_bang(x->outlet2);
128 outlet_float(x->outlet, 0);
137 mu = x->mu + x->attr_step;
139 outlet_bang(x->outlet2);
149 a0 = y3 - y2 - y0 + y1;
154 outlet_float(x->outlet, a0*mu*mu2+a1*mu2+a2*mu+a3);
160 void cubic_interpolate_int(t_cubic_interp *x,
long n)
162 cubic_interpolate_float(x, (
double)n);
167 void cubic_interpolate_float(t_cubic_interp *x,
double f)
178 x->value[i] = x->value[i+1];
185 void cubic_interpolate_clear(t_cubic_interp *x)
193 void cubic_interpolate_assist(t_cubic_interp *x,
void *b,
long msg,
long arg,
char *dst)
199 case 0: strcpy(dst,
"(bang/float) interpolate, set next");
207 case 0: strcpy(dst,
"(float) interpolated value");
break;
208 case 1: strcpy(dst,
"(bang) need new target value");
break;
209 case 2: strcpy(dst,
"dumpout");
break;
int JAMOMA_EXPORT_MAXOBJ main(void)
Set up this class as a Max external the first time an object of this kind is instantiated.
t_class * this_class
Required. Global pointing to this class.