blepSlave2s

Multi wave oscillator with sync and FM modulation Bandwith limited
Author: Remco van der Most
License: BSD
Github: sss/osc/blepSlave2s.axo

Inlets

frac32.bipolar pitch

frac32 fm

frac32 pw

frac32buffer pwm

frac32buffer mod

frac32buffer sync, resets oscillator phase on rising zero-crossing

int32 wave

Outlets

frac32buffer.bipolar saw wave, anti-aliased

frac32 pitch

Parameters

int32.hradio wave

frac32.s.map.pitch pitch

frac32.s.map pulse width for pulse oscillator mode (5)

frac32.s.map pulse width modulation width for pulse oscillator mode (5)

frac32.s.map fm

bool32.tgl snc

Attributes

objref core

Declaration
int32_t osc_p;
uint32_t uosc_p;
static const int blepvoices = 8;
const int16_t *uoscp[blepvoices];
int16_t *oscp[blepvoices];
int32_t vgain[blepvoices];
uint32_t nextvoice;
int32_t pwmp;
int32_t i0;
int32_t sync[BUFSIZE];
int i;
int k;
int wave;
int32_t hp;
int32_t pitch;
int snc;
int32_t fm;
int32_t v27 = 1 << 27;
int32_t vi28 = (1 << 28) - 1;
int32_t SQRT(int32_t in) {
  int32_t ai = in;
  float aif = ai;
  aif *= (1 << 27);
  aif = _VSQRTF(aif);
  return (int)aif;
}
Init
int j;

for (j = 0; j < blepvoices; j++) {
  oscp[j] = &blept[BLEPSIZE - 1];
  nextvoice = 0;
  i0 = 0;
}
Control Rate
wave = (param_wave + inlet_wave);
wave = (wave > 0 ? wave : -wave) % 9;

pitch = param_pitch + inlet_pitch;

snc = param_snc;

fm = __SSAT(param_fm + inlet_fm, 28) << 3;

int32_t pwm;

pwm = param_pw + inlet_pw;

for (i = 0; i < blepvoices; i++) {
  attr_core.oscp[i] = oscp[i];
  attr_core.uoscp[i] = uoscp[i];
  attr_core.vgain[i] = vgain[i];
}
for (i = 0; i < BUFSIZE; i++) {
  attr_core.sync[i] = snc > 0 ? (k > 0 ? sync[i] : inlet_sync[i]) : 0;
  int32_t md = ___SMMUL(inlet_mod[i] << 2, fm);
  hp += md - hp >> 8;
  attr_core.mod[i] = md - hp;
  if (wave >= 4) {
    attr_core.Pwm[i] = pwm + ___SMMUL((inlet_pwm[i]) << 1,
                                      (k > 0 ? param_pwm : param_pwm) << 4);
  }
}
attr_core.i0 = i0;
attr_core.osc_p = osc_p;
attr_core.uosc_p = uosc_p;
attr_core.nextvoice = nextvoice;

attr_core.pwmp = pwmp;
switch (wave) {
case 0:
  attr_core.OSC_SIN(pitch);
  break;
case 1:
  attr_core.OSC_TRI(pitch);
  break;
case 2:
  attr_core.OSC_PEK(pitch);
  break;
case 3:
  attr_core.OSC_SAW(pitch);
  break;
case 4:
  attr_core.OSC_SQR(pitch);
  break;
case 5:
  attr_core.OSC_PLS(pitch);
  break;
case 6:
  attr_core.OSC_VOW(pitch);
  break;
case 7:
  attr_core.OSC_HRM(pitch);
  break;
case 8:
  attr_core.OSC_NSI(pitch);
  break;
}
for (i = 0; i < BUFSIZE; i++) {

  outlet_wave[i] = attr_core.wave[i];
}
for (i = 0; i < blepvoices; i++) {
  oscp[i] = attr_core.oscp[i];
  uoscp[i] = attr_core.uoscp[i];
  vgain[i] = attr_core.vgain[i];
}
i0 = attr_core.i0;
osc_p = attr_core.osc_p;
uosc_p = attr_core.uosc_p;
nextvoice = attr_core.nextvoice;
pwmp = attr_core.pwmp;

outlet_pitch = param_pitch + inlet_pitch;

Privacy

© 2024 Zrna Research