beatplayer2

An realtime beat slicer. Port of sliceplay~ puredata object from Katja Vetter (http://www.katjaas.nl/beatdetection/beatdetection.html). Play slice store in slicebuffer/sliceindex tables with beatslicer2 object.
Author: Jérôme Burlando
License: BSD
Github: gao/sample/beatplayer2.axo

Inlets

frac32.bipolar Pitch of the slice.

bool32.rising Start playback

bool32 Play slice in reverse mode.

bool32 If active and if trig on "start" input, play the slice. Else slice must be entirely played to be replayed.

int32 Select the slice to play.

Outlets

frac32buffer wave

Attributes

objref Slices stack

objref Slices cuepoints table

Declaration
int pstart;
int play;
int64_t pos;
uint32_t beg;
uint32_t end;
uint32_t f0;
int32_t pitch;
uint8_t reverse;
Init
pstart = 0;
play = 0;
beg = 0;
end = 0;
pos = 0;
f0 = 0;
pitch = 0;
reverse = 0;
Control Rate
if (inlet_nslice < attr_slicesindex.array[0]) {
  if ((inlet_start > 0) && !pstart && (inlet_retrig || !play)) {
    pstart = 1;
    play = 1;
    reverse = inlet_reverse;
    pitch = inlet_pitch;
    if (inlet_nslice == 0) {
      beg = 0;
      end = attr_slicesindex.array[1];
    } else {
      beg = (uint64_t)attr_slicesindex.array[inlet_nslice];
      end = attr_slicesindex.array[inlet_nslice + 1];
    }
    if (!reverse) {
      pos = ((uint64_t)beg) << 32;
    } else {
      pos = ((uint64_t)end) << 32;
    }
  } else if (!(inlet_start > 0)) {
    pstart = 0;
  }
}

MTOFEXTENDED(pitch + 80179668, f0);
Audio Rate
outlet_o = 0;

if (play) {
  uint64_t inc = ((uint64_t)f0) << 4;
  if (!reverse) {
    uint32_t o =
        ___SMMUL(attr_slicesbuffer.array[pos >> 32] << attr_slicesbuffer.GAIN,
                 INT32_MAX - (((uint32_t)pos) >> 1));
    outlet_o = ___SMMLA(attr_slicesbuffer.array[(pos >> 32) + 1]
                            << attr_slicesbuffer.GAIN,
                        (((uint32_t)pos) >> 1), o);
    pos += inc;
    if (pos >> 32 > end)
      play = 0;
  } else if (reverse) {
    uint32_t o =
        ___SMMUL(attr_slicesbuffer.array[pos >> 32] << attr_slicesbuffer.GAIN,
                 INT32_MAX - (((uint32_t)pos) >> 1));
    outlet_o = ___SMMLA(attr_slicesbuffer.array[(pos >> 32) - 1]
                            << attr_slicesbuffer.GAIN,
                        (((uint32_t)pos) >> 1), o);
    pos -= inc;
    if (pos >> 32 < beg)
      play = 0;
  } else {
    play = 0;
  }
}

Privacy

© 2024 Zrna Research