3Shape

Multi waveform shaper like the eurorack modular ADE-10 of abstract data. Features 7 modes (at the moment), mode-selection is kept within selection bounds, so any value can be send to the inputs. Except for mode 0 (filter), the ofs input and knob control a dc offset given to the audio going into the shaper. mode=0 : filter->mod controls cutoff, ofs morphs through LP/BP/HP mode mode=1 : mid-offset modifier->enlarges positive and negative side to reach the respective other range mode=2 : sineshaper->mod controls gain of input mode=3 : sined squareshaper->mod controls gain of input mode=4 : sined squareshaper with wrap->mod controls gain of input mode=5 : wrapper->mod controls gain mode=6 : quantizer->mod controls quantification mode=7 : triangle bounce->mod controls gain, the higher, the faster the triangle
Author: Remco van der Most
License: BSD
Github: sss/dist/3Shape.axo

Inlets

frac32 ofs1

frac32 mod1

frac32 ofs2

frac32 mod2

frac32 ofs3

frac32 mod3

frac32buffer in

int32 Md1

int32 Md2

int32 Md3

Outlets

frac32buffer out

Parameters

int32 Mode1

int32 Mode2

int32 Mode3

frac32.u.map mix1

frac32.u.map mix2

frac32.u.map mix3

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 audia;
int32_t val[3];
int32_t f;
int32_t cccomp;

int32_t mode1(int32_t input, int32_t modulate, int instance, int32_t extra) {
  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, int instance, int32_t extra) {
  int32_t sine;
  SINE2TINTERP((input << 3) + ___SMMUL(input << 5, modulate << 4), sine)
  audio = sine >> 4;
}

int32_t mode3(int32_t input, int32_t modulate, int instance, int32_t extra) {
  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, int instance, int32_t extra) {
  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, int instance, int32_t extra) {
  audio = ((input + (1 << 27) + ___SMMUL(modulate << 5, input << 4)) &
           ((1 << 28) - 1)) -
          (1 << 27);
}

int32_t mode6(int32_t input, int32_t modulate, int instance, int32_t extra) {
  audio = input / modulate * modulate;
}

int32_t mode7(int32_t input, int32_t modulate, int instance, int32_t extra) {
  audio = (((1 << 27) + input + ___SMMUL(modulate << 3, input << 3)) &
           ((1 << 28) - 1)) -
          (1 << 27);
  audio = audio > (1 << 27) ? ((1 << 27) - (audio - (1 << 27))) : audio;
  audio = audio < (-1 << 27) ? ((-1 << 27) - (audio + (1 << 27))) : audio;
}

int32_t mode8(int32_t input, int32_t modulate, int instance, int32_t extra) {
  MTOF(modulate, f)
  val[instance] = ___SMMLA(((input - val[instance]) << 1), f, val[instance]);
  cccomp = (1 << 26) + (extra >> 1);
  audio = val[instance] - ___SMMUL(input << 3, cccomp << 2);
}
Control Rate
int32_t Mode1;
int32_t Mode2;
int32_t Mode3;
Mode1 = (param_Mode1 + inlet_Md1) & 7;
Mode2 = (param_Mode2 + inlet_Md2) & 7;
Mode3 = (param_Mode3 + inlet_Md3) & 7;

int32_t mix1;
int32_t mix2;
int32_t mix3;
mix1 = (1 << 27) - param_mix1;
mix2 = (1 << 27) - param_mix2;
mix3 = (1 << 27) - param_mix3;
Audio Rate
audio = inlet_in + ___SMMUL(inlet_in << 3, param_gainIn << 3);
audia = audio;
switch (Mode1 > 0 ? Mode1 : 0) {
case 0:
  mode8(audio, param_mod1 + inlet_mod1, 0, inlet_ofs1 + param_ofs1);
  break;
case 1:
  mode1(audio + inlet_ofs1 + param_ofs1, param_mod1 + inlet_mod1, 0, 0);
  break;
case 2:
  mode2(audio + inlet_ofs1 + param_ofs1, param_mod1 + inlet_mod1, 0, 0);
  break;
case 3:
  mode3(audio + inlet_ofs1 + param_ofs1, param_mod1 + inlet_mod1, 0, 0);
  break;
case 4:
  mode4(audio + inlet_ofs1 + param_ofs1, param_mod1 + inlet_mod1, 0, 0);
  break;
case 5:
  mode5(audio + inlet_ofs1 + param_ofs1, param_mod1 + inlet_mod1, 0, 0);
  break;
case 6:
  mode6(audio + inlet_ofs1 + param_ofs1, param_mod1 + inlet_mod1, 0, 0);
  break;
case 7:
  mode7(audio + inlet_ofs1 + param_ofs1, param_mod1 + inlet_mod1, 0, 0);
  break;
}
audio = ___SMMUL(mix1 << 3, audia << 2) + ___SMMUL(param_mix1 << 3, audio << 2);
audia = audio;
switch (Mode2 > 0 ? Mode2 : 0) {
case 0:
  mode8(audio, param_mod2 + inlet_mod2, 1, inlet_ofs2 + param_ofs2);
  break;
case 1:
  mode1(audio + inlet_ofs2 + param_ofs2, param_mod2 + inlet_mod2, 1, 0);
  break;
case 2:
  mode2(audio + inlet_ofs2 + param_ofs2, param_mod2 + inlet_mod2, 1, 0);
  break;
case 3:
  mode3(audio + inlet_ofs2 + param_ofs2, param_mod2 + inlet_mod2, 1, 0);
  break;
case 4:
  mode4(audio + inlet_ofs2 + param_ofs2, param_mod2 + inlet_mod2, 1, 0);
  break;
case 5:
  mode5(audio + inlet_ofs2 + param_ofs2, param_mod2 + inlet_mod2, 1, 0);
  break;
case 6:
  mode6(audio + inlet_ofs2 + param_ofs2, param_mod2 + inlet_mod2, 1, 0);
  break;
case 7:
  mode7(audio + inlet_ofs2 + param_ofs2, param_mod2 + inlet_mod2, 1, 0);
  break;
}
audio = ___SMMUL(mix2 << 3, audia << 2) + ___SMMUL(param_mix2 << 3, audio << 2);
audia = audio;
switch (Mode3 > 0 ? Mode3 : 0) {
case 0:
  mode8(audio, param_mod3 + inlet_mod3, 2, inlet_ofs3 + param_ofs3);
  break;
case 1:
  mode1(audio + inlet_ofs3 + param_ofs3, param_mod3 + inlet_mod3, 2, 0);
  break;
case 2:
  mode2(audio + inlet_ofs3 + param_ofs3, param_mod3 + inlet_mod3, 2, 0);
  break;
case 3:
  mode3(audio + inlet_ofs3 + param_ofs3, param_mod3 + inlet_mod3, 2, 0);
  break;
case 4:
  mode4(audio + inlet_ofs3 + param_ofs3, param_mod3 + inlet_mod3, 2, 0);
  break;
case 5:
  mode5(audio + inlet_ofs3 + param_ofs3, param_mod3 + inlet_mod3, 2, 0);
  break;
case 6:
  mode6(audio + inlet_ofs3 + param_ofs3, param_mod3 + inlet_mod3, 2, 0);
  break;
case 7:
  mode7(audio + inlet_ofs3 + param_ofs3, param_mod3 + inlet_mod3, 2, 0);
  break;
}
audio = ___SMMUL(mix3 << 3, audia << 2) + ___SMMUL(param_mix3 << 3, audio << 2);
audia = audio;
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