play pitch loop

play audio sample from table with pitch control, starting from position
Author: Johannes Taelman
License: BSD
Github: table/play pitch loop.axo

Inlets

bool32.rising start playback

bool32.rising stop playback

frac32.bipolar pitch modulation

frac32.positive start position in table

Outlets

frac32buffer wave

Parameters

frac32.s.map.pitch pitch

int32 loopstart

int32 loopend

Attributes

objref table

Declaration
int pstart;
int pstop;
uint64_t pos;
Init
pos = 0;
pstart = 0;
pstop = 1;
Control Rate
if ((inlet_start > 0) && !pstart) {
  pstart = 1;
  pstop = 0;
  uint32_t asat = __USAT(inlet_pos, 27);
  pos = ((uint64_t)(asat >> (27 - attr_table.LENGTHPOW))) << 32;
} else if (!(inlet_start > 0)) {
  pstart = 0;
}
if ((inlet_stop > 0) && !pstop) {
  pstop = 1;
  pstart = 0;
}
uint32_t f0;
MTOFEXTENDED(param_pitch + inlet_pitch, f0);
Audio Rate
if (!pstop) {
  if ((pos >> 32) < attr_table.LENGTH) {
    uint32_t r = ___SMMUL(attr_table.array[pos >> 32] << attr_table.GAIN,
                          INT32_MAX - (((uint32_t)pos) >> 1));
    r = ___SMMLA(attr_table.array[(pos >> 32) + 1] << attr_table.GAIN,
                 (((uint32_t)pos) >> 1), r);
    outlet_wave = r;
    pos += ((uint64_t)f0) << 4;
  } else
    outlet_wave = 0;
} else
  outlet_wave = 0;

Privacy

© 2024 Zrna Research