m8v1

play a wavetable, which has been loaded by wave/wavetable load/ crossfade will fade beween waves. (~ double cpu load). note: you can use as a single wave oscillator by just loadng 1 wave
Author: Jaffasplaffa
License: GPL
Github: jaffa/wt/m8v1.axo

Inlets

frac32 m

frac32.bipolar pitch

frac32.positive wave index

frac32buffer frequency

bool32.rising reset phase

Outlets

frac32buffer m

Parameters

int32 mainoct

bool32.tgl rston

frac32.u.map MORPH

frac32.u.map wavetable index

frac32.u.map wave2

frac32.u.map wave3

frac32.u.map wave4

frac32.u.map wave5

frac32.u.map wave6

frac32.u.map wave7

frac32.u.map wave8

frac32.s.map pitch

Attributes

objref wavetable load object

Declaration
uint32_t phase;
uint32_t r;

uint32_t WAVESMASK, WAVESZ;

uint32_t wt1;
uint32_t wtm1;
int32_t WTOUT1;

uint32_t wt2;
uint32_t wtm2;
int32_t WTOUT2;

uint32_t wt3;
uint32_t wtm3;
int32_t WTOUT3;

uint32_t wt4;
uint32_t wtm4;
int32_t WTOUT4;

uint32_t wt5;
uint32_t wtm5;
int32_t WTOUT5;

uint32_t wt6;
uint32_t wtm6;
int32_t WTOUT6;

uint32_t wt7;
uint32_t wtm7;
int32_t WTOUT7;

uint32_t wt8;
uint32_t wtm8;
int32_t WTOUT8;

int32_t oct;

int32_t MORPH;
int32_t MORPHLIMIT;
int32_t MORPHINLETLIMIT;

int32_t RstON;

int32_t prev;
int32_t step;
Init
phase = 0;
r = 1;

WAVESMASK = (~((1 << (21 - (attr_t.WAVESPOW - 6))) - 1));
WAVESZ = (1 << (21 - (attr_t.WAVESPOW - 6)));

wt1 = 0;
wtm1 = (1 << attr_t.SIZEPOW) - 1;

wt2 = 0;
wtm2 = (1 << attr_t.SIZEPOW) - 1;

wt3 = 0;
wtm3 = (1 << attr_t.SIZEPOW) - 1;

wt4 = 0;
wtm4 = (1 << attr_t.SIZEPOW) - 1;

wt5 = 0;
wtm5 = (1 << attr_t.SIZEPOW) - 1;

wt6 = 0;
wtm6 = (1 << attr_t.SIZEPOW) - 1;

wt7 = 0;
wtm7 = (1 << attr_t.SIZEPOW) - 1;

wt8 = 0;
wtm8 = (1 << attr_t.SIZEPOW) - 1;
Control Rate
uint32_t freq;
MTOFEXTENDED(param_pitch + (param_mainoct * (12 << 21)) + inlet_pitch, freq);

{
  uint32_t w = inlet_wnr + param_wave1;
  w = w > (64 << 21) ? (64 << 21) - (w - (64 << 21)) : w;

  wt1 = w & WAVESMASK;
  uint32_t wsi = __USAT(wt1, 27) >> (27 - attr_t.LENGTHPOW);
  wtm1 = (wsi + (1 << attr_t.SIZEPOW)) - 1;
}

{
  uint32_t w2 = inlet_wnr + param_wave2;
  w2 = w2 > (64 << 21) ? (64 << 21) - (w2 - (64 << 21)) : w2;

  wt2 = w2 & WAVESMASK;
  uint32_t wsi2 = __USAT(wt2, 27) >> (27 - attr_t.LENGTHPOW);
  wtm2 = (wsi2 + (1 << attr_t.SIZEPOW)) - 1;
}

{
  uint32_t w3 = inlet_wnr + param_wave3;
  w3 = w3 > (64 << 21) ? (64 << 21) - (w3 - (64 << 21)) : w3;

  wt3 = w3 & WAVESMASK;
  uint32_t wsi3 = __USAT(wt3, 27) >> (27 - attr_t.LENGTHPOW);
  wtm3 = (wsi3 + (1 << attr_t.SIZEPOW)) - 1;
}

{
  uint32_t w4 = inlet_wnr + param_wave4;
  w4 = w4 > (64 << 21) ? (64 << 21) - (w4 - (64 << 21)) : w4;

  wt4 = w4 & WAVESMASK;
  uint32_t wsi4 = __USAT(wt4, 27) >> (27 - attr_t.LENGTHPOW);
  wtm4 = (wsi4 + (1 << attr_t.SIZEPOW)) - 1;
}

{
  uint32_t w5 = inlet_wnr + param_wave5;
  w5 = w5 > (64 << 21) ? (64 << 21) - (w5 - (64 << 21)) : w5;

  wt5 = w5 & WAVESMASK;
  uint32_t wsi5 = __USAT(wt5, 27) >> (27 - attr_t.LENGTHPOW);
  wtm5 = (wsi5 + (1 << attr_t.SIZEPOW)) - 1;
}

{
  uint32_t w6 = inlet_wnr + param_wave6;
  w6 = w6 > (64 << 21) ? (64 << 21) - (w6 - (64 << 21)) : w6;

  wt6 = w6 & WAVESMASK;
  uint32_t wsi6 = __USAT(wt6, 27) >> (27 - attr_t.LENGTHPOW);
  wtm6 = (wsi6 + (1 << attr_t.SIZEPOW)) - 1;
}

{
  uint32_t w7 = inlet_wnr + param_wave7;
  w7 = w7 > (64 << 21) ? (64 << 21) - (w7 - (64 << 21)) : w7;

  wt7 = w7 & WAVESMASK;
  uint32_t wsi7 = __USAT(wt7, 27) >> (27 - attr_t.LENGTHPOW);
  wtm7 = (wsi7 + (1 << attr_t.SIZEPOW)) - 1;
}

{
  uint32_t w8 = inlet_wnr + param_wave8;
  w8 = w8 > (64 << 21) ? (64 << 21) - (w8 - (64 << 21)) : w8;

  wt8 = w8 & WAVESMASK;
  uint32_t wsi8 = __USAT(wt8, 27) >> (27 - attr_t.LENGTHPOW);
  wtm8 = (wsi8 + (1 << attr_t.SIZEPOW)) - 1;
}
Audio Rate
{
  int32_t phasor;
  if (RstON && r) {
    phase = 0;
    r = 0;
  } else {
    if (!RstON)
      r = 1;
    phase += (freq >> 0) + inlet_freq;
  }
  phasor = phase >> 5;

  phasor = phasor >> attr_t.WAVESPOW;

  int32_t swt1;
  {
    uint32_t asat = __USAT(phasor + wt1, 27);
    int index = asat >> (27 - attr_t.LENGTHPOW);
    int32_t y1 = attr_t.array[index] << attr_t.GAIN;
    int32_t y2 = attr_t.array[(index + 1) & wtm1] << attr_t.GAIN;
    int frac = (asat - (index << (27 - attr_t.LENGTHPOW)))
               << (attr_t.LENGTHPOW + 3);
    swt1 = ___SMMUL(y1, (1 << 30) - frac);
    swt1 = ___SMMLA(y2, frac, swt1);
  }
  WTOUT1 = swt1 << 2;

  int32_t swt2;
  {
    uint32_t asat2 = __USAT(phasor + wt2, 27);
    int index = asat2 >> (27 - attr_t.LENGTHPOW);
    int32_t y12 = attr_t.array[index] << attr_t.GAIN;
    int32_t y22 = attr_t.array[(index + 1) & wtm2] << attr_t.GAIN;
    int frac2 = (asat2 - (index << (27 - attr_t.LENGTHPOW)))
                << (attr_t.LENGTHPOW + 3);
    swt2 = ___SMMUL(y12, (1 << 30) - frac2);
    swt2 = ___SMMLA(y22, frac2, swt2);
  }
  WTOUT2 = swt2 << 2;

  int32_t swt3;
  {
    uint32_t asat3 = __USAT(phasor + wt3, 27);
    int index = asat3 >> (27 - attr_t.LENGTHPOW);
    int32_t y13 = attr_t.array[index] << attr_t.GAIN;
    int32_t y23 = attr_t.array[(index + 1) & wtm3] << attr_t.GAIN;
    int frac3 = (asat3 - (index << (27 - attr_t.LENGTHPOW)))
                << (attr_t.LENGTHPOW + 3);
    swt3 = ___SMMUL(y13, (1 << 30) - frac3);
    swt3 = ___SMMLA(y23, frac3, swt3);
  }
  WTOUT3 = swt3 << 2;

  int32_t swt4;
  {
    uint32_t asat4 = __USAT(phasor + wt4, 27);
    int index = asat4 >> (27 - attr_t.LENGTHPOW);
    int32_t y14 = attr_t.array[index] << attr_t.GAIN;
    int32_t y24 = attr_t.array[(index + 1) & wtm4] << attr_t.GAIN;
    int frac4 = (asat4 - (index << (27 - attr_t.LENGTHPOW)))
                << (attr_t.LENGTHPOW + 3);
    swt4 = ___SMMUL(y14, (1 << 30) - frac4);
    swt4 = ___SMMLA(y24, frac4, swt4);
  }
  WTOUT4 = swt4 << 2;

  int32_t swt5;
  {
    uint32_t asat5 = __USAT(phasor + wt5, 27);
    int index = asat5 >> (27 - attr_t.LENGTHPOW);
    int32_t y15 = attr_t.array[index] << attr_t.GAIN;
    int32_t y25 = attr_t.array[(index + 1) & wtm5] << attr_t.GAIN;
    int frac5 = (asat5 - (index << (27 - attr_t.LENGTHPOW)))
                << (attr_t.LENGTHPOW + 3);
    swt5 = ___SMMUL(y15, (1 << 30) - frac5);
    swt5 = ___SMMLA(y25, frac5, swt5);
  }
  WTOUT5 = swt5 << 2;

  int32_t swt6;
  {
    uint32_t asat6 = __USAT(phasor + wt6, 27);
    int index = asat6 >> (27 - attr_t.LENGTHPOW);
    int32_t y16 = attr_t.array[index] << attr_t.GAIN;
    int32_t y26 = attr_t.array[(index + 1) & wtm6] << attr_t.GAIN;
    int frac6 = (asat6 - (index << (27 - attr_t.LENGTHPOW)))
                << (attr_t.LENGTHPOW + 3);
    swt6 = ___SMMUL(y16, (1 << 30) - frac6);
    swt6 = ___SMMLA(y26, frac6, swt6);
  }
  WTOUT6 = swt6 << 2;

  int32_t swt7;
  {
    uint32_t asat7 = __USAT(phasor + wt7, 27);
    int index = asat7 >> (27 - attr_t.LENGTHPOW);
    int32_t y17 = attr_t.array[index] << attr_t.GAIN;
    int32_t y27 = attr_t.array[(index + 1) & wtm7] << attr_t.GAIN;
    int frac7 = (asat7 - (index << (27 - attr_t.LENGTHPOW)))
                << (attr_t.LENGTHPOW + 3);
    swt7 = ___SMMUL(y17, (1 << 30) - frac7);
    swt7 = ___SMMLA(y27, frac7, swt7);
  }
  WTOUT7 = swt7 << 2;

  int32_t swt8;
  {
    uint32_t asat8 = __USAT(phasor + wt8, 27);
    int index = asat8 >> (27 - attr_t.LENGTHPOW);
    int32_t y18 = attr_t.array[index] << attr_t.GAIN;
    int32_t y28 = attr_t.array[(index + 1) & wtm8] << attr_t.GAIN;
    int frac8 = (asat8 - (index << (27 - attr_t.LENGTHPOW)))
                << (attr_t.LENGTHPOW + 3);
    swt8 = ___SMMUL(y18, (1 << 30) - frac8);
    swt8 = ___SMMLA(y28, frac8, swt8);
  }
  WTOUT8 = swt8 << 2;

  RstON = (param_rston) ? inlet_reset : 0;
}

int32_t a1;
int32_t b1;
int32_t c1;
int32_t d1;
int32_t e1;
int32_t f1;
int32_t g1;
int32_t h1;
int32_t a2;
int32_t b2;
int32_t c2;
int32_t d2;
int32_t e2;
int32_t f2;
int32_t g2;
int32_t h2;
int32_t x;
int32_t y;

switch (int(MORPHINLETLIMIT + MORPHLIMIT >> 24) > 0
            ? MORPHINLETLIMIT + MORPHLIMIT >> 24
            : 0) {
case 0:
  a1 = WTOUT1, b1 = WTOUT2, c1 = WTOUT3, d1 = WTOUT4, e1 = WTOUT5, f1 = WTOUT6,
  g1 = WTOUT7, h1 = WTOUT8;
  break;
case 1:
  a1 = WTOUT2, b1 = WTOUT3, c1 = WTOUT4, d1 = WTOUT5, e1 = WTOUT6, f1 = WTOUT7,
  g1 = WTOUT8, h1 = WTOUT1;
  break;
case 2:
  a1 = WTOUT3, b1 = WTOUT4, c1 = WTOUT5, d1 = WTOUT6, e1 = WTOUT7, f1 = WTOUT8,
  g1 = WTOUT1, h1 = WTOUT2;
  break;
case 3:
  a1 = WTOUT4, b1 = WTOUT5, c1 = WTOUT6, d1 = WTOUT7, e1 = WTOUT8, f1 = WTOUT1,
  g1 = WTOUT2, h1 = WTOUT3;
  break;
case 4:
  a1 = WTOUT5, b1 = WTOUT6, c1 = WTOUT7, d1 = WTOUT8, e1 = WTOUT1, f1 = WTOUT2,
  g1 = WTOUT3, h1 = WTOUT4;
  break;
case 5:
  a1 = WTOUT6, b1 = WTOUT7, c1 = WTOUT8, d1 = WTOUT1, e1 = WTOUT2, f1 = WTOUT3,
  g1 = WTOUT4, h1 = WTOUT5;
  break;
case 6:
  a1 = WTOUT7, b1 = WTOUT8, c1 = WTOUT1, d1 = WTOUT2, e1 = WTOUT3, f1 = WTOUT4,
  g1 = WTOUT5, h1 = WTOUT6;
  break;
case 7:
  a1 = WTOUT8, b1 = WTOUT1, c1 = WTOUT2, d1 = WTOUT3, e1 = WTOUT4, f1 = WTOUT5,
  g1 = WTOUT6, h1 = WTOUT7;
  break;
default:
  a1 = WTOUT1, b1 = WTOUT2, c1 = WTOUT3, d1 = WTOUT4, e1 = WTOUT5, f1 = WTOUT7,
  g1 = WTOUT6, h1 = WTOUT8;
  break;
}
switch (int(MORPHINLETLIMIT + MORPHLIMIT >> 24) > 0
            ? MORPHINLETLIMIT + MORPHLIMIT >> 24
            : 0) {
case 0:
  a2 = WTOUT2, b2 = WTOUT3, c2 = WTOUT4, d2 = WTOUT5, e2 = WTOUT6, f2 = WTOUT7,
  g2 = WTOUT8, h2 = WTOUT1;
  break;
case 1:
  a2 = WTOUT3, b2 = WTOUT4, c2 = WTOUT5, d2 = WTOUT6, e2 = WTOUT7, f2 = WTOUT8,
  g2 = WTOUT1, h2 = WTOUT2;
  break;
case 2:
  a2 = WTOUT4, b2 = WTOUT5, c2 = WTOUT6, d2 = WTOUT7, e2 = WTOUT8, f2 = WTOUT1,
  g2 = WTOUT2, h2 = WTOUT3;
  break;
case 3:
  a2 = WTOUT5, b2 = WTOUT6, c2 = WTOUT7, d2 = WTOUT8, e2 = WTOUT1, f2 = WTOUT2,
  g2 = WTOUT3, h2 = WTOUT4;
  break;
case 4:
  a2 = WTOUT6, b2 = WTOUT7, c2 = WTOUT8, d2 = WTOUT1, e2 = WTOUT2, f2 = WTOUT3,
  g2 = WTOUT4, h2 = WTOUT5;
  break;
case 5:
  a2 = WTOUT7, b2 = WTOUT8, c2 = WTOUT1, d2 = WTOUT2, e2 = WTOUT3, f2 = WTOUT4,
  g2 = WTOUT5, h2 = WTOUT6;
  break;
case 6:
  a2 = WTOUT8, b2 = WTOUT1, c2 = WTOUT2, d2 = WTOUT3, e2 = WTOUT4, f2 = WTOUT5,
  g2 = WTOUT6, h2 = WTOUT7;
  break;
case 7:
  a2 = WTOUT1, b2 = WTOUT2, c2 = WTOUT3, d2 = WTOUT4, e2 = WTOUT5, f2 = WTOUT6,
  g2 = WTOUT7, h2 = WTOUT8;
  break;
default:
  a2 = WTOUT2, b2 = WTOUT3, c2 = WTOUT4, d2 = WTOUT5, e2 = WTOUT6, f2 = WTOUT7,
  g2 = WTOUT8, h2 = WTOUT1;
  break;
}
x = (MORPHINLETLIMIT + MORPHLIMIT) -
    (((MORPHINLETLIMIT + MORPHLIMIT) >> 24) << 24);
y = (1 << 24) - x;

MORPH = ___SMMUL(y << 4, a1 << 4) + ___SMMUL(x << 4, a2 << 4);

outlet_m = MORPH;

MORPHLIMIT = ___SMMUL(param_MORPH << 3, 1 + (56 << 21) << 2);
MORPHINLETLIMIT = ___SMMUL(inlet_m << 3, 1 + (56 << 21) << 2);

Privacy

© 2024 Zrna Research