cymb2

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

Inlets

bool32 newSeed

Outlets

frac32buffer.bipolar out

Declaration
static const int NB = 8;
static const int32_t a = 1664525;
static const int32_t b = 1013904223;
int16_t p[NB];
int32_t seed;
int16_t c[NB];
int32_t r[NB];
int32_t rB[NB];
bool _newSeed = false;

int8_t sc = 0; // slide counter
Init
for (int j = 0; j < NB; j++) {
  c[j] = r[j] = rB[j] = 0;
}
seed = GenerateRandomNumber();
p[0] = 26;
p[1] = 55;
p[2] = 100;
p[3] = 103;
p[4] = 227;
p[5] = 238;
p[6] = 551;
p[7] = 839;
Control Rate
if (!_newSeed && inlet_newSeed) {
  seed = GenerateRandomNumber();
}
_newSeed = inlet_newSeed;

if (sc <= 0) {
  sc = 64;
  seed = seed * a + b;
}
sc--;
for (int i = 0; i < BUFSIZE; i++) {
  outlet_out[i] = 0;
}
for (int j = 0; j < NB; j++) {
  int32_t _c = c[j];
  int32_t _r = r[j];
  int32_t _rB = rB[j];
  int32_t p_2 = p[j] >> 1;
  for (int i = 0; i < BUFSIZE; i++) {
    if (_c <= 0) {
      _c = p[j];
      _r = seed;
    }
    outlet_out[i] += (_r = _r * a + b) >> (31 - 23);
    if (_c == p_2)
      _rB = seed;
    outlet_out[i] += (_rB = _rB * a + b) >> (31 - 23);
    _c--;
  }
  c[j] = _c;
  r[j] = _r;
  rB[j] = _rB;
}

Privacy

© 2024 Zrna Research