3StageShaper

Multistage multimode waveshaper This module features 3 stages with selectable waveshaper-mode. Each mode will leave the incoming waveform unharmed as long as it's values are zero. As soon as any of the values are changed, the mode will induce it's destructive property. Offset offsets the incoming waveform (dc-offset) mod# will apply an amount of the mode-effect.
Author: Remco van der Most
License: BSD
Github: sss/dist/3StageShaper.axo

Inlets

frac32buffer in

frac32 ofs1

frac32 mod1

frac32 ofs2

frac32 mod2

frac32 ofs3

frac32 mod3

Outlets

frac32buffer out

Parameters

int32 Mode1

int32 Mode2

int32 Mode3

frac32.s.map gainIn

frac32.s.map mod1

frac32.s.map ofs1

frac32.s.map mod2

frac32.s.map ofs2

frac32.s.map mod3

frac32.s.map ofs3

Declaration
int32_t audio;
int32_t LP;
int32_t HP;
int32_t mode1(int32_t input, int32_t modulate) {
  audio = input > 0 ? input + ___SMMUL((input - (1 << 27)) << 3, modulate << 2)
                    : input + ___SMMUL((input + (1 << 27)) << 3, modulate << 2);
}

int32_t mode2(int32_t input, int32_t modulate) {
  int32_t sine;
  SINE2TINTERP((input << 3) + ___SMMUL(input << 5, modulate << 4), sine)
  audio = sine >> 4;
}

int32_t mode3(int32_t input, int32_t modulate) {
  int32_t sine;
  SINE2TINTERP(__SSAT((input << 2) + ___SMMUL(input << 5, modulate << 4), 31),
               sine)
  audio = sine >> 4;
}

int32_t mode4(int32_t input, int32_t modulate) {
  int32_t sine;
  SINE2TINTERP(__SSAT((input << 2) + ___SMMUL(input << 4, modulate << 4), 30),
               sine)
  audio = sine >> 4;
}

int32_t mode5(int32_t input, int32_t modulate) {
  audio = ((input + (1 << 27) + modulate) & ((1 << 28) - 1)) - (1 << 27);
}

int32_t mode6(int32_t input, int32_t modulate) {
  audio = input / modulate * modulate;
}
Audio Rate
audio = inlet_in + ___SMMUL(inlet_in << 3, param_gainIn << 3);
switch (param_Mode1 > 0 ? param_Mode1 : 0) {
case 0:
  mode1(audio + inlet_ofs1 + param_ofs1, param_mod1 + inlet_mod1);
  break;
case 1:
  mode2(audio + inlet_ofs1 + param_ofs1, param_mod1 + inlet_mod1);
  break;
case 2:
  mode3(audio + inlet_ofs1 + param_ofs1, param_mod1 + inlet_mod1);
  break;
case 3:
  mode4(audio + inlet_ofs1 + param_ofs1, param_mod1 + inlet_mod1);
  break;
case 5:
  mode6(audio + inlet_ofs1 + param_ofs1, param_mod1 + inlet_mod1);
  break;
}

switch (param_Mode2 > 0 ? param_Mode2 : 0) {
case 0:
  mode1(audio + inlet_ofs2 + param_ofs2, param_mod2 + inlet_mod2);
  break;
case 1:
  mode2(audio + inlet_ofs2 + param_ofs2, param_mod2 + inlet_mod2);
  break;
case 2:
  mode3(audio + inlet_ofs2 + param_ofs2, param_mod2 + inlet_mod2);
  break;
case 3:
  mode4(audio + inlet_ofs2 + param_ofs2, param_mod2 + inlet_mod2);
  break;
case 4:
  mode5(audio + inlet_ofs2 + param_ofs2, param_mod2 + inlet_mod2);
  break;
case 5:
  mode6(audio + inlet_ofs2 + param_ofs2, param_mod2 + inlet_mod2);
  break;
}

switch (param_Mode3 > 0 ? param_Mode3 : 0) {
case 0:
  mode1(audio + inlet_ofs3 + param_ofs3, param_mod3 + inlet_mod3);
  break;
case 1:
  mode2(audio + inlet_ofs3 + param_ofs3, param_mod3 + inlet_mod3);
  break;
case 2:
  mode3(audio + inlet_ofs3 + param_ofs3, param_mod3 + inlet_mod3);
  break;
case 3:
  mode4(audio + inlet_ofs3 + param_ofs3, param_mod3 + inlet_mod3);
  break;
case 4:
  mode5(audio + inlet_ofs3 + param_ofs3, param_mod3 + inlet_mod3);
  break;
case 5:
  mode6(audio + inlet_ofs3 + param_ofs3, param_mod3 + inlet_mod3);
  break;
}
audio = audio > (1 << 27) ? (1 << 27) - (audio - (1 << 27)) : audio;
audio = audio < (-1 << 27) ? (-1 << 27) - (audio + (1 << 27)) : audio;
LP = LP + (((audio >> 1) - LP) >> 1);
HP = HP + ((LP - HP) >> 11);
outlet_out = LP - HP;

Privacy

© 2024 Zrna Research