Skip to content

Miselu/simplecoremidi

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple CoreMIDI for Python

Simple CoreMIDI for Python is the simplest way of using MIDI in Python on Mac OS X. Period.

Installation

pip install simplecoremidi

Usage

To send midi out from your application::

from simplecoremidi import send_midi
send_midi((0x90, 0x3c, 0x40))

This sends a MIDI Note On signal. To receive it you'll have to configure your DAW or software to receive from the "simple core midi source" MIDI source.

To receive midi from another application::

from simplecoremidi import recv_midi
data = recv_midi()

This returns all the midi data sent to the "simple core midi destination" MIDI destination since your last call. Put it inside a loop and poll it.

Look at the example in the simplecoremidi/examples directory.

To create an Output that will send to a Destination device::

from simplecoremidi import MIDIOutput
out = MIDIOutput("Numark ORBIT")
out.send([0x90, 60, 127])

To create an Input that can read from a Source device::

from simplecoremidi import MIDIInput
in = MIDIInput("Numark ORBIT")
data = in.recv()

As before, this returns all the midi data read from the Source since your last call. The format of the result is a tuple.

(144, 40, 127, 128, 41, 0, 144, 41, 127)

To enumerate Inputs:: from simplecoremidi import MIDIInput print MIDIInput.enumerate()

The result will be a tuple of names.

('Bus 1', 'IAC Bus 2', 'Python MIDI', 'Session 3' )

Likewise, simplecoremidi.MIDIOutput.enumerate() will return a tuple containing names of available MIDIOutputs.

Notes

  • It only works on Macs. It will never work on Windows or Linux.
  • It is not configurable.

HISTORY

  • cloned from https://github.com/sixohsix/simplecoremidi
  • sheffler added MidiInput, MIDIOutput
  • added example interfacing with Numark ORBIT controller
  • tymm merged with changes to sixohsix tree (python3 support, etc)
  • removed sheffler's list-of-tuples format of received data
  • added error handling code & raise exceptions instead of segfaulting in asst. cases
  • added ability to enumerate MIDI inputs & outputs

Packages

No packages published

Languages

  • C 68.6%
  • Python 31.4%