syncModOsc

multi modulated oscillator on sine basis. "pitch" controls pitch in normal logarithic sense "lin" adds a linear offset to the rate of the oscillator "LFM" and "EFM" are modulation width controls for linear and exponential modulation "SoftFM" controls the width of the phase modulation by pseudo-derivative of sync-input. "PM" controls the width of the normal phase modulation "AM" controls the width of amplitude modulation "hardsync" resets phase to zero immediatly at sync>0. "soft" resets phase to zero at sync>0, but smoothed by a lowpass filter, which is controlled by "softness" "SH" takes current wave-output value and adds it as an offset at sync>0, smoothed by the "smoothSH" control "reverse" reverses play direction at sync>0 "shift" shifts the phase by the amount of the pseudo derivate of the sync signal when sync>0 features external "modulation width" inputs to control those with LFO's, sequencers or envelopes.
Author: Remco van der Most
License: BSD
Github: sss/osc/syncModOsc.axo

Inlets

frac32buffer linear FM audio input

frac32buffer exponential FM audio input

frac32buffer phase modulation audio input

frac32buffer amplitude modulation audio input

frac32buffer sync audio input

frac32 linear FM width control

frac32 exponential FM width control

frac32 softFM width control

frac32 phase modulation width control

frac32 amplitude modulation width control

frac32 softsync softness control

frac32 smoothSH softness control

bool32 off/on hardsync control

bool32 off/on softsync control

bool32 off/on smoothSH control

bool32 off/on reverse control

bool32 off/on shift control

bool32 active

frac32.bipolar pitch

Outlets

frac32buffer.bipolar sine wave

Parameters

frac32.s.map.pitch logarithmic pitch control (normal)

frac32.s.map.pitch smooths out softsync

frac32.s.map.pitch smooths out SH sync

frac32.s.map linear pitch detune

frac32.s.map linear FM width

frac32.s.map exponential FM width

frac32.s.map softFM width

frac32.s.map phase modulation width

frac32.s.map amplitude modulation width

bool32.tgl hardsyncs signal to phase=0 at sync

bool32.tgl softsyncs signal to phase=0 at sync

bool32.tgl adds current wave-position as offset to the wave at sync

bool32.tgl reverses play direction at sync

bool32.tgl shifts at sync by pseudoderivative of sync signal

Declaration
uint32_t Phase;
int32_t prev;
int32_t r;
int32_t p2;
int trig;
int32_t val1;
int32_t val2;
int32_t vol;
int32_t prav;
int8_t dir;
int32_t fq;
int32_t fs;
int32_t ccomp;
Init
Phase = 0;
dir = 1;
Control Rate
if (inlet_active > 0) {

  MTOF(param_softness + inlet_softness + inlet_pitch, fq);

  MTOF(param_smoothSH + inlet_pitch, fs);

  ccomp = (1 << 27) - ((param_AM + inlet_AW) > 0 ? (param_AM + inlet_AW)
                                                 : (-param_AM - inlet_AW));
}
Audio Rate
if (inlet_active > 0) {
  int32_t freq;
  MTOFEXTENDED(param_pitch +
                   ___SMMUL((param_EFM + inlet_EFW) << 3, inlet_EFM << 2) +
                   inlet_pitch,
               freq);
  Phase +=
      (param_lin + freq +
       ___SMMUL(inlet_LFM << 3, (param_LFM + inlet_LFW) << 2) +
       (___SMMUL((inlet_sync - prev) << 5, (param_softFM + inlet_softFM) << 4)
        << 2)) *
      dir;
  if ((inlet_sync > 0) && (!(trig))) {
    trig = 1;
    if (param_hardsync + inlet_hardsync > 0) {
      Phase = 0;
    }
    if (param_soft + inlet_softsync > 0) {
      vol = -p2;
    }
    if (param_SH + inlet_smthSH > 0) {
      prav = -(r >> 5);
    }
    if (param_reverse + inlet_reverse > 0) {
      dir = dir > 0 ? -1 : 1;
      ;
    }
    if (param_shift + inlet_shift > 0) {
      Phase = Phase - ((inlet_sync - prev) << 3);
    }

  } else if (inlet_sync <= 0) {
    trig = 0;
  }
  val2 = ___SMMLA((prav - val2) << 1, fs, val2);
  val1 = ___SMMLA((vol - val1) << 1, fq, val1);
  p2 = Phase + val1 +
       (___SMMUL(inlet_phase << 4, (param_PM + inlet_PMW) << 4) << 4);
  SINE2TINTERP(p2, r)

  outlet_wave = ___SMMUL(
      (((r) >> 5) + val2 * ((param_SH + inlet_smthSH) > 0 ? 1 : 0)) << 3,
      (ccomp + ___SMMUL((param_AM + inlet_AW) << 3, inlet_AM << 2) << 2));
  prev = inlet_sync;
}

Privacy

© 2024 Zrna Research