Go Down

Topic: splitting polyphony with midi (Read 611 times) previous topic - next topic

LOOKmumnoarduino

hello!
Something is telling me its not feasible. but I thought i should bounce this problem i have around to see if anyone has any ideas of how it could be achieved.

It's quite a specific issue. So i've struggled to find much on it.

basically The problem i am trying to solve is :-

1 midi input. ie a keyboard playing,,,,,    the output is 6 midi outputs (same channels just different outputs) with the polyphony split. so all outputs are polyphonic but the polyphony is spread onto the 6 channels.   the method is used a lot in analog synths to control seperate synth voices, however its quite important it sends out midi annoyingly!

initially i didn't think was possible as there are not enough Tx pins, not even on a teensy.  So im hoping im overlooking something!

Or better still! someone has already done this?

thanks a lot!

pjrc

You do get 6 transmit pins on Teensy 3.5 and 3.6.  :)

On 3.6 you also get high speed USB host.  So in theory you could connect USB hubs and USB-serial cables (and use the USBHost_t36 library), to get a *lot* more serial ports!

PieterP

#2
Aug 03, 2018, 02:06 pm Last Edit: Aug 03, 2018, 02:17 pm by PieterP
You can easily multiplex the TX pin.

The code is rather trivial:
Code:
template <uint8_t N> int8_t find(int8_t target, int8_t (&notes)[N]) {
  for (uint8_t i = 0; i < N; i++)
    if (notes[i] == target)
      return i;
  return -1;
}

void loop() {
  static int8_t playingNotes[] = { -1, -1, -1, -1, -1, -1}; // Six outputs
  if (/* MIDI message received */) {
    MIDI_message_t midimsg = /* Get MIDI message from MIDI library */;
    if (midimsg.channel != 1) // only listen to channel 1
      return;
    if (midimsg.type == NOTE_OFF || (midimsg.type == NOTE_ON && midimsg.data2 == 0)) {
      // Note Off
      int8_t index = find(midimsg.data1, playingNotes);
      if (index < 0) // this note is not playing
        return;
      playingNotes[index] = -1;
      /* Set mux address to index */
      /* Send midimsg */
      /* Flush MIDI interface */
    } else if (midimsg.type == NOTE_ON) {
      // Note On
      int8_t index = find(-1, playingNotes);
      if (index < 0) // no more free outputs
        return;
      playingNotes[index] = midimsg.data1;
      /* Set mux address to index */
      /* Send midimsg */
      /* Flush MIDI interface */
    } else if (midimsg.type == CONTROL_CHANGE && midimsg.data1 == 0x7B) {
      // All Notes Off
      for (uint8_t i = 0; i < sizeof(playingNotes) / sizeof(playingNotes[0]); i++) {
        playingNotes[i] = -1;
        /* Set mux address to i */
        /* Send midimsg */
        /* Flush MIDI interface */
      }
    }
  }
}

Go Up