waveformRandom

Random waveform-table generator. Creates random waves into the "waveformGenerator" module. Amount of waveforms created depends on the setting on the "waveformGenerator". Use "waveformTableCombinor" to combine tables.
Author: Remco van der Most
License: BSD
Github: sss/osc/waveformRandom.axo

Inlets

None

Outlets

None

Parameters

int32 damp

bool32.mom create

Attributes

objref table

combo size

Declaration
static const uint32_t LENGTHPOW = (attr_size);
static const uint32_t LENGTH = (1 << attr_size);
static const uint32_t LENGTHMASK = ((1 << attr_size) - 1);
int32_t *A;

int i;
int j;
int k;
int l;
int gtrig;
int32_t val;
Init
static int32_t _A[LENGTH] __attribute__((section(".sdram")));
A = &_A[0];
Control Rate
if ((param_create > 0) && !gtrig) {
  gtrig = 1;
  for (i = 0; i < attr_table.Waveforms; i++) {
    uint32_t Time =
        ((((uint32_t)(GenerateRandomNumber()) & attr_table.LENGTHMASK)) >> 5);
    int32_t count;
    val = ___SMMUL((int32_t)(GenerateRandomNumber()), attr_table.maxLvl << 22);
    for (j = 0; j < attr_table.LENGTH; j++) {
      count += 1;
      if (count >= Time) {
        count = 0;
        Time =
            ((((uint32_t)(GenerateRandomNumber()) & attr_table.LENGTHMASK)) >>
             5);
        val = ___SMMUL((int32_t)(GenerateRandomNumber()),
                       attr_table.maxLvl << 22);
      }
      attr_table.array[j + i * attr_table.LENGTH] =
          (val - attr_table.array[((j - 1) & attr_table.LENGTHMASK) +
                                  i * attr_table.LENGTH] >>
           param_damp) +
          attr_table
              .array[((j - 1) & attr_table.LENGTHMASK) + i * attr_table.LENGTH];
    }
  }

  for (i = 0; i < attr_table.Waveforms; i++) {
    for (l = 0; l < attr_table.LENGTH; l++) {
      A[l] = attr_table.array[l + i * attr_table.LENGTH];
    }
    for (j = 0; j < attr_table.LENGTH; j++) {
      int32_t sum = 0;
      for (k = 0; k < 16; k++) {
        sum += A[((j - 8 + k) & attr_table.LENGTHMASK)] >> 4;
      }
      attr_table.array[j + i * attr_table.LENGTH] = sum;
    }
  }
  attr_table.Do = 1;
} else if (param_create == 0) {
  gtrig = 0;
}

Privacy

© 2024 Zrna Research