@inari said:
However what's not clear is how these different sample rates get into the filter blocks, which use x_sr for calculating their coefficients.
But they also use c_coef and c_x which take current sample rate into account because they are type _samplerate. From d_ugen.c:
/* ------------------------ samplerate~~ -------------------------- */
static t_class *samplerate_tilde_class;
typedef struct _samplerate
{
t_object x_obj;
t_float x_sr;
t_canvas *x_canvas;
} t_samplerate;
static void samplerate_tilde_bang(t_samplerate *x)
{
outlet_float(x->x_obj.ob_outlet, canvas_getsr(x->x_canvas));
}
static void *samplerate_tilde_new(void)
{
t_samplerate *x = (t_samplerate *)pd_new(samplerate_tilde_class);
outlet_new(&x->x_obj, &s_float);
x->x_canvas = canvas_getcurrent();
return (x);
}
static void samplerate_tilde_setup(void)
{
samplerate_tilde_class = class_new(gensym("samplerate~"),
(t_newmethod)samplerate_tilde_new, 0, sizeof(t_samplerate), 0, 0);
class_addbang(samplerate_tilde_class, samplerate_tilde_bang);
}
/* -------------------- setup routine -------------------------- */
void d_ugen_setup(void)
{
block_tilde_setup();
samplerate_tilde_setup();
}
I think if you do the math it will work out but I could be missing something, OOP in C plus heavy pointer use plus math symbols thrown about with pointer symbols always leaves me a but unsure of what is going on if not completely lost.