WeightedFolMod

Records the weights for each note-follow-up and copies it into the internal array of the "WeightedFollow module" when you hit "copy". Connect a midi module note and gate outputs to the note and gate inputs and play a melody. Make sure your last played note makes a connection back to another note played before.
Author: Remco van der Most
License: BSD
Github: sss/patt/WeightedFolMod.axo

Inlets

bool32 gate

int32 note

Outlets

None

Parameters

bool32.mom copy

bool32.mom reset

Attributes

objref core

Declaration
static const uint32_t LENGTH = 48 * 48;
int32_t prev;
int i;
int gtrig;
int16_t *array;
int j;
int ctrig;
int rtrig;
Init
static int16_t _array[LENGTH] __attribute__((section(".sdram")));
array = &_array[0];

for (i = 0; i < LENGTH; i++) {
  array[i] = 0;
}
int prev = 0;
Control Rate
if ((param_reset > 0) && !rtrig) {
  rtrig = 1;
  for (i = 0; i < LENGTH; i++) {
    array[i] = 0;
  }
} else if (param_reset == 0) {
  rtrig = 0;
}

if ((inlet_gate > 0) && !gtrig) {
  gtrig = 1;
  int32_t NOTE = inlet_note;
  NOTE = NOTE - NOTE / 48 * 48;
  NOTE = NOTE >= 0 ? NOTE : NOTE + 48;
  array[prev + NOTE] += 1;
  prev = NOTE * 48;
} else if (inlet_gate == 0) {
  gtrig = 0;
}

if ((param_copy > 0) && !ctrig) {
  ctrig = 1;
  for (i = 0; i < 48; i++) {
    for (j = 0; j < 48; j++) {
      attr_core.array[i * 48 + j] = array[i * 48 + j];
      if (j > 0) {
        attr_core.array[i * 48 + j] += attr_core.array[i * 48 + j - 1];
      }
    }
  }
} else if (param_copy == 0) {
  ctrig = 0;
}

Privacy

© 2024 Zrna Research