recmodes

a helper for different recording modes for 'smplr'. 'loopRec' will record into the selected slot,as long as 'loopRec' is high, no new slices will be created. in addition,'loopRec' will check if the selected slot is empty.if not, the object will search for the next empty slot. 'sliceArm' will arm 'smplr' to record to the selected slot, 'sliceRec' will start recording to that slot if it's empty.
Author: Robert Schirmer
License: BSD
Github: rbrt/old/recmodes.axo

Inlets

int32.positive slot

bool32.risingfalling loopRec

bool32.risingfalling sync

bool32.risingfalling sliceArm

bool32.risingfalling DISABLE

frac32.positive phase

bool32.rising sliceRec

Outlets

bool32 arm

bool32.pulse rec

int32.positive playmode

int32 slot

Attributes

objref smplr

spinner loopFlag

spinner sliceFlag

Declaration
bool srec;
uint8_t slot;
bool rec;
bool lrec;

uint32_t start;
int32_t _ap;
int32_t phase;
bool full;
Control Rate
outlet_rec = 0;
full = attr_smplr.array[(inlet_slot << 2) + 2];

if (!inlet_DISABLE) {
  if (inlet_loopRec && !lrec) {
    lrec = 1;
    start = inlet_phase;
    outlet_playmode = attr_loopFlag;
    if (full) {
      slot = 255;
      int i;
      for (i = 0; i < 126; i++)
        if (!attr_smplr.array[(i << 2) + 2]) {
          slot = i;
          break;
        }
    } else
      slot = inlet_slot;
    if (slot != 255) {
      rec = 1;
      outlet_rec = 1;
    }
  }

  if (!inlet_loopRec && lrec) {
    if (inlet_sync) {
      phase = (inlet_phase - start) & ((1 << 27) - 1);
      if ((phase - _ap) <= 0) {
        lrec = 0;
        rec = 0;
        attr_smplr.array[511] -= 16;
      }
      _ap = phase;
    } else {
      rec = 0;
      lrec = 0;
    }
  }

  if (!lrec) {
    if ((inlet_sliceArm && !rec) && !full) {
      srec = 1;
      rec = 1;
    }
    if (srec) {
      outlet_rec = inlet_sliceRec;
      if (!full)
        slot = inlet_slot;
      outlet_playmode = attr_sliceFlag;
    }
    if (!inlet_sliceArm && srec) {
      srec = 0;
      rec = 0;
    }
  }

  outlet_arm = rec;
  outlet_slot = slot;
}

Privacy

© 2024 Zrna Research