master

'arm' will arm the recorder, 'rec' will start recording to the selected slot or, when already recording,start another recording in a selected slot. you cannot record into a slot that already contains sample data. if already recording,recording will continue in the slot you were recording to before. when 'arm' is 0 again,recording will stop. sample start-and endpoints can be accessed 'from the outside' via the recorder-objects name.
Author: Robert Schirmer
License: BSD
Github: rbrt/sstation/master.axo

Inlets

int32.positive slot

bool32.rising trig

bool32.rising clear the recorders data

bool32.rising defrag

bool32.risingfalling copy

bool32.risingfalling move

bool32.risingfalling delete

Outlets

int32 test

bool32 delete

Attributes

combo size

Declaration
uint8_t SHIFT;
bool REC;
bool RECSTATE;
uint8_t RECSLOT;
uint32_t RECPOS;

// global stuff like RECPOS
uint32_t GLOBAL[8];
// slot params and other data
uint32_t *array;
// the recordings
int16_t *WAVE;
static const uint32_t W_LENGTHPOW = (attr_size);
static const uint32_t W_LENGTH = (1 << attr_size);
static const uint32_t W_LENGTHMASK = ((1 << attr_size) - 1);

static const uint32_t LENGTHPOW = (13);
static const uint32_t LENGTH = (1 << 13);
static const uint32_t LENGTHMASK = ((1 << 13) - 1);
static const uint32_t GAIN = 0;
static const uint32_t BITS = 32;

bool ctrig;
bool dtrig;
bool cpytrig;
bool cpytemptrig;
bool del;
bool clrtrig;

bool move;
bool mtrig;
uint8_t mslot;
uint8_t srcslot;
bool deletetrig;
bool copytrig;
uint32_t sstart;
uint32_t send;
uint32_t slength;
int32_t paramtemp[32];
uint8_t delcount;

void delete_slot(uint8_t target) {
  if (array[(target << 5) + 2]) {
    sstart = array[target << 5];
    send = array[(target << 5) + 1];
    int i;
    for (i = 0; i < 32; i++)
      array[(target << 5) + i] = 0;
    bool check = 1;
    for (i = 0; i < 127; i++)
      if (array[(i << 5) + 1] == send)
        check = 0;
    if (check) {
      array[delcount + 4096] = sstart;
      array[delcount + 4352] = send;
      delcount++;
    }
  }
}
Init
SHIFT = (27 - W_LENGTHPOW);

int i;
static uint32_t _array[attr_poly][8192] __attribute__((section(".sdram")));
array = &_array[parent->polyIndex][0];
for (i = 0; i < 8192; i++)
  array[i] = 0;

static int16_t _WAVE[attr_poly][W_LENGTH] __attribute__((section(".sdram")));
WAVE = &_WAVE[parent->polyIndex][0];
for (i = 0; i < W_LENGTH; i++)
  WAVE[i] = 0;
Control Rate
mslot = inlet_slot % 126;
outlet_delete = 0;

// delete
if (inlet_delete && inlet_trig && !dtrig) {
  delete_slot(mslot);
  dtrig = 1;
  outlet_delete = 1;
}
// compact
if (inlet_defrag && !ctrig) {
  ctrig = 1;
  int i;
  for (i = 0; i < delcount; i++) {
    sstart = array[i + 4096];
    send = array[i + 4352];
    slength = (send - sstart);
    int shift_index;
    for (shift_index = 0; shift_index < 4096; shift_index += 32)
      if (array[shift_index] >= send) {
        array[shift_index] -= slength;
        array[shift_index + 1] -= slength;
      }
    int move_samples;
    for (move_samples = send; move_samples < RECPOS; move_samples++)
      WAVE[move_samples - slength] = WAVE[move_samples];
    int shift_chunks;
    for (shift_chunks = 0; shift_chunks < delcount; shift_chunks++)
      if (array[shift_chunks + 4096] >= send) {
        array[shift_chunks + 4096] -= slength;
        array[shift_chunks + 4352] -= slength;
      }
    RECPOS -= slength;
  }
  delcount = 0;
}

// paste
if (inlet_trig && cpytemptrig && !cpytrig && (inlet_copy || move)) {
  cpytrig = 1;
  delete_slot(mslot);
  int i;
  for (i = 0; i < 32; i++)
    array[(mslot << 5) + i] = paramtemp[i];
  if (move) {
    for (i = 0; i < 32; i++)
      array[(srcslot << 5) + i] = 0;
    outlet_delete = 1;
    move = 0;
  }
}

// copy
if (inlet_trig && !cpytemptrig && (inlet_copy || move)) {
  cpytemptrig = 1;
  srcslot = mslot;
  int i;
  for (i = 0; i < 32; i++)
    paramtemp[i] = array[(mslot << 5) + i];
}

// move
if (inlet_move && !mtrig) {
  mtrig = 1;
  move = 1;
}

// clear
if (inlet_clear && !clrtrig) {
  clrtrig = 1;
  delcount = 0;
  int i;
  for (i = 0; i < 8192; i++)
    array[i] = 0;
  RECPOS = 0;
}

if (!inlet_copy && !inlet_move)
  cpytemptrig = 0;
if (!inlet_move) {
  mtrig = 0;
  move = 0;
}
if (!inlet_trig) {
  cpytrig = 0;
  dtrig = 0;
}
if (!inlet_clear)
  clrtrig = 0;
if (!inlet_defrag)
  ctrig = 0;

outlet_test = delcount;

Privacy

© 2024 Zrna Research