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

Thread: Arduino MIDI Library 4.2 - 2 x 2 Midi Interface thru / merge

  1. #1
    Senior Member adrian's Avatar
    Join Date
    Oct 2015
    Location
    Wellington, NZ
    Posts
    504

    Arduino MIDI Library 4.2 - 2 x 2 Midi Interface thru / merge

    Hello

    I was wondering how to use the Midi Library with 2 separate serial interfaces on teensy 3.2, and it turns out that the Arduino MIDI Library 4.2 is all set up for that! So I downloaded it and put it in the teensy AVR library folder, and tried out one of the examples:
    Code:
    #include <MIDI.h>
    
    // This example shows how to create two instances of the library to create a merger.
    // There are two MIDI couples of IO, A and B, each using thru and merging with the
    // input from the other node. The result is the following:
    // A out = A in + B in
    // B out = B in + A in
    
    MIDI_CREATE_INSTANCE(HardwareSerial, Serial1,     midiA);
    MIDI_CREATE_INSTANCE(HardwareSerial, Serial2,     midiB);
    
    void setup()
    
    {
      // Initiate MIDI communications, listen to all channels
      midiA.begin(MIDI_CHANNEL_OMNI);
      midiB.begin(MIDI_CHANNEL_OMNI);
    }
    
    void loop()
    {
      if (midiA.read())
      {
        // Thru on A has already pushed the input message to out A.
        // Forward the message to out B as well.
        midiB.send(midiA.getType(),
                   midiA.getData1(),
                   midiA.getData2(),
                   midiA.getChannel());
      }
    
      if (midiB.read())
      {
        // Thru on B has already pushed the input message to out B.
        // Forward the message to out A as well.
        midiA.send(midiB.getType(),
                   midiB.getData1(),
                   midiB.getData2(),
                   midiB.getChannel());
      }
    }
    It compiled!

    Unfortunately, I don't have my teensy midi hardware setup running right at the moment (there are not enough hours in the day), but I'm putting it back together for a project, so I'm not going to futz around with other serial solutions ... So, untested, but interesting !

    The 4.2 library is different from the 3.2 library I have been using in that under 4.2 you have to use a macro to institute an instance, and it would appear that midi mirroring / thru is turned on by default (what appears at the RX is mirrored out of the TX.... ) but I am yet to confirm that for real.

    Apologies if this is all old news.
    Last edited by adrian; 01-13-2016 at 01:32 AM.

  2. #2
    Junior Member
    Join Date
    Aug 2017
    Posts
    8
    i am also interested on this project. i would like to if you have any advance on it.
    cheers

  3. #3
    Senior Member adrian's Avatar
    Join Date
    Oct 2015
    Location
    Wellington, NZ
    Posts
    504
    Have a look at posts 14 to 16 in this thread: https://forum.pjrc.com/threads/34697...-in-usb_midi-h

  4. #4
    Junior Member
    Join Date
    Aug 2017
    Posts
    8
    Quote Originally Posted by adrian View Post
    Have a look at posts 14 to 16 in this thread: https://forum.pjrc.com/threads/34697...-in-usb_midi-h
    thank you Adrian, hope to be join this challenge soon too.

Posting Permissions

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