midimux 2

collects 3 midi-streams into one. each stream can be muted. buttons 'muteNoteOnOnly' set whether all messages of an input stream or muted or only note-ons.
Author: Robert Schirmer
License: BSD
Github: rbrt/poly/midimux 2.axo

Inlets

bool32.risingfalling mute1

bool32.risingfalling muteOnOnly1

bool32.risingfalling mute2

bool32.risingfalling muteOnOnly2

int32.positive note1

int32.positive velo1

int32.positive note2

int32.positive velo2

Outlets

int32.positive note

int32.positive velo

Declaration
uint8_t nin[2];
uint8_t vin[2];

uint8_t pren[2];
uint8_t prev[2];

uint8_t nstack[8] = {0};
uint8_t vstack[8] = {0};
uint8_t slength;
uint8_t swrite;
uint8_t sread;
uint8_t noteout;
uint8_t veloout;
Control Rate
if (!inlet_mute1) {
  nin[0] = inlet_note1;
  vin[0] = inlet_velo1;
} else if ((!inlet_velo1) && inlet_muteOnOnly1) {
  nin[0] = inlet_note1;
  vin[0] = 0;
}

if (!inlet_mute2) {
  nin[1] = inlet_note2;
  vin[1] = inlet_velo2;
} else if ((!inlet_velo1) && inlet_muteOnOnly2) {
  nin[1] = inlet_note2;
  vin[1] = 0;
}

int i;
for (i = 0; i < 2; i++) {
  if ((nin[i] != pren[i]) || (vin[i] != prev[i])) {
    nstack[swrite] = nin[i];
    vstack[swrite] = vin[i];
    pren[i] = nin[i];
    prev[i] = vin[i];
    slength++;
    swrite++;
    swrite = swrite % 8;
  }
}

if (slength) {
  noteout = nstack[sread];
  veloout = vstack[sread];
  sread++;
  sread = sread % 8;
  slength--;
}

outlet_note = noteout;
outlet_velo = veloout;

Privacy

© 2024 Zrna Research