euclid length out

Euclidean rhythm generator. Chainable. Notes specifics the number of active steps, length the number of steps of the sequence (maximum sequence length=31). Inlet in specifics what step to read, like sel i 16/32 or disp/ibar . If outside the range the default inlet will be outputted (like said objects). Dynamic algorithm, therefore variable dsp load with different configurations. Additional outlet outputs an integer represention of the current sequence: you can decode the number with multiple logic/decode bin 8 chained
Author: Sputnki
License: BSD
Github: sptnk/sequencer/euclid length out.axo

Inlets

int32.positive step select

bool32 default

Outlets

int32.positive chain output

bool32 bool out

int32 encoded output

Parameters

int32 notes

int32 length

Declaration
bool sequence[31];
int powers[31];
Init
for (int i = 0; i < 31; i += 1) {
  powers[i] = 1 << i;
}
Control Rate
int notes = param_notes;
if (notes > param_length)
  notes = param_length;

int rests = param_length - notes;

outlet_chain = inlet_in - param_length;
if (rests) {
  if (notes < rests) {
    int mul = rests / notes;
    int rem = rests - (mul * notes);
    int ii = 0;
    int temp;

    for (int i = 0; i < notes; i += 1) {
      if (i < rem) {
        temp = ii;
        sequence[ii] = 1;
        for (ii = temp + 1; ii < temp + mul + 2; ii += 1)
          sequence[ii] = 0;
      } else {
        temp = ii;
        sequence[ii] = 1;
        for (ii = temp + 1; ii < temp + mul + 1; ii += 1)
          sequence[ii] = 0;
      }
    }
  } else if (notes > rests) {
    int mul = notes / rests;
    int rem = notes - (mul * rests);
    int ii = 0;
    int temp;

    for (int i = 0; i < rests; i += 1) {
      if (i < rem) {

        sequence[ii] = 1;
        ii += 1;
        sequence[ii] = 0;
        temp = ii;
        for (ii = temp + 1; ii < temp + mul + 1; ii += 1)
          sequence[ii] = 1;
      } else {
        sequence[ii] = 1;
        ii += 1;
        sequence[ii] = 0;
        temp = ii;
        for (ii = temp + 1; ii < temp + mul; ii += 1)
          sequence[ii] = 1;
      }
    }

  } else {
    sequence[0] = 1;
    for (int i = 1; i < param_length; i += 1)
      sequence[i] = !sequence[i - 1];
  }
} else {
  for (int ii = 0; ii < param_length; ii += 1)
    sequence[ii] = 1;
}

if (inlet_in >= 0 && inlet_in < param_length)
  outlet_out = sequence[inlet_in];
else
  outlet_out = inlet_default;

int num = 0;
for (int i = 0; i < param_length; i += 1)
  num += sequence[i] * powers[i];

outlet_enc = num;

Privacy

© 2024 Zrna Research