bool32 when it goes high, searches for the next pattern that's similar to the base pattern
bool32 when it goes high, copies the current selected preset number to the base-preset control. The next search will look for sequences similar to this new pattern.
bool32 when this goes high, selects a random preset as long as input is high. When low, the output goes back to following the selected preset.
int32.positive preset selection output
int32 sets the base pattern on which the search for the next pattern is based
int32 sets the channel on which the similarity search is based (kick, basskick,toms,snare,etc)
int32 sets how similar the new pattern should be to the base pattern. Low values give high similarity
bool32.mom when it goes high, searches for the next pattern that's similar to the base pattern
bool32.mom when it goes high, copies the current selected preset number to the base-preset control. The next search will look for sequences similar to this new pattern.
objref should refer to the "baseq" sequencer module
int patt;
bool nxt;
int i;
int j;
int ofs;
int prv;
bool get = 0;
bool nw;
int pos;
bool pv;
int cnt;
bool rnd;
int RND;
patt = 0;
ofs = 0;
j = 0;
get = 1;
pv = 0;
cnt = 0;
int chn = param_channel * 96;
if ((inlet_rnd > 0) && !rnd) {
rnd = 1;
RND = (int32_t)(GenerateRandomNumber() % 2913);
} else if (inlet_rnd < 1) {
rnd = 0;
}
if (!(param_pattern == prv)) {
ofs = 0;
j = 0;
}
bool next = param_next || inlet_next;
bool NEW = param_new || inlet_new;
if ((NEW > 0) && !nw) {
PExParameterChange(&parent->PExch[PARAM_INDEX_attr_legal_name_pattern], pos,
0xFFFD);
nw = 1;
// get=0;
ofs = 0;
j = 0;
} else if (NEW < 1) {
nw = 0;
}
if ((next > 0) && !nxt) {
nxt = 1;
get = 0;
} else if (next < 1) {
nxt = 0;
}
int base = param_pattern;
cnt = 2;
while ((get == 0) && (cnt > 0)) {
j += 1;
j = j > 2999 ? 0 : j;
int sel = (j + base);
sel = sel > 2999 ? sel - 2999 : sel;
sel = sel * 768;
int go = param_difference;
int hi = 0;
for (i = 0; i < 96; i++) {
if (!((attr_seq.array[base * 768 + i + chn] > 0) ==
((attr_seq.array[sel + i + chn] > 0)))) {
go -= 1;
}
hi += attr_seq.array[sel + i + chn] > 0 ? 1 : 0;
}
if ((go > 0) && (hi > 0)) {
get = 1;
ofs = j;
}
cnt -= 1;
}
pos = param_pattern + ofs;
pos = pos > 2999 ? pos - 2999 : pos;
outlet_out = inlet_rnd > 0 ? RND : pos;
prv = param_pattern;