basearch

Pattern selector/finder for the "baseq" sequencer. Select base pattern to base the search on Select on which channel in the pattern you want to base your search on. Select how different the newly found pattern may be from your base-pattern. The controls: "next" searches for the next pattern that's similar enough to the base pattern. "new" copies the currently selected pattern to the base-pattern-value to start it's next search based on this new pattern. "rnd" chooses as random pattern as long as it's high. When low, goes back to the selected pattern.
Author: Remco van der Most
License: BSD
Github: sss/seq/basearch.axo

Inlets

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.

Outlets

int32.positive preset selection output

Parameters

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.

Attributes

objref should refer to the "baseq" sequencer module

Declaration
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;
Init
patt = 0;
ofs = 0;
j = 0;
get = 1;
pv = 0;
cnt = 0;
Control Rate
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;

Privacy

© 2024 Zrna Research