1shot

one-shot readout of table data
Author: robert schirmer
License: BSD
Github: rbrt/old/1shot.axo

Inlets

bool32.rising tigger playback

frac32.positive offset

frac32.positive length of the area to index

frac32.positive startpoint inside 'range'

frac32.bipolar speed modulation

Outlets

frac32buffer.positive phase

bool32 playback state

Parameters

frac32.s.map speed ,+ 64 normal speed forward, - 64 backward

Attributes

objref table

Declaration
float32_t index;
bool play;
int32_t pos;
int shift;
int range;
int start;
int ntrig;
Init
play = 0;

// set 'shift factor' for storing the recording length/the sync output
if (attr_table.LENGTH == 2048) {
  shift = 16;
}
if (attr_table.LENGTH == 4096) {
  shift = 15;
}
if (attr_table.LENGTH == 8192) {
  shift = 14;
}
if (attr_table.LENGTH == 16384) {
  shift = 13;
}
if (attr_table.LENGTH == 32768) {
  shift = 12;
}
if (attr_table.LENGTH == 65536) {
  shift = 11;
}
if (attr_table.LENGTH == 131072) {
  shift = 10;
}
if (attr_table.LENGTH == 262144) {
  shift = 9;
}
if (attr_table.LENGTH == 524288) {
  shift = 8;
}
if (attr_table.LENGTH == 1048576) {
  shift = 7;
}
if (attr_table.LENGTH == 2097152) {
  shift = 6;
}
if (attr_table.LENGTH == 4194304) {
  shift = 5;
}
Audio Rate
int t_speed = (inlet_speed + param_speed);
range = (inlet_range >> shift);
start = ((___SMMUL(inlet_range, inlet_start) << 5) >> shift);

if (inlet_play && (!ntrig)) {
  ntrig = 1;
  index = (t_speed < 0) ? (range - start) : 0;
  play = 1;
} else if (!(inlet_play > 0))
  ntrig = 0;

if (play) {

  index += (t_speed * (float)(1.0f / (1 << 27)));
  pos = (index + start);

  if ((pos > range) || (pos < start))
    play = 0;

  outlet_pos = ((pos << shift) + inlet_offset);
} else
  outlet_pos = 0;

outlet_play = play;

Privacy

© 2024 Zrna Research