Jump to content
43oh

[Energia Library] MIDI library 4.1 is working on Tiva/Stellaris Launchpads (with a little hands on)


Recommended Posts

Hello,

I tried out basic functionality with the arduino MIDI library 4.1 on TIVA Launchpad TM4C123G (all others should work also)

Download Link: https://github.com/FortySevenEffects/arduino_midi_library/

 

The only thing to do is to setup the serial interface, you can simply do that with insert following line into midi_Settings.h:

 

#define MIDI_DEFAULT_SERIAL_PORT     Serial1 

 

"Serial1" defines  PC_4 = RX(1) input on tiva, PC_5 = TX(1) output on tiva, so you should choose every serial port you want (untested).

my patched midi_Settings.h is included as attachement

I´ve tested successfully it with my self build midi interface, sending some random notes from my computer.

 

Here is a basic test code example - it reads midi input notes on channel1 and print it out on the serial monitor (+ led flashing)

#include <MIDI.h>

#define LED RED_LED  // LED pin on Tiva Launchpad TM4C123G

void HandleNoteOn(byte channel, byte pitch, byte velocity)
{
    // Do whatever you want when you receive a Note On.
  
    if (velocity == 0)
    {
      digitalWrite(LED,LOW);
        // This acts like a NoteOff.
    }
    else
    {
    digitalWrite(LED,HIGH);
    }
    Serial.print("Note ON: Channel: ");
    Serial.print(channel);
    Serial.print(" Key: ");
    Serial.print(pitch);
    Serial.print(" Velocity: ");
    Serial.println (velocity);
    // Try to keep your callbacks short (no delays ect) 
    // otherwise it would slow down the loop() and have a bad impact 
    // on real-time performance.
}


void HandleNoteOff(byte channel, byte pitch, byte velocity)
{
 digitalWrite(LED,LOW);
   Serial.print("Note OFF: Channel: ");
    Serial.print(channel);
    Serial.print(" Key: ");
    Serial.print(pitch);
    Serial.print(" Velocity: ");
    Serial.println (velocity);
}
void setup()
{
    pinMode(LED, OUTPUT);
    MIDI.begin(1);          // Launch MIDI and listen to channel 1
    MIDI.setHandleNoteOn(HandleNoteOn); 
    MIDI.setHandleNoteOff(HandleNoteOff); 
    Serial.begin(9600); // Energia serial monitor to see events
}

void loop()
{
  MIDI.read(); // nothing more to do here 

}

Be carful! the "serial.print" lines are only for testing and not recommended within the setHandleNoteOn/Off handler!

 

Hey admin: please let us attach *.ino files! (You aren't permitted to upload this kind of file)

 

regards

Matthias

midi_Settings.h

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...