midithru

an object to forward midi from one device to another note: does not handle sysex or clock
Author: Mark Harris
License: GPL
Github: tb/midi/utils/midithru.axo

Inlets

None

Outlets

None

Attributes

combo input

combo output

combo led

Declaration
int flash_cnt = 0;
bool flash_state = false;
const int FLASH_LEN = 0x100;
Init
if (attr_led) {
  sysmon_disable_blinker();
  palSetPadMode(LED2_PORT, LED2_PIN, PAL_MODE_OUTPUT_PUSHPULL);
}
flash_cnt = 0;
flash_state = false;
Control Rate
if (attr_led) {
  if (flash_cnt > 0)
    flash_cnt--;
  bool fs = flash_cnt > 0;
  if (fs != flash_state) {
    palWritePad(LED2_PORT, LED2_PIN, fs);
    flash_state = fs;
  }
}
Midi Handler
if (attr_input) {
  uint8_t status_type = status & 0xF0;
  if ((status_type == MIDI_CONTROL_CHANGE) || (status_type == MIDI_NOTE_OFF) ||
      (status_type == MIDI_NOTE_ON) || (status_type == MIDI_POLY_PRESSURE) ||
      (status_type == MIDI_PITCH_BEND)) {
    MidiSend3((midi_device_t)attr_output, status, data1, data2);
    flash_cnt = FLASH_LEN;
  } else if ((status_type == MIDI_PROGRAM_CHANGE) ||
             (status_type == MIDI_CHANNEL_PRESSURE)) {
    MidiSend2((midi_device_t)attr_output, status, data1);
    flash_cnt = FLASH_LEN;
  }
}

Privacy

© 2024 Zrna Research