colvet

Author: Smashed Transistors
License: LGPL
Github: tiar/noise/colvet.axo

Inlets

frac32.bipolar pitch

frac32.bipolar randomness

Outlets

frac32buffer.bipolar out

Parameters

frac32.s.map pitch

frac32.s.map randomness

Declaration
uint32_t p;     // phase counter
int32_t dp;     // delta phase
int32_t r;      // sign and delta phase random gen
int32_t r2;     // color rand gen
int32_t nextR2; // color slide
int32_t env;    // decay exp env
uint8_t c;
Init
p = 0;
dp = 1 << 30;
r = 137;
r2 = 137;
nextR2 = 137;
env = 1 << 27;
c = 0;
Control Rate
int32_t basePitch = param_pitch + inlet_pitch;
int32_t mod = param_randomness + inlet_randomness; // pitch rand mod depth
c++;
if (c >= 100) {
  c = 0;
  nextR2 = -1511872763 * (nextR2 - 1);
}
Audio Rate
p += dp;
if (p < dp) { // p have just wrapped to zero
  // reset env with random sign
  env = (r = r * 69069 + 1) > 0 ? 1 << 28 : -1 << 28;
  // pitch with random modulation
  int32_t pitch = ___SMMLA(r = r * 69069 + 1, mod, basePitch);
  // delta phase
  MTOFEXTENDED(pitch, dp);
  //"color" slide
  r2 = nextR2;
}
outlet_out = ___SMMUL(r2, env);
// color pseudo rand seq
r2 = r2 * 69069 + 1;
// color env
env = ___SMMUL(env, 127 << 24) << 1;

Privacy

© 2024 Zrna Research