play n

play back a sequence recorded with 'note rec'
Author: Robert Schirmer
License: BSD
Github: rbrt/mloop/play n.axo

Inlets

int32.positive index (0 - 512)

bool32.risingfalling start/stop

bool32.rising stop all active notes

Outlets

int32 note

int32 velo

Attributes

objref seq

Declaration
uint16_t v;
uint8_t *active;
uint8_t note;
uint8_t velo;
bool sa;
bool play;
uint8_t stoplist[32];
uint8_t stopcount;

void stopall() {
  stopcount = 0;
  int i;
  for (i = 0; i < 128; i++) {
    if (active[i]) {
      stoplist[stopcount] = i;
      stopcount++;
    }
  }
  return;
}
Init
static uint8_t _active[attr_poly][128] __attribute__((section(".sdram")));
active = &_active[parent->polyIndex][0];

{
  int i;
  for (i = 0; i < 128; i++)
    active[i] = 0;
}
Control Rate
if (inlet_play && !play)
  play = 1;
if (!inlet_play && play) {
  play = 0;
  stopall();
}

if (play) {
  v = attr_seq.array[inlet_index];
  if (v) {
    note = (v & 255) - 1;
    velo = v >> 8;
    active[note] = velo;
  }
}

if (inlet_stopall && !sa) {
  stopall();
  sa = 1;
}
if (!inlet_stopall)
  sa = 0;

if (stopcount) {
  note = stoplist[stopcount - 1];
  velo = 0;
  stopcount--;
}

outlet_note = note;
outlet_velo = velo;

Privacy

© 2024 Zrna Research