gnoise

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

Inlets

frac32 period

frac32 detune

frac32 jitter

frac32 slide

Outlets

frac32buffer.bipolar impulses

Parameters

frac32.u.map period

frac32.u.map detune

frac32.u.map jitter

frac32.u.map slide

Declaration
// const int32_t a = 69069;
// const int32_t b = 0;
const int32_t a = 1664525;
const int32_t b = 1013904223;
int32_t cForNewSeed;
int32_t cA, randA;
int32_t cB, randB;
int32_t cC, randC;
int32_t cD, randD;
int32_t seed;
uint32_t rand2;
int32_t nPeriodA;
Init
cA = cB = cC = cD;
seed = 987654321;
rand2 = 654624898UL;
Control Rate
// period in samples for generator A
int32_t period = (__USAT(param_period + inlet_period, 28) >> (27 - 11)) + 64;
// depth of the random jitter on the period
int32_t jitter = __USAT(param_jitter + inlet_jitter, 27);
jitter = ___SMMUL(jitter, jitter) << 5;
jitter = ___SMMUL(jitter, period) << 4;
// each period, the seed is changed to create an evolving sound
int32_t slide = __USAT(param_slide + inlet_slide, 27) >> (27 - 8);
// detunings for the 3 co generators
int32_t detune = __USAT(inlet_detune + param_detune, 27);
int32_t detB = ___SMMUL(34 << 5, detune);
int32_t detC = ___SMMUL(-14 << 5, detune);
int32_t detD = ___SMMUL(-10 << 5, detune);

for (int i = 0; i < BUFSIZE; i++) {
  // The (de)counter for generator A reaches zero
  // we reset the generator to the seed
  // we randomize the (de)counter cA according to jitter
  if (cA <= 0) {
    randA = seed;
    rand2 = rand2 * 69069UL + 1UL;
    cA = nPeriodA = ___SMMLA(rand2 & 0x7FFFFFFF, jitter, period);
    rand2 = rand2 * 69069UL + 1UL;
    cForNewSeed = ___SMMLS(rand2, slide, cA);
  }
  // seed "slide" to create evolving sounds
  if (cA == cForNewSeed) {
    seed = randA;
  }
  cA--;
  outlet_out[i] = ((randA = randA * a + b) >> (31 - 25));
}
// "detuned" co-generators create intricate interferences
for (int i = 0; i < BUFSIZE; i++) {
  if (cB <= 0) {
    randB = seed;
    cB = nPeriodA + detB;
  }
  cB--;
  outlet_out[i] += (randB = randB * a + b) >> (31 - 25);
}
for (int i = 0; i < BUFSIZE; i++) {
  if (cC <= 0) {
    randC = seed;
    cC = nPeriodA + detC;
  }
  cC--;
  outlet_out[i] += (randC = randC * a + b) >> (31 - 25);
}
for (int i = 0; i < BUFSIZE; i++) {
  if (cD <= 0) {
    randD = seed;
    cD = nPeriodA + detD;
  }
  cD--;
  outlet_out[i] += (randD = randD * a + b) >> (31 - 25);
}

Privacy

© 2024 Zrna Research