smplr sdram

'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/old/smplr sdram.axo

Inlets

bool32.risingfalling arm the recorder

bool32.rising a pulse will start a recording a sample in the selected slot if 'arm' is 1 and the selected slot doesn't already contain a sample

bool32.rising clear the recorders data

frac32 additional data,for example timepoint of the recording start

frac32buffer audio in

int32.positive select a slot to record into (0 - 127)

int32.positive playback mode the currently recording slot will be set to

Outlets

bool32 recording status

bool32 rec status && fade status

bool32 '1' if a slot already contains a sample

int32.positive slot currently recording to

frac32.positive remaining recording-time

bool32.pulse issues a pulse when a new slot is recorded

Parameters

frac32.s.map.kdecaytime.exp attack

frac32.s.map.kdecaytime.exp release

Attributes

objref table to record to

Declaration
bool rec;
bool recstate;
bool fadetrig;
bool rtrig;
uint32_t fadepos;
uint32_t recstart;
uint32_t recend;
uint32_t rec_max;
uint8_t shift;
int32_t env;

uint8_t mslot;
uint8_t preslot;
uint8_t recslot;

static const uint16_t LENGTH = 512;
uint32_t *array;

bool full;
bool rectrig;
Init
rec_max = attr_wave.LENGTH;
shift = (27 - attr_wave.LENGTHPOW);
static uint32_t _array[attr_poly][512] __attribute__((section(".sdram")));
array = &_array[parent->polyIndex][0];
{
  int i;
  for (i = 0; i < 512; i++)
    array[i] = 0;
}
Control Rate
outlet_recstart = 0;

mslot = (inlet_slot % 126);
full = array[(mslot << 2) + 2];

if (inlet_arm) {
  if (!full && (inlet_rec && !rectrig)) {
    rectrig = 1;
    recslot = mslot;
    if (rec)
      array[(preslot << 2) + 1] = array[511];
    rec = 1;
    recstate = 1;
    outlet_recstart = 1;
    fadetrig = 0;
    recstart = array[511];
    array[recslot << 2] = array[511];
    array[(recslot << 2) + 2] = (inlet_playmode) ? inlet_playmode : 1;
    array[(recslot << 2) + 3] = __SSAT(inlet_Aux, 28);
    preslot = recslot;
  }
}

if (!inlet_rec)
  rectrig = 0;

if (!inlet_arm && rec) {
  rec = 0;
  array[(recslot << 2) + 1] = array[511];
}

// fades
if (rec) {
  env = (1 << 27) - (___SMMUL((1 << 27) - env, param_attack) << 1);
} else {
  env = ___SMMUL(env, param_release) << 1;
  if (!fadetrig) {
    fadetrig = 1;
    recend = array[511];
    fadepos = recstart;
  }
}
recstate = env;

// clear
if (inlet_clear && !rtrig) {
  rtrig = 1;
  int i;
  for (i = 0; i < 512; i++)
    array[i] = 0;
}
if (!inlet_clear)
  rtrig = 0;

outlet_slotFull = full;
outlet_remain = (rec_max - array[511]) << shift;
outlet_recstate = rec;
outlet_fadestate = recstate;
outlet_recslot = recslot;
Audio Rate
// record

if (recstate) {
  if (rec) {
    attr_wave.array[array[511]] =
        __SSAT((___SMMUL((inlet_wave), env) << 5), 28) >> attr_wave.GAIN;
    if (array[511] < rec_max)
      array[511]++;
    else
      array[511] = recstart;
  } else {
    attr_wave.array[fadepos] = (__SSAT((___SMMUL((inlet_wave), env) << 5), 28) +
                                (attr_wave.array[fadepos] << attr_wave.GAIN)) >>
                               attr_wave.GAIN;
    fadepos++;
    if (fadepos >= recend)
      fadepos = recstart;
  }
}

Privacy

© 2024 Zrna Research