srec

'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/srec.axo

Inlets

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

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

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

int32 test

Parameters

frac32.s.map.kdecaytime.exp attack

frac32.s.map.kdecaytime.exp release

Attributes

objref smplr

Declaration
bool rec;
bool fadetrig;
uint32_t fadepos;

uint32_t recstart;
uint32_t recend;
uint32_t rec_max;
int32_t env;

uint8_t mslot;
uint8_t preslot;
bool full;
bool rectrig;
Init
rec_max = attr_smplr.W_LENGTH;
Control Rate
outlet_recstart = 0;

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

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

if (!inlet_rec)
  rectrig = 0;

if (!inlet_arm && rec) {
  rec = 0;
  attr_smplr.array[(attr_smplr.RECSLOT << 5) + 1] = attr_smplr.RECPOS;
}

// 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 = attr_smplr.RECPOS;
    fadepos = recstart;
  }
}
attr_smplr.RECSTATE = env;

outlet_slotFull = full;
outlet_remain = (rec_max - attr_smplr.RECPOS) << attr_smplr.SHIFT;
outlet_recstate = rec;
outlet_fadestate = attr_smplr.RECSTATE;
outlet_recslot = attr_smplr.RECSLOT;

outlet_test = attr_smplr.RECPOS;
Audio Rate
// record
int rv;
if (attr_smplr.RECSTATE) {
  rv = __SSAT((___SMMUL(inlet_wave, env) << 5), 28) >> 16;
  if (rec) {
    attr_smplr.WAVE[attr_smplr.RECPOS] = rv;
    if (attr_smplr.RECPOS < rec_max)
      attr_smplr.RECPOS++;
    else
      attr_smplr.RECPOS = recstart;
  } else {
    rv += (attr_smplr.WAVE[fadepos]);
    attr_smplr.WAVE[fadepos] = rv;
    if (fadepos < recend)
      fadepos++;
    else
      fadepos = recstart;
  }
}

Privacy

© 2024 Zrna Research