Skip to main content

Python RTP-MIDI / AppleMIDI driver

Project description

pymidi

A python RTP-MIDI / AppleMIDI implementation. You can use this library to build a network attached virtual MIDI device.

Build Status

Latest release: v0.2.1 (2018-09-16) (changelog)

Table of Contents

Quickstart

$ pip install pymidi

or

pipenv install pymidi

See Using in Another Project and the Developer Setup wiki for more information.

Developer Setup

Set up your workspace with the very excellent Pipenv:

$ pipenv install

Once installed, you'll probably find it useful to work in a pipenv shell, for ease of testing and running things:

$ pipenv shell
(pymidi-tFFCbXNj)
$ python pymidi/server.py

Running tests

Tests are run with nose; either of the following will work:

$ python setup.py test
$ nosetests

Developing against something else

If you're working on a project that uses pymidi and want to develop both concurrently, leverage the setuptools develop command:

$ cd ~/git/otherproject
$ pipenv shell
$ pushd ~/git/pymidi && python setup.py develop && popd

This creates a link to ~/git/pymidi within the environment of ~/git/otherproject.

Demo Server

The library includes a simple demo server which prints stuff.

$ python pymidi/server.py

See --help for usage.

Using in Another Project

Most likely you will want to embed a server in another project, and respond to MIDI commands in some application specific way. The demo serve is an example of what you need to do.

First, create a subclass of server.Handler to implement your policy:

from pymidi import server

class MyHandler(server.handler)
    def on_peer_connected(self, peer):
        print('Peer connected: {}'.format(peer))

    def on_peer_disconnected(self, peer):
        print('Peer disconnected: {}'.format(peer))

    def on_midi_commands(self, command_list):
        for command in command_list:
            if command.command == 'note_on':
                key = command.params.key
                velocity = command.params.velocity
                print('Someone hit the key {} with velocity {}'.format(key, velocity))

Then install it in a server and start serving:

server = new Server()
server.add_handler(MyHandler())
server.serve_forever()

See the Developer Setup wiki for ways to test with real devices.

Project Status

What works:

  • Exchange packet parsing
  • Timestamp sync packet parsing
  • Exchange & timestamp sync protocol support
  • MIDI message parsing

Not (yet) implemented:

  • Journal contents parsing
  • Verification of peers on the data channel
  • Auto-disconnect peers that stop synchronizing clocks

References and Reading

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pymidi-0.2.1.tar.gz (11.0 kB view details)

Uploaded Source

File details

Details for the file pymidi-0.2.1.tar.gz.

File metadata

  • Download URL: pymidi-0.2.1.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/2.7.15

File hashes

Hashes for pymidi-0.2.1.tar.gz
Algorithm Hash digest
SHA256 79bc6d8ebb115c67811326c7ea44a1e45d96068d77cf52af2325b27a5bb63078
MD5 cae9e13f4dd7724c4d931e0608109c0b
BLAKE2b-256 4585355da3c85f3ea44b74e9f9d71695184d99573964d8e63e2d68491351e712

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page