CY2

non-alliased 4x squarewave based cymbal generator
Author: Remco van der Most
License: BSD
Github: sss/edrum/CY2.axo

Inlets

frac32 pitch

frac32 closed

frac32 open

Outlets

frac32buffer.positive phasor wave

Parameters

frac32.u.map lvl

frac32.u.map.kdecaytime decClosed

frac32.u.map.kdecaytime decOpen

frac32.s.map p1

frac32.s.map p2

frac32.s.map p3

frac32.s.map p4

frac32.s.map pw1

frac32.s.map pw2

frac32.s.map pw3

frac32.s.map pw4

frac32.s.map pwm1

frac32.s.map pwm2

frac32.s.map pwm3

frac32.s.map pwm4

frac32.s.map fmw

Declaration
int32_t Phase[4];
int32_t wave[4];
int i;
int32_t env;
bool trg;
uint32_t D;
Init
for (i = 0; i < 4; i++) {
  Phase[i] = 0;
}
Control Rate
uint32_t freq[4];
MTOFEXTENDED(param_p1 + inlet_pitch, freq[0]);
MTOFEXTENDED(param_p2 + inlet_pitch, freq[1]);
MTOFEXTENDED(param_p3 + inlet_pitch, freq[2]);
MTOFEXTENDED(param_p4 + inlet_pitch, freq[3]);

int32_t pw[4];
pw[0] = param_pw1;
pw[1] = param_pw2;
pw[2] = param_pw3;
pw[3] = param_pw4;
int32_t pwm[4];
pwm[0] = param_pwm1;
pwm[1] = param_pwm2;
pwm[2] = param_pwm3;
pwm[3] = param_pwm4;
int32_t lvl = param_lvl >> 2;
int32_t fmw = param_fmw;

bool TRG = inlet_closed + inlet_open;

env -= ___SMMUL(env, D);

if (TRG && !trg) {
  trg = 1;
  if (inlet_open > 0) {
    env = inlet_open;
    MTOF((-param_decOpen << 1) + (1 << 27), D)
  } else if (inlet_closed > 0) {
    env = inlet_closed;
    MTOF((-param_decClosed << 1) + (1 << 27), D)
  }
} else if (TRG == 0) {
  trg = 0;
}
Audio Rate
int32_t out = 0;
for (i = 0; i < 4; i++) {
  Phase[i] += freq[i] + ___SMMUL(fmw << 4, wave[(i + 3) & 3] << 3);
  wave[i] +=
      ((Phase[i] > (pw[i] + ___SMMUL(pwm[i] << 4, wave[(i + 3) & 3] << 3) << 5)
            ? lvl
            : -lvl) -
       wave[i]) >>
      4;
  out += wave[i];
}
outlet_wave = ___SMMUL(out << 2, env << 3);

Privacy

© 2024 Zrna Research