scalebankLIVE

Live note scaler. Works together with the scaleLIVE module (don't forget to enter the name of this object into the object reference of the scaleLIVE module!)
Author: Remco van der Most
License: BSD
Github: sss/harmony/scalebankLIVE.axo

Inlets

bool32 when high, adds the note-input to the scale (only semitones, octaves are removed). When delete is also high, removes the note-input from the scale

bool32 next gate (add) after triggering clear, restarts a new scale starting with the new note.

bool32 when high, deletes the played note from the scale

int32 set semitone note-value to add/delete to/from the scale

int32 sets how many notes may be added AND played. When 7 notes are added, lowering this control won't allow the last played notes to be used->note priority->first played, last gone

Outlets

None

Parameters

bin12 scale

Displays

int32.label notes

Declaration
int array[12];
int i;
int notes;
bool trg;
bool clr;
int def;
bool rst;
bool D;
int NT;
Init
for (i = 0; i < 12; i++) {
  array[i] = 0;
}

notes = 0;
D = 1;
Control Rate
NT = inlet_notes > 0 ? inlet_notes : 1;
if (D) {
  D = 0;
  PExParameterChange(&parent->PExch[PARAM_INDEX_attr_legal_name_scale],
                     (1 << 12) - 1, 0xFFFD);
  notes = 0;
}
if ((inlet_clear > 0) && !clr) {
  clr = 1;
  rst = 1;
} else if (inlet_clear < 1) {
  clr = 0;
}

if ((inlet_gate > 0) && !trg) {
  trg = 1;
  if (rst > 0) {
    rst = 0;
    for (i = 0; i < 12; i++) {
      array[i] = 0;
      notes = 0;
    }
  }
  if ((notes < inlet_notes) || ((inlet_delete > 0) && (notes > 0))) {
    int sel = inlet_note - inlet_note / 12 * 12;
    sel += sel < 0 ? 12 : 0;
    if (inlet_delete > 0) {
      if (array[sel] > 0) {
        notes -= 1;
        array[sel] = 0;
      }
    } else if ((inlet_delete == 0) && (array[sel] == 0)) {
      notes += 1;
      array[sel] = notes;
    }
  }

  int32_t tmp = 0;
  for (i = 0; i < 12; i++) {
    tmp += ((array[i] > 0) ? 1 : 0) << i;
  }
  PExParameterChange(&parent->PExch[PARAM_INDEX_attr_legal_name_scale], tmp,
                     0xFFFD);

} else if (inlet_gate < 1) {
  trg = 0;
}
disp_notes = notes;

Privacy

© 2024 Zrna Research