Giter Site home page Giter Site logo

python-midi-ableton's Introduction

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.