Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: Multiple MIDI Serial Inputs?

  1. #1
    Junior Member
    Join Date
    Nov 2016
    Posts
    8

    Multiple MIDI Serial Inputs?

    Is it possible to use more than one MIDI serial input with the Teensy MIDI library? Has anyone done this? Particularly on Teensy 3.2 or 3.5.

    I use MIDI serial with callbacks from a keyboard, and it works great. Would like to add a second MIDI controller to my project. I tried using a separate MIDI combiner (merge), but latency is a problem at 31.25K baud.

    Thanks,
    Dave Erickson
    www.djerickson.com

  2. #2
    Senior Member
    Join Date
    Jan 2017
    Location
    Maastricht
    Posts
    169
    Yes, I did this with my sequencer, albeit with a Teensy 3.6 but that shouldn't matter.

    I declared two MIDI ports:
    Code:
    MIDI_CREATE_INSTANCE(HardwareSerial, Serial5, MIDI1);
    MIDI_CREATE_INSTANCE(HardwareSerial, Serial6, MIDI2);
    and made the handlers point to the same functions:
    Code:
      MIDI1.setHandleNoteOn(handleNoteOn);
      MIDI1.setHandleNoteOff(handleNoteOff);
      MIDI1.setHandleControlChange(handleControlChange);
      MIDI2.setHandleNoteOn(handleNoteOn);
      MIDI2.setHandleNoteOff(handleNoteOff);
      MIDI2.setHandleControlChange(handleControlChange);
      MIDI1.begin(MIDI_CHANNEL_OMNI);
      MIDI2.begin(MIDI_CHANNEL_OMNI);
    This works like a charm if one doesn't need to know which port the MIDI came from, i.e. if you just need to merge ports.

  3. #3
    Junior Member
    Join Date
    Nov 2016
    Posts
    8
    This is perfect, thanks! I like that you can use the same callback function for both ports, or not.
    Currently I use just:
    MIDI_CREATE_DEFAULT_INSTANCE();
    which creates object "MIDI" and defaults to the first serial port.

    Armed with your advice I dug into the MIDI library at:
    https://github.com/FortySevenEffects...o_midi_library
    Usage details are in the .h files, particularly the bottom of midi_Defs.h

    Thanks again,
    Dave
    www.djerickson.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •