liveRecord

live samplerecorder to be used with the livePlayer. Uses a 32bit "starts" table and a 16bit "samples" table. Autoclear resets the entire buffer when the recorder goes over the maximum time.
Author: Remco van der Most
License: BSD
Github: sss/sampler/liveRecord.axo

Inlets

frac32buffer wave input

bool32 when high, records input into the table at next start position

bool32 when high, clears buffer and start positions

Outlets

None

Parameters

bool32.tgl autoclear

Attributes

objref this should refer to a 16bit table allocator (sdram)

objref this should refer to a 32bit table allocator

Declaration
uint32_t writepos;
bool rec;
bool clear;
int i;
bool clr;
Init
writepos = 0;
Control Rate
if (((inlet_clear || clr > 0) && !clear) ||
    ((param_autoclear > 0) && (attr_starts.array[0] == 63))) {
  clear = 1;
  for (i = 0; i < attr_samples.LENGTH; i++) {
    attr_samples.array[i] = 0;
  }
  for (i = 0; i < attr_starts.LENGTH; i++) {
    attr_starts.array[i] = 0;
  }
  clr = 0;
} else if (inlet_clear || clr < 1) {
  clear = 0;
}
Audio Rate
if ((inlet_rec > 0) && (writepos < attr_samples.LENGTH) &&
    (attr_starts.array[0] < 63)) {
  if (!rec) {
    rec = 1;
  }
  writepos = (writepos + 1);
  if (writepos > attr_samples.LENGTHMASK) {
    clr = 1;
  }
  writepos = writepos & attr_samples.LENGTHMASK;
  attr_samples.array[writepos] = __SSAT(inlet_in >> 14, 16);
} else if ((inlet_rec < 1) && (rec == 1)) {
  rec = 0;
  attr_starts.array[0] += 1;
  attr_starts.array[attr_starts.array[0]] = writepos;
}

Privacy

© 2024 Zrna Research