read interp fract

read from table, linear interpolated.'offset' and 'range' define the area inside the table to read from.
Author: Robert Schirmer
License: BSD
Github: rbrt/testing/read interp fract.axo

Inlets

frac32buffer.positive index in fraction of table size

frac32.positive offset

frac32.positive range

Outlets

frac32buffer table[a]

Attributes

objref table

Declaration
int32_t max;
int32_t offset;
uint8_t shift;
Init
shift = 27 - attr_table.LENGTHPOW;
Control Rate
offset = ___SMMUL(inlet_offset, (attr_table.LENGTH << 5));

// this is NOT an elegant solution
if (inlet_range == (1 << 27) - 1)
  max = ___SMMUL(inlet_range, (attr_table.LENGTH << 5)) + offset + 1;
else
  max = ___SMMUL(inlet_range, (attr_table.LENGTH << 5)) + offset;
Audio Rate
uint32_t phase =
    __USAT((___SMMUL(inlet_phase, inlet_range) << 5) + inlet_offset, 27);

int index = phase >> shift;
int index2;
// this is also not the best I guess.but it works (;
if ((index + 1) < max)
  index2 = index + 1;
else
  index2 = offset;

int32_t y1 = attr_table.array[index] << attr_table.GAIN;
int32_t y2 = attr_table.array[index2] << attr_table.GAIN;

int frac = (phase - (index << shift)) << (attr_table.LENGTHPOW + 3);
int32_t rr;
rr = ___SMMUL(y1, (1 << 30) - frac);
rr = ___SMMLA(y2, frac, rr);
outlet_out = rr << 2;

Privacy

© 2024 Zrna Research