smplr test

'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 test.axo

Inlets

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

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

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

frac32 additional data,for example timepoint of the recording start

frac32buffer audio in

Outlets

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

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

Parameters

frac32.s.map.kdecaytime.exp attack

frac32.s.map.kdecaytime.exp release

Attributes

objref brain

objref table to record to

Declaration
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;

bool full;
bool rectrig;
Init
rec_max = attr_wave.LENGTH;
shift = (27 - attr_wave.LENGTHPOW);
Control Rate
outlet_recstart = 0;

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

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

if (!inlet_rec)
  rectrig = 0;

if (!inlet_arm && attr_brain.REC) {
  attr_brain.REC = 0;
  attr_brain.array[(attr_brain.RECSLOT << 2) + 1] = attr_brain.array[1022];
}

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

outlet_slotFull = full;
outlet_remain = (rec_max - attr_brain.array[1022]) << shift;
outlet_recstate = attr_brain.REC;
outlet_fadestate = recstate;
outlet_recslot = attr_brain.RECSLOT;
Audio Rate
// record
int rv;
if (recstate) {
  rv = __SSAT((___SMMUL(inlet_wave, env) << 5), 28) >> attr_wave.GAIN;
  if (attr_brain.REC) {
    attr_wave.array[attr_brain.array[1022]] = rv;
    if (attr_brain.array[1022] < rec_max)
      attr_brain.array[1022]++;
    else
      attr_brain.array[1022] = recstart;
  } else {
    rv += (attr_wave.array[fadepos]);
    attr_wave.array[fadepos] = rv;
    if (fadepos < recend)
      fadepos++;
    else
      fadepos = recstart;
  }
}

Privacy

© 2024 Zrna Research