risset5

5 output ramps and enveloppes for Risset type effects
Author: Smashed Transistors
License: LGPL
Github: tiar/lfo/risset5.axo

Inlets

frac32.bipolar pitch

Outlets

frac32 env1

frac32 ramp1

frac32 env2

frac32 ramp2

frac32 env3

frac32 ramp3

frac32 env4

frac32 ramp4

frac32 env5

frac32 ramp5

Parameters

frac32.s.map v1

frac32.s.map v0

frac32.s.map.lfopitch pitch

Attributes

combo rampType

Declaration
uint32_t p;

#define REVERSE (attr_rampType > 3)
#define POWER2 (attr_rampType == 2 || attr_rampType == 4)
#define POWER4 (attr_rampType == 3 || attr_rampType == 5)

int32_t v0, v1;
int32_t calcRamp(uint32_t p) {

  int32_t r = (int32_t)(p >> (32 - 27)); // q27
  if (REVERSE) {
    r = 0x07FFFFFF - r;
  }
  if (POWER2) {
    r = ___SMMUL(r, r) << 5;
  }
  if (POWER4) {
    r = ___SMMUL(r, r) << 5;
    r = ___SMMUL(r, r) << 5;
  }
  return ___SMMLA(r, v1 - v0, v0 >> 5) << 5;
}
int32_t calcEnv(uint32_t p) {
  // return abs((int32_t)p)>>(31-27);
  int32_t e = abs((int32_t)p); // q31
  // shaping 3x2-2x3 = x2(3-2x)
  //                q30    q31q31    q29     2eq29
  return ___SMMUL(___SMMUL(e, e), (3 << 29) - (e >> 1)); // q27
}
Init
p = 0;
Control Rate
int32_t dp;
MTOFEXTENDED(param_pitch + inlet_pitch, dp);
p += dp >> 2;

v0 = param_v0;
v1 = param_v1;

outlet_ramp1 = calcRamp(p);
outlet_env1 = calcEnv(p);

p += 858993459L;
outlet_ramp2 = calcRamp(p);
outlet_env2 = calcEnv(p);

p += 858993459L;
outlet_ramp3 = calcRamp(p);
outlet_env3 = calcEnv(p);

p += 858993459L;
outlet_ramp4 = calcRamp(p);
outlet_env4 = calcEnv(p);

p += 858993459L;
outlet_ramp5 = calcRamp(p);
outlet_env5 = calcEnv(p);

p += 858993460L;

Privacy

© 2024 Zrna Research