scope

bipolar audio rate signal oscilloscope (time domain), showing 128 consecutive samples after the signal becomes positive.
Author: Johannes Taelman mod Smashed Transistors
License: BSD
Github: tiar/disp/scope.axo

Inlets

frac32buffer.bipolar input

Outlets

None

Displays

int8array128.vbar scope

Declaration
int8_t t[128];
int index;
int32_t pval;
float dc, lp1, lp2, lp3;
float tlp[16];
int32_t pin;
Init
int i;
for (i = 0; i < 128; i++)
  t[i] = 0;
index = 0;
pval = 0;
lp1 = lp2 = lp3 = dc = 0.0f;
pin = 0;
for (i = 0; i < 16; i++)
  tlp[i] = 0.0f;
Control Rate
int i;
for (i = 0; i < 16; i++) {
  if (inlet_in[i] > 0) {
    tlp[i] = inlet_in[i];
  } else {
    tlp[i] = 0.5f * inlet_in[i];
  }
}
for (i = 0; i < 16; i++) {
  dc += 0.01f * (tlp[i] - dc);
  lp1 += 0.01f * (tlp[i] - dc - lp1);
  lp2 += 0.01f * (lp1 - lp2);
  lp3 += 0.01f * (lp2 - lp3);
  tlp[i] = lp3;
}

if (index < 0) {
  for (i = 0; i < 16; i++) {
    int32_t val = (tlp[i]) > 0;
    if (val && (!pval)) {
      index = 0;
      break;
    }
    pval = val;
  }
  if (index == 0) {
    for (; i < 16; i++) {
      t[index++] = (uint8_t)(inlet_in[i] >> 21);
    }
  }
} else {
  for (i = 0; i < 16; i++) {
    if (index == 128) {
      index = -1;
      break;
    }
    t[index++] = (uint8_t)(inlet_in[i] >> 21);
  }
  if (index == -1) {
    for (i = 0; i < 128; i++)
      disp_scope[i] = t[i];
    pval = (tlp[BUFSIZE - 1]) > 0;
  }
}

Privacy

© 2024 Zrna Research