permuList4

Combination module based on permutation: Creates a full list of 4-number-combinations from the available options. No repetition, no importance of order. eg: 1,2,3,4 1,2,3,5 or 3,6,8,11 (any increasing order) BUT NOT: 1,1,3,3,6 (no repetition of numbers) AND NOT: 3,1,6,5 (not smaller then any value left of itself) "select" knob is scaled to the amount of possible combinations "fine" knob can be used when using a high option count->otherwise the stepsize would be to big to select all possible combinations. The 4 outputs give you the selected indices. This module could be used for selecting 4 out of 16 functions which may not be selected twice.
Author: Remco van der Most
License: BSD
Github: sss/ctrl/permuList4.axo

Inlets

None

Outlets

int32 o1

int32 o2

int32 o3

int32 o4

Parameters

frac32.u.map.gain sets the amount of options the 4 slots can choose from

frac32.u.map.gain with high options count, you might need this knob to be able to reach all steps (eg. when using 8bit midi to control the knobs)

Attributes

combo options

Displays

int32.label options

int32.label d1

int32.label d2

int32.label d3

int32.label d4

Declaration
int i;
int T[13] = {1, 5, 15, 35, 70, 126, 210, 330, 495, 715, 1001, 1365, 1820};
int options;
int32_t q = attr_options;
uint8_t *c;
// int c[attr_options<<2];
Init
static uint8_t _array[attr_options << 2] __attribute__((section(".sdram")));
c = &_array[0];

for (i = 0; i < 13; i++) {
  if (T[i] == attr_options) {
    options = i + 4;
  }
}

for (i = 0; i < 4; i++) {
  c[i] = i;
}
int j;
for (i = 1; i < q; i++) {
  int k = i << 2;
  for (j = 0; j < 4; j++) {
    c[k + j] = c[k + j - 4];
  }
  c[k + 3] += 1;

  while ((c[k + 3] >= options) || (c[k + 2] >= options - 1) ||
         (c[k + 1] >= options - 2)) {
    if (c[k + 3] >= options) {
      c[k + 2] += 1;
      c[k + 3] = c[k + 2] + 1;
    }
    if (c[k + 2] >= (options - 1)) {
      c[k + 1] += 1;
      c[k + 2] = c[k + 1] + 1;
      c[k + 3] = c[k + 2] + 1;
    }
    if (c[k + 1] >= (options - 2)) {
      c[k] += 1;
      c[k + 1] = c[k + 0] + 1;
      c[k + 2] = c[k + 1] + 1;
      c[k + 3] = c[k + 2] + 1;
    }
  }
}
Control Rate
disp_options = q;
int pst =
    ___SMMUL(((q) << 1), __USAT((uint32_t)(param_fine >> 7) + param_select, 31))
    << 2;
outlet_o1 = disp_d1 = c[pst];
outlet_o2 = disp_d2 = c[pst + 1];
outlet_o3 = disp_d3 = c[pst + 2];
outlet_o4 = disp_d4 = c[pst + 3];

Privacy

© 2024 Zrna Research