Search code examples
pythonarduinomidiableton-livemidi-instrument

How do I send MIDI data to my Arduino board from Ableton Live control surface script


I'm trying to send MIDI data from Ableton Live's Control Surface Script to my Arduino board.

Currently Arduino set up to log every MIDI / SysEx message received on every channel, that's all it's doing as of now. I can confirm it works correctly by using Live's External Instrument: I set External Instruments to send MIDI to Arduino board and it logs incoming events (tested with NoteOn, NoteOff, PitchBend).

But when it comes to Control Surface Script nothing is working. Here's what I tried:

# __init__.py

from .test import SendMidiTest

def create_instance(c_instance):
    return SendMidiTest(c_instance)
# SendMidiTest.py
# I'm trying to send NoteOn MIDI message every time I change track in Live

import Live
from _Framework.ControlSurface import ControlSurface

g_logger = None

def log(msg):
    global g_logger
   
    if g_logger is not None:
        g_logger(msg)

class SendMidiTest(ControlSurface):
    def __init__(self, *a, **k):
        super(SendMidiTest, self).__init__(*a, **k)
        self.song().view.add_selected_track_listener(self.handle_track_change)

    def handle_track_change(self):
        log('track changed')
        self._send_midi((144, 65, 112,))
        log('message should be sent')

I see both messages in Live's log but I don't have any incoming MIDI on my board (Arduino RX LED isn't blinking as well).

Here's the configuration of MIDI port:

enter image description here

What am I doing wrong? Any help appreciated.


Solution

  • Long story short: the issue was board hadn't been set as an output in the MIDI settings

    enter image description here