{
t_object x_obj;
aubio_sampler_t *o;
+ t_symbol *x_arrayname;
+ fvec_t *table;
t_inlet *inlet_s;
t_inlet *inlet_t;
t_outlet *outlet;
smpl_t transpose;
} t_aubiosampler_tilde;
+static void * aubiosampler_tilde_set_table (t_aubiosampler_tilde *x, t_symbol *s);
+
static t_int *
aubiosampler_tilde_perform (t_int * w)
{
output_vec.data = out;
output_vec.length = s_n;
+ aubio_sampler_set_stretch(x->o, x->stretch);
+ aubio_sampler_set_transpose(x->o, x->transpose);
aubio_sampler_do(x->o, &output_vec, &read);
/* signal the end of file with a bang */
static void
aubiosampler_tilde_dsp (t_aubiosampler_tilde * x, t_signal ** sp)
{
+ //if (x->x_arrayname) aubiosampler_tilde_set_table(x, x->x_arrayname);
dsp_add (aubiosampler_tilde_perform, 3, x, sp[0]->s_vec, sp[0]->s_n);
}
x->stretch = 1.;
x->o = new_aubio_sampler(sys_getblksize(), sys_getsr());
if (!x->o) return NULL;
+ x->table = NULL;
x->inlet_s = floatinlet_new (&x->x_obj, &x->stretch);
x->inlet_t = floatinlet_new (&x->x_obj, &x->transpose);
x->outlet = outlet_new(&x->x_obj, gensym("signal"));
}
}
+static void *
+aubiosampler_tilde_set_table (t_aubiosampler_tilde *x, t_symbol *s) {
+ t_garray *a;
+ x->x_arrayname = s;
+ uint_t length; t_word *data;
+ if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class))) {
+ if (*s->s_name)
+ pd_error(x, "aubiosampler~: %s: no such array", x->x_arrayname->s_name);
+ //x->table = NULL;
+ } else if (!garray_getfloatwords(a, &length, &data)) {
+ //} else if (!garray_getfloatwords(a, &x->table->length, (t_word **)&x->table->data)) {
+ pd_error(x, "aubiosampler~: bad template %s", x->x_arrayname->s_name);
+ //x->table = NULL;
+ } else {
+ post("aubiosampler~: table set to %s (%d long)", x->x_arrayname->s_name,
+ length);
+#if 0
+ x->table.length = length * 2;
+ x->table.data = (smpl_t*)data;
+ //pd_error(x, "aubiosampler~: table set to %s (%d long)", x->x_arrayname->s_name,
+ // x->table->length);
+ aubio_sampler_set_table(x->o, &x->table);
+#else
+ fvec_t *newtable = new_fvec(length), *oldtable = x->table;
+ uint_t i;
+ for (i = 0; i < length; i++) {
+ newtable->data[i] = data[i].w_float;
+ }
+ x->table = newtable;
+ aubio_sampler_set_table(x->o, x->table);
+ if (oldtable) del_fvec(oldtable);
+#endif
+ garray_usedindsp(a);
+ }
+}
+
void
aubiosampler_tilde_float(t_aubiosampler_tilde *x, t_floatarg f) {
if (f == 3) {
(t_method)aubiosampler_tilde_open, gensym ("open"), A_GIMME, 0);
class_addmethod (aubiosampler_tilde_class,
(t_method)aubiosampler_tilde_seek, gensym ("seek"), A_DEFFLOAT, 0);
+ class_addmethod(aubiosampler_tilde_class,
+ (t_method)aubiosampler_tilde_set_table, gensym("set"), A_SYMBOL, 0);
class_addmethod (aubiosampler_tilde_class,
(t_method)aubiosampler_tilde_dsp, gensym ("dsp"), A_CANT, 0);
}