Ableton MIDI

Hey!

I am pretty new to Arduino and I am trying to work on a project that uses MIDI from Ableton. The end goal is to have it so that Track #1 on Ableton sends MIDI notes (C3-C4 white keys only) and these notes translate into a true/false statement output. For example, note C3 would be pin #30 on the Arduino Mega. When C3 is played in Ableton, pin #30 turns on, else the pin is inactive.

I am currently using Hairless MIDI and loopMIDI, which seem to recognize there is a MIDI output from Ableton, but I can not figure out how to turn these values into a true-false statement for Arduino outputs. I have looked through many tutorials, but all I can find is DIY MIDI controllers, where an analog button pressed on an Arduino plays a note in Ableton. I have included pictures of how my computer is set up, as well as a .txt file with the code I have currently. Any help or tutorials would be very much appreciated.

Happy Thanksgiving!!!

-Mike

1.PNG

3.PNG

1.PNG

3.PNG

Code.txt (546 Bytes)

Lots of people have successfully read information from MIDI and acted on it. A search on “Arduino read MIDI” will find plenty or https://forum.arduino.cc/index.php?topic=84029.0 is one discussion from years ago.

Steve

but I can not figure out how to turn these values into a true-false statement for Arduino outputs.

When the Arduino receives the midi message it tests the note number for an expected value and sets a logic variable accordingly. So note on sets the logic variable high and a note off sets the variable to low.

You do not get Ableton to do this because it has no idea about pins, it only knows about midi messages.

I don’t see you sending anything from Ableton, you should use an external instrument directed to hairless to do that.

You don’t say after that what you want to do with this value.

You could use the Control Surface library I maintain to do this with just a couple of lines of code. See the Getting Started example, it does almost exactly what you’re after.
Also have a look at the Note LED example.

In your specific case, the code would look something like this:

#include <Control_Surface.h> // Include the library

// Instantiate a MIDI Interface to use with Hairless at 115200 baud
HairlessMIDI_Interface midi;

using namespace MIDI_Notes;

// Create an array of NoteValueLED objects that listen for incoming 
// MIDI Note messages and turn on/off the LEDs accordingly
NoteValueLED leds[] = {
  {30, note(C, 3)}, // LED pin, MIDI note number
  {31, note(D, 3)},
  {32, note(E, 3)},
  {33, note(F, 3)},
  {34, note(G, 3)},
  {35, note(A, 3)},
  {36, note(B, 3)},
  {37, note(C, 4)},
};

void setup() {
  // Set up pin modes for the LEDs, initialize the MIDI interface etc.
  Control_Surface.begin();
}

void loop() {
  // Continuously listen for incoming MIDI messages and update the LEDs accordingly
  Control_Surface.loop();
}

Pieter

Hope you’ve been able to sort this out? I saw this post last week when I was trying to figure some things out - seems we’re doing something similar with Ableton and Hairless MIDI.

Here’s what I ended up with on my Uno R3.

#include <MIDI.h>
MIDI_CREATE_DEFAULT_INSTANCE();
//**** BANK ONE ****
#define iciclePin 6
#define treeBGPin 2
#define treeRYPin 4
#define treeControlPin 5
//**** BANK TWO ****
#define colour1Pin 9
#define starPin 10
#define nativityPin 11

int note=0;
int velo=0;
int chan=0;

//---------------------------------------------------------------------------
void lightOn(byte channel, byte pitch, byte velocity)
{
  note=(int) pitch;
  velo=(int) velocity *2;
  chan=(int) channel;
  if(note == 24){
    analogWrite(iciclePin, velo);
  }
  else if(note == 27){
    analogWrite(colour1Pin, velo);
  }
  else if(note == 34){
    analogWrite(starPin, velo);
  }
  else if(note == 35){
    analogWrite(nativityPin, velo);
  }
  else if(note == 36){
    digitalWrite(treeBGPin, HIGH);
    digitalWrite(treeRYPin, LOW);
    analogWrite(treeControlPin, velo);
  }
  else if(note == 37){
    digitalWrite(treeBGPin, LOW);
    digitalWrite(treeRYPin, HIGH);
    analogWrite(treeControlPin, velo);
  }
}

void lightOff(byte channel, byte pitch, byte velocity)
{
  note =(int) pitch;
  velo =(int) velocity;
  if(note == 24){
    digitalWrite(iciclePin, LOW);
  }
  else if(note == 27){
    digitalWrite(colour1Pin, LOW);
  }
  else if(note == 34){
    digitalWrite(starPin, LOW);
  }
  else if(note == 35){
    digitalWrite(nativityPin, LOW);
  }
  else if(note == 36){
    digitalWrite(treeRYPin, LOW);
    digitalWrite(treeControlPin, LOW);
  }
  else if(note == 37){
    digitalWrite(treeBGPin, LOW);
    digitalWrite(treeControlPin, LOW);
  }
}

//---------------------------------------------------------------------------

void setup() {
  //****BANK ONE****
  pinMode(iciclePin, OUTPUT);
  pinMode(treeRYPin, OUTPUT);
  pinMode(treeBGPin, OUTPUT);
  pinMode(treeControlPin, OUTPUT);
  digitalWrite(treeRYPin, LOW);
  digitalWrite(treeBGPin, LOW);
  //****BANK TWO****
  pinMode(colour1Pin, OUTPUT);
  pinMode(starPin, OUTPUT);
  pinMode(nativityPin, OUTPUT);
  MIDI.begin(MIDI_CHANNEL_OMNI);
  MIDI.setHandleNoteOn(lightOn);
  MIDI.setHandleNoteOff(lightOff);
  Serial.begin(115200); //COM5 linked to Hairless MIDI ***REMEMBER THIS MUST FOLLOW MIDI.begin()*** (Don't know why)
}

void loop() {
  MIDI.read();
}

The best method I found was using Callbacks in MIDI Library - Arduino Reference - there is an example code on using callbacks under File => Examples => MIDI in the Arduino IDE when you install the MIDI Library, and some pretty good documentation online.