Arduino MIDI Library v4.0 is out !

The release v4.0 of the Arduino MIDI Library is now out !

You can find the changelog and download link here:
https://github.com/FortySevenEffects/arduino_midi_library/releases/tag/4.0

The documentation is available here:
http://arduinomidilib.fortyseveneffects.com

The Arduino Playground page has also been updated:
http://playground.arduino.cc/Main/MIDILibrary

  • mikeg

    Hi, I want to use MIDILibrary but I’m an arduino newbie. :)

    What is the basic arduino setup do I need to just use it with a computer?

  • Tyler

    Hey!

    Stoked about 4.0 release! I am curious how to use serial1 with the midi library 4.0. How can I do this?

    Tyler

    • Francois

      Hi Tyler,

      You can change the default serial port in midi_Settings.h, line 54.

      • Tyler

        Hey,

        Thank you for your response!
        Line 54 for MIDI.h says:

        inline void sendProgramChange(DataByte inProgramNumber,
        Channel inChannel);

        Tyler

        • Francois

          It’s in midi_Settings.h 😉

          Change
          #define MIDI_DEFAULT_SERIAL_PORT Serial
          to
          #define MIDI_DEFAULT_SERIAL_PORT Serial1

          • Tyler

            Doh, Midi settings my bad. Checked it out and found this, do they both need to be serial1. I apologize for being confused.

            // Set the default port to use for MIDI.
            #if MIDI_AUTO_INSTANCIATE
            # ifdef ARDUINO
            # ifdef USBCON
            # define MIDI_DEFAULT_SERIAL_PORT Serial1 // For Leonardo
            # else
            # define MIDI_DEFAULT_SERIAL_PORT Serial // For other Arduinos
            # endif

          • Francois

            The first #define is for the Arduino Leonardo board only, as its hardware serial port (UART) is Serial1 (Serial on Leonardo goes through USB). For other Arduino boards, the second #define determines which serial port is used.

  • Acasve

    Hi!
    I want to set my Arduino Mega 2560 to activate TX2 MIDI output, How I can do it?. I’ve tried putting MIDI_DEFAULT_SERIAL_PORT Serial2 but it does not work.
    I also used TX0 to monitor serial only.
    Thanks

    • Francois

      Hello,

      Normally what you did works, did you do the following?

      • Change line 54 of midi_Settings.h to:
        #define MIDI_DEFAULT_SERIAL_PORT Serial2
      • Use the default object:
        MIDI.begin(), MIDI.read()

      If so, can I have a look at your sketch?
      Thanks !

  • Acasve

    Hi Francois
    My setting is ..

    #if MIDI_AUTO_INSTANCIATE
    # ifdef ARDUINO
    # ifdef USBCON
    # define MIDI_DEFAULT_SERIAL_PORT Serial1 // For Leonardo
    # else
    # define MIDI_DEFAULT_SERIAL_PORT Serial2 // For other Arduinos
    # endif
    # define MIDI_DEFAULT_SERIAL_CLASS HardwareSerial
    # include "Arduino.h"
    # include "HardwareSerial.h"
    # else
    # error Auto-instanciation disabled. Use MIDI_CREATE_INSTANCE macro.
    # endif
    #endif

    A part of my sketch:

    #include <MIDI.h>

    int note1 = 60;
    int pin1 = 23;

    boolean active = false;

    void setup()
    {
    MIDI.begin();
    }

    void loop()
    {
    if (digitalRead(pin1) == HIGH && active)
    {
    active = false;
    MIDI.sendNoteOn(note1,127,1);
    }

    if (digitalRead(pin1)== LOW && !active)
    {
    active = true;
    MIDI.sendNoteOff(note1,127,1);
    }
    }

    • Francois

      Can you try the following please?

      #include <MIDI.h>
      MIDI_CREATE_INSTANCE(HardwareSerial, Serial2, midi2);

      setup()
      {
      midi2.begin();
      }

      loop()
      {
      midi2.read();
      midi2.sendNoteOn(60, 127, 1);
      }

      Thanks !

  • Acasve

    It’s ok now. Thanks for your help. I understand MIDI_CREATE_INSTANCE now.

  • http://rfweb.ru/ Alex Beep

    I want to switch from hairless usb-midi serial to usb midi cable driver. What i should change to send commands to midi jack? wiring is not a problem, but i cant find out how to initialize instance with hardware ports? Arduino uno

    • http://fortyseveneffects.com fortysevenfx

      Hi Alex,

      On Uno, the same pins (RX & TX) are used for both hardware & USB serial communication, as the ATmega328P does not have native USB capabilities. I believe Hairless uses a different baudrate, so for plain hardware MIDI using DIN plugs, change the baudrate back to 31250.