pink oct

Cheap almost pink noise Range -64..64. Configureable number of octaves.
Author: Johannes Taelman
License: BSD
Github: noise/pink oct.axo

Inlets

None

Outlets

frac32buffer.bipolar pink noise

Attributes

combo octaves

Declaration
static const int noct = attr_octaves;
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, 7};
  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 == attr_octaves) {
  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) >> attr_octaves);

Privacy

© 2024 Zrna Research