I'm trying to modify the delay/read_interp
object so that it takes an amount of samples (or in other words amount of s-rate cycles) as parameter instead of the "kind of percentage" parameter it takes by default.
What I'd like to do is, say the delay/write
is 256
samples and I'd like to use half of that is pass 128
into the time
parameter.
This is the s-rate code from the delay/read_interp
object:
uint32_t tmp_d = __USAT(param_time + inlet_time,27);
uint32_t tmp_di = attr_delayname.writepos - (tmp_d>>(27-attr_delayname.LENGTHPOW)) - BUFSIZE + buffer_index -1;
uint32_t tmp_w1 = (tmp_d<<(attr_delayname.LENGTHPOW+3)) & 0x3FFFFFFF;
uint32_t tmp_w2 = (1<<30) - tmp_w1;
int32_t tmp_a1 = attr_delayname.array[tmp_di&attr_delayname.LENGTHMASK]<<16;
int32_t tmp_a2 = attr_delayname.array[(tmp_di+1)&attr_delayname.LENGTHMASK]<<16;
int32_t tmp_r = ___SMMUL(tmp_a1,tmp_w1);
tmp_r = ___SMMLA(tmp_a2,tmp_w2,tmp_r);
outlet_out= tmp_r;
I tried to make sense of it, but I have no clue why all the bitshifting is happening and where the (to me) "magic" values like 3
, 0x3FFFFFFF
and 30
come from.
Does anyone have an idea how to rewrite this so it takes samples/s-rate cycle count as input?