rec

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

Inlets

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

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

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 smplr

Declaration
bool recstate;
bool fadetrig;
bool rtrig;
uint32_t fadepos;
uint32_t recstart;
uint32_t recend;
uint32_t rec_max;
int32_t env;
uint16_t slot_t;

uint8_t mslot;

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

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

if (inlet_arm) {
  if (!full && (inlet_rec && !rectrig)) {
    rectrig = 1;
    if (attr_smplr.REC)
      attr_smplr.array[slot_t + 29] = attr_smplr.REC_HEAD;
    attr_smplr.RECSLOT = mslot;
    slot_t = mslot << 5;
    attr_smplr.REC = 1;
    recstate = 1;
    outlet_recstart = 1;
    fadetrig = 0;
    recstart = attr_smplr.REC_HEAD;
    attr_smplr.array[slot_t + 28] = attr_smplr.REC_HEAD;
    attr_smplr.array[slot_t + 30] = (inlet_playmode) ? inlet_playmode : 1;
    attr_smplr.array[slot_t + 31] = __SSAT(inlet_Aux, 28);
  }
}

if (!inlet_rec)
  rectrig = 0;

if (!inlet_arm && attr_smplr.REC) {
  attr_smplr.REC = 0;
  attr_smplr.array[slot_t + 29] = attr_smplr.REC_HEAD;
}

// fades
if (attr_smplr.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.REC_HEAD;
    fadepos = recstart;
  }
}
recstate = env;

outlet_slotFull = full;
outlet_remain = (rec_max - attr_smplr.REC_HEAD) << attr_smplr.SHIFT;
outlet_recstate = attr_smplr.REC;
outlet_fadestate = recstate;
outlet_recslot = attr_smplr.RECSLOT;
Audio Rate
// record
int rv;
if (recstate) {
  rv = __SSAT((___SMMUL(inlet_wave, env) << 5), 28) >> attr_smplr.W_GAIN;
  if (attr_smplr.REC) {
    attr_smplr.WAVE[attr_smplr.REC_HEAD] = rv;
    if (attr_smplr.REC_HEAD < rec_max)
      attr_smplr.REC_HEAD++;
    else
      attr_smplr.REC_HEAD = recstart;
  } else {
    rv += (attr_smplr.WAVE[fadepos]);
    attr_smplr.WAVE[fadepos] = rv;
    if (fadepos < recend)
      fadepos++;
    else
      fadepos = recstart;
  }
}

Privacy

© 2024 Zrna Research