pink

Cheap almost pink noise over 7 octaves. Range -64..64
Author: Johannes Taelman
License: BSD
Github: noise/pink.axo

Inlets

None

Outlets

frac32buffer.bipolar pink noise

Declaration
static const int noct = 7;
int32_t obuf[noct];
int32_t sum;
uint32_t seed;
int index;
const int8_t *dyadictree(void) {
  static const int8_t dtree[] = {
      0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1,
      0, 3, 0, 1, 0, 2, 0, 1, 0, 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2,
      0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 6, 0, 1,
      0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3,
      0, 1, 0, 2, 0, 1, 0, 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1,
      0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, -1};
  return dtree;
}
Init
int i;
for (i = 0; i < noct; i++)
  obuf[i] = 0;
index = 0;
sum = 0;
seed = 0x830af41e + GenerateRandomNumber();
Audio Rate
int o = dyadictree()[index++];
if (o == -1) {
  index = 0;
} else {
  sum -= obuf[o];
  seed = (seed * 196314165) + 907633515;
  obuf[o] = ((int32_t)seed) >> 7;
  sum += obuf[o];
}
seed = (seed * 196314165) + 907633515;
outlet_out = sum + (((int32_t)seed) >> 7);

Privacy

© 2024 Zrna Research