Skip to content

A tutorial/guide on how to send midi signals from python to Ableton live, as resources on the internet about this are sparse and cryptic

Notifications You must be signed in to change notification settings

AhmadMoussa/Python-Midi-Ableton

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 

Repository files navigation

Python-Midi-Ableton

A tutorial on how to send midi signals from a python script to a midi track in ableton live

What you'll need:

Why is this relevant:

  • Because I couldn't find any resources on how to send Midi Notes from a Python script to Ableton for windows
  • You want to send Midi Signals from Python to Ableton Live on a Windows pc

What are we actually going to do:

  1. We can't communicate directly between ableton live and python
  2. We need to create a virtual port to which we can send midi signals from python and to which ableton will be "listening" to
  3. We need to write a script that send midi signals, for that purpose we will use the python-rtmidi package
  4. We need to setup ableton to listen to the port

What you'll have to do:

  1. Install python and the python rt-midi package like this
  2. Install the loopMidi software, once you launch it you should see something like this: like this
  3. Now press the little plus button in the bottom-left corner: like this You'll see that it'll add an item to list. Voila, we created a new port.
  4. Now let's write the python script that'll send some notes to the port:
import time
import rtmidi

midiout = rtmidi.MidiOut()
available_ports = midiout.get_ports()

# here we're printing the ports to check that we see the one that loopMidi created. 
# In the list we should see a port called "loopMIDI port".
print(available_ports)

# Attempt to open the port
if available_ports:
    midiout.open_port(1)
else:
    midiout.open_virtual_port("My virtual output")

note_on = [0x90, 60, 112]
note_off = [0x80, 60, 0]
midiout.send_message(note_on)
time.sleep(0.5) 
# I tried running the script without having to invoke the sleep function but it doesn't work. 
# If someone could enlighten me as to why this is, I'd be more than grateful.
midiout.send_message(note_off)

del midiout

Here we're simply sending a middle C note as MIDI to the port. Save this in a .py file, we'll need to run it later.

  1. Now let's set up Ableton:

    • Go to Preferences -> MIDI link where you should see the loopMidi port as an input and output port. Set the loopMidi port's track and sync to "On" like this
    • Create a new Midi track in your project Create a new midi track in your project
    • Set the input of the track to be the "loopMidi Port" and set the track to "In"
    • Also don't forget to load the track with a synth. An ableton stock sound should also do the trick.
  2. Run the script python "scriptname".py in your command prompt, and you should be able to hear ableton play back a C note at you.

I hope this helped, if anything is unclear or you have suggestions let me know.

About

A tutorial/guide on how to send midi signals from python to Ableton live, as resources on the internet about this are sparse and cryptic

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published