saw

saw wave oscillator Bandwith limited
Author: Johannes Taelman
License: BSD
Github: osc/saw.axo

Inlets

frac32.bipolar pitch

Outlets

frac32buffer.bipolar saw wave, anti-aliased

Parameters

frac32.s.map.pitch pitch

Declaration
int32_t osc_p;
static const int blepvoices = 4;
int16_t *oscp[blepvoices];
uint32_t nextvoice;
Init
int j;
for (j = 0; j < blepvoices; j++)
  oscp[j] = &blept[BLEPSIZE - 1];
nextvoice = 0;
Control Rate
int32_t freq;
MTOFEXTENDED(param_pitch + inlet_pitch, freq);
int j;
int16_t *lastblep = &blept[BLEPSIZE - 1];
for (j = 0; j < BUFSIZE; j++) {
  int i;
  int p;
  p = osc_p;
  osc_p = p + freq;
  if ((osc_p > 0) && !(p > 0)) { // dispatch
    nextvoice = (nextvoice + 1) & (blepvoices - 1);
    int32_t x = osc_p / (freq >> 6);
    oscp[nextvoice] = &blept[x];
  }
  int32_t sum = 0;
  for (i = 0; i < blepvoices; i++) { // sample
    int16_t *t = oscp[i];
    sum += *t;
    t += 64;
    if (t >= lastblep)
      t = lastblep;
    oscp[i] = t;
  }
  sum = (16384 * blepvoices) - sum - 8192;
  uint32_t g = osc_p;
  sum = (g >> 5) + (sum << 13);
  outlet_wave[j] = sum;
}

Privacy

© 2024 Zrna Research