multiNoise

Seeded random generator with lots of goodies to change the character of the noise. Hard to tell what each control does, best is just to check it out and listen to the responses when changing a parameter while showing the signal on a display &/ analyser.
Author: Remco van der most
License: BSD
Github: sss/noise/multiNoise.axo

Inlets

bool32 init

bool32 RANDOM

frac32 pitch

frac32 rate

frac32buffer fFM

frac32buffer rFM

Outlets

frac32buffer.bipolar white noise

frac32buffer phase

Parameters

frac32.s.map.pitch pitch

frac32.s.map.pitch rate

frac32.s.map.pitch damp

frac32.u.map chaotic

frac32.u.map same

frac32.u.map update

frac32.s.map fixRnd

frac32.s.map modF

frac32.s.map brighten

bool32.tgl rnd

bool32.tgl linkP2R

bool32.tgl randFix

bool32.tgl linkO2F

bool32.tgl linkD2B

Declaration
uint32_t seeds[8];
uint32_t Seeds[8];
uint32_t SeedS[8];
int32_t phase;
bool ptrig;
bool itrig;
int i;
uint32_t Updater;
bool utrig;
int32_t n;
int32_t val1;
int32_t val2;
int32_t val3;
int32_t fixed;
bool RTRG;
Init
SeedS[0] = 0x21c32332 + GenerateRandomNumber();
SeedS[1] = 0xfbc57f7a + GenerateRandomNumber();
SeedS[2] = 0x7dd1ef4a + GenerateRandomNumber();
SeedS[3] = 0xe4ec34ad + GenerateRandomNumber();
SeedS[4] = 0x72007b2f + GenerateRandomNumber();
SeedS[5] = 0x3d1e9783 + GenerateRandomNumber();
SeedS[6] = 0xa4a8f892 + GenerateRandomNumber();
SeedS[7] = 0xc82c5e28 + GenerateRandomNumber();

for (i = 0; i < 8; i++) {
  Seeds[i] = SeedS[i];
}
fixed = (int32_t)GenerateRandomNumber();
Control Rate
if ((inlet_RANDOM > 0) && !RTRG) {
  RTRG = 1;
  int32_t Trn = ((int32_t)GenerateRandomNumber() >> 4);
  Trn = -___SMMUL(Trn << 2, Trn << 2) + (3 << 25);
  PExParameterChange(&parent->PExch[PARAM_INDEX_attr_legal_name_pitch], Trn,
                     0xFFFD);
  PExParameterChange(&parent->PExch[PARAM_INDEX_attr_legal_name_linkP2R],
                     (int)GenerateRandomNumber() & 1, 0xFFFD);
  Trn = ((int32_t)GenerateRandomNumber() >> 4);
  Trn = -___SMMUL(Trn << 2, Trn << 2) + (3 << 25);
  PExParameterChange(&parent->PExch[PARAM_INDEX_attr_legal_name_rate], Trn,
                     0xFFFD);
  PExParameterChange(&parent->PExch[PARAM_INDEX_attr_legal_name_chaotic],
                     (uint32_t)GenerateRandomNumber() >> 5, 0xFFFD);
  PExParameterChange(&parent->PExch[PARAM_INDEX_attr_legal_name_same],
                     (uint32_t)GenerateRandomNumber() >> 5, 0xFFFD);
  PExParameterChange(&parent->PExch[PARAM_INDEX_attr_legal_name_update],
                     (uint32_t)GenerateRandomNumber() >> 5, 0xFFFD);
  PExParameterChange(&parent->PExch[PARAM_INDEX_attr_legal_name_fixRnd],
                     (int32_t)GenerateRandomNumber() >> 4, 0xFFFD);
  //	PExParameterChange(&parent->PExch[PARAM_INDEX_attr_legal_name_randFix],(int)
  //GenerateRandomNumber()&1,0xFFFD);
  PExParameterChange(&parent->PExch[PARAM_INDEX_attr_legal_name_linkO2F],
                     (int)GenerateRandomNumber() & 1, 0xFFFD);
  PExParameterChange(&parent->PExch[PARAM_INDEX_attr_legal_name_modF],
                     (int32_t)GenerateRandomNumber() >> 4, 0xFFFD);
  PExParameterChange(&parent->PExch[PARAM_INDEX_attr_legal_name_damp],
                     ((int32_t)GenerateRandomNumber() >> 4) + (1 << 25),
                     0xFFFD);
  PExParameterChange(&parent->PExch[PARAM_INDEX_attr_legal_name_linkD2B],
                     (int)GenerateRandomNumber() & 1, 0xFFFD);
  //	PExParameterChange(&parent->PExch[PARAM_INDEX_attr_legal_name_brighten],((int32_t)
  //GenerateRandomNumber()>>5),0xFFFD);
} else if (inlet_RANDOM == 0) {
  RTRG = 0;
}
int32_t freq;
int32_t pitch = param_pitch + inlet_pitch;
MTOFEXTENDED(pitch, freq)
int32_t rate = param_rate + inlet_rate;
MTOFEXTENDED(rate + pitch * param_linkP2R, rate)
int32_t F;
int32_t damp = param_damp + pitch * param_linkO2F;

int32_t G;
int32_t B = param_brighten + damp * param_linkD2B;

int32_t update = param_update;
update = ___SMMUL(update << 3, update << 2);
update = ___SMMUL(update << 3, update << 2);
update = update - (1 << 26) << 1;

int32_t chaos = (1 << 27) - param_chaotic;

if ((inlet_init > 0) && !itrig) {
  itrig = 1;
  for (i = 0; i < 8; i++) {
    Seeds[i] = SeedS[i];
  }
  phase = 0;
  Updater = 0;
} else if (inlet_init == 0) {
  itrig = 0;
}

if (param_rnd > 0) {
  for (i = 0; i < 8; i++) {
    Seeds[i] = SeedS[i] = (int32_t)GenerateRandomNumber();
  }
}
MTOF(damp + ___SMMUL(param_modF << 2, n << 4), F)
MTOF(B + ___SMMUL(param_modF << 2, n << 4), G)
Audio Rate
phase += freq + (___SMMUL(freq, inlet_fFM) << 6);

Updater += rate + (___SMMUL(rate, inlet_rFM) << 6);

if (Updater > (1 << 31)) {
  Updater = 0;
  n = 0;
  utrig = 1;
  for (i = 0; i < 8; i++) {

    seeds[i] += ___SMMUL((seeds[(i + 1) & 7] * 196314165) + 907633515,
                         (1 << 27) - param_same << 4)
                << 1;
    n += ((int32_t)(seeds[i])) >> 7;

    if (((int32_t)GenerateRandomNumber() >> 4) < update) {
      Seeds[i] += ((int32_t)(GenerateRandomNumber() >> 4)) < param_fixRnd
                      ? (int32_t)GenerateRandomNumber()
                      : fixed;
    }
  }

  if ((phase > 0) && !ptrig) {
    if (param_randFix > 0) {
      fixed = (int32_t)GenerateRandomNumber();
    }
    ptrig = 1;
    if (((uint32_t)GenerateRandomNumber() >> 5) < chaos) {
      for (i = 0; i < 8; i++) {
        seeds[i] = Seeds[i];
      }
    }
  } else if ((phase < 0) && ptrig) {
    ptrig = 0;
  }
}

outlet_phase = phase;

val1 = ___SMMLA((n - val1) << 1, F, val1);
val2 = ___SMMLA((val1 - val2) << 1, F, val2);
val3 = ___SMMLA((val2 - val3) << 1, G, val3);

outlet_wave = val2 - val3;

Privacy

© 2024 Zrna Research