PolyCount

random measure generator Set the maximum 'bar'-count with the "total" parameter. min sets the minimum amount of counts per measure max sets the maximum amount of counts per mearuse press random to re-randomise the measures quant quantizes the measure length to whole steps in power of 2,so 8ths->4ths->2s Inputs: TRIGGER: multiple ways: -connect the trigger input to a tempo-synced LFO which gets it's rate multiplied with the max-output of this module. this way measures always take the same time, but you have fills at different rates->polyrhythmic measures: 1/1,2/2,3/3,4/4,5/5 -just connect a LFO to the trigger, this will create measures of different time-length: 1/1,2/1,3/1,4/1 R: r resets the internal count back to zero, useful if its running allongside other sequencers and needs to be reset at the same positions. RND: rnd randomises the whole set of beats-per-measure. OUTPUTS: count: outputs the count-per measure/stage (drive some pattern generator with this) max: outputs the maximum count for the measure/stage (for if pattern generator asks for a maximum count-input) stage: outputs which stage the counter is in (useful for adding variations per measure/stage) c: outputs a trigger when the total-count restarts at 0. normal: outputs the normal total-count normax: outputs the maximum of the total-count (for same use as max output)
Author: Remco van der Most
License: BSD
Github: sss/logic/PolyCount.axo

Inlets

bool32.rising trigger

bool32.rising reset

bool32.rising rnd

Outlets

int32 count

int32 max

int32 stage

int32 stages

int32 normal

int32 normax

bool32.pulse nxt

bool32.pulse carry pulse

Parameters

int32 total

int32 min

int32 max

int32 quant

bool32.mom rnd

Declaration
int ntrig;
int rtrig;
int count;

int32_t max[64];
int i;
int stage;
int k;
int strig;
int32_t random;
int RND;
int32_t MAX;
int pk;
Init
count = 0;
ntrig = 0;
rtrig = 0;
// max[0]== (int32_t)(GenerateRandomNumber()% 8)+1;
// for(i=1;i<64;i++){
//	max[i] = (int32_t)(GenerateRandomNumber()% 8)+1+max[i-1];

//	}

RND = 1;
Control Rate
int32_t width = param_max - param_min + 1;
outlet_c = 0;
if ((inlet_trig > 0) && !ntrig) {
  count += 1;
  if (count >= param_total) {
    count = 0;
    outlet_c = 1;
    stage = 0;
    MAX = max[0];
  }
  ntrig = 1;
} else if (!(inlet_trig > 0))
  ntrig = 0;
if ((inlet_r > 0) && !rtrig) {
  count = 0;
  rtrig = 1;
} else if (!(inlet_r > 0))
  rtrig = 0;

int rnd = inlet_rnd + param_rnd + RND;
if ((rnd > 0) && !strig) {
  RND = 0;
  max[0] = (int32_t)(GenerateRandomNumber());
  max[0] = max[0] - max[0] / width * width;
  max[0] = max[0] < 0 ? max[0] + width : max[0];
  max[0] = ((((max[0] + param_min) / param_quant) * param_quant));
  for (i = 1; i < 64; i++) {
    max[i] = (int32_t)(GenerateRandomNumber());
    max[i] = max[i] - max[i] / width * width;
    max[i] = max[i] < 0 ? max[i] + width : max[i];
    max[i] =
        ((((max[i] + param_min) / param_quant) * param_quant)) + max[i - 1];
  }
  strig = 1;
} else if (!(rnd > 0)) {
  strig = 0;
}

int32_t Stages;
stage = 0;
k = 0;
for (i = 0; i < 64; i++) {
  if (param_total > max[i]) {
    Stages = i + 1;
  }
}
outlet_stages = Stages;

stage = 0;
k = 0;
for (i = 0; i < 64; i++) {
  if (count >= max[i]) {

    stage = max[i];
    k = i;
  }
}
outlet_count = count - stage;
if (!(k == pk)) {
  MAX = (max[k + 1] - max[k]) > (param_total - count) ? (param_total - count)
                                                      : (max[k + 1] - max[k]);
}
if (count == 0) {
  MAX = max[0];
}

outlet_max = MAX;
outlet_stage = k;
outlet_nxt = (!(k == pk));
outlet_normal = count;
outlet_normax = param_total;
pk = k;

Privacy

© 2024 Zrna Research