Comprehensive MIDI 1.0 and 2.0 constant definitions for Python.
Project description
PyMidiDefs
Comprehensive MIDI 1.0 and 2.0 constant definitions for Python.
A zero-dependency reference library providing named constants, lookup dictionaries, and utility functions for the MIDI specification. Covers note numbers, Control Change assignments, General MIDI instruments and percussion, status bytes, Standard MIDI File meta-events, MIDI 2.0 Universal MIDI Packet (UMP) message types, and MIDI-CI capability inquiry constants.
Why PyMidiDefs?
If you're building a Python synthesiser, sequencer, DAW, MIDI controller interface, music generator, or any application that sends or receives MIDI messages, you need the same set of protocol constants: note numbers, CC assignments, program change values, status bytes. These numbers are defined by the MIDI specification and never change, yet most projects end up re-defining them from scratch or copying them from unreliable sources.
PyMidiDefs gives you a single, authoritative package with every constant sourced directly from the official MIDI specifications. It has no runtime dependencies and works with any MIDI library or framework -- python-rtmidi, mido, pygame.midi, or your own socket-level implementation.
About MIDI
MIDI (Musical Instrument Digital Interface) is a technical standard for communication between electronic musical instruments, computers, and audio devices. It was conceived in the early 1980s by Dave Smith of Sequential Circuits and Ikutaro Kakehashi of Roland, who proposed a Universal Synthesizer Interface to allow instruments from different manufacturers to talk to each other. The MIDI 1.0 Detailed Specification was published in August 1983 by the International MIDI Association (now the MIDI Manufacturers Association, MMA) and has remained backwards-compatible ever since.
General MIDI (GM), standardised in 1991, defined a common set of 128 instrument sounds and a percussion key map so that a MIDI file created on one device would sound broadly similar on another. The Standard MIDI File (SMF) format, also formalised in the early 1990s, became the universal way to store and exchange MIDI sequences.
In January 2020, the MIDI Association announced MIDI 2.0 -- the first major update to the protocol in nearly four decades. MIDI 2.0 introduces the Universal MIDI Packet (UMP) format with higher-resolution velocity and controller values, per-note controllers, and bidirectional communication via MIDI-CI (Capability Inquiry) for automatic device configuration, profile negotiation, and property exchange. MIDI 2.0 is a strict superset of MIDI 1.0; all existing MIDI 1.0 definitions remain valid.
Installation
pip install git+https://github.com/simonholliday/PyMidiDefs.git
Modules
| Module | Description |
|---|---|
pymididefs.notes |
MIDI note numbers (C-1 to G9) and name/number conversion |
pymididefs.cc |
Control Change number assignments (0-127), plus 14-bit pack/unpack helpers |
pymididefs.rpn |
Standard Registered Parameter Numbers (RPN) and the 14-bit parameter conventions shared with NRPN |
pymididefs.drums |
General MIDI Level 1 percussion key map |
pymididefs.gm |
General MIDI Level 1 instrument program numbers and families |
pymididefs.status |
MIDI 1.0 status bytes (channel voice, system common, system real-time) |
pymididefs.meta |
Standard MIDI File meta-event type bytes |
pymididefs.ump |
MIDI 2.0 Universal MIDI Packet message types and constants |
pymididefs.ci |
MIDI 2.0 Capability Inquiry (MIDI-CI) constants |
Usage
import pymididefs.notes
import pymididefs.cc
import pymididefs.drums
import pymididefs.gm
# Note constants
pymididefs.notes.C4 # 60 (Middle C)
pymididefs.notes.A4 # 69 (Concert pitch)
# Note name conversion
pymididefs.notes.note_to_name(60) # "C4"
pymididefs.notes.name_to_note("Db4") # 61
# Control Change numbers
pymididefs.cc.SUSTAIN_PEDAL # 64
pymididefs.cc.FILTER_CUTOFF # 74
pymididefs.cc.CC_MAP["pan"] # 10
# GM percussion
pymididefs.drums.KICK_1 # 36
pymididefs.drums.HI_HAT_CLOSED # 42
pymididefs.drums.GM_DRUM_MAP["snare_1"] # 38
pymididefs.drums.KICK # 36 (unnumbered "primary" alias of KICK_1)
pymididefs.drums.GM_DRUM_PRIMARY_ALIASES["crash"] # 49
# GM instruments
pymididefs.gm.ACOUSTIC_GRAND_PIANO # 0
pymididefs.gm.VIOLIN # 40
pymididefs.gm.GM_INSTRUMENT_NAMES[40] # "Violin"
pymididefs.gm.GM_INSTRUMENT_MAP["flute"] # 73
RPN and 14-bit values
import pymididefs.rpn
import pymididefs.cc
# Standard Registered Parameter Numbers
pymididefs.rpn.PITCH_BEND_SENSITIVITY # 0
pymididefs.rpn.MODULATION_DEPTH_RANGE # 5 (added in GM2)
pymididefs.rpn.NULL_PARAMETER # 16383 (sent as MSB=127, LSB=127)
# 14-bit pack/unpack — works for any MIDI 1.0 14-bit value
# (Bank Select, Data Entry, RPN/NRPN parameter numbers, pitch bend, ...)
pymididefs.cc.pack_14bit(8192) # (64, 0) pitch bend centre
pymididefs.cc.unpack_14bit(64, 0) # 8192
MIDI 2.0
import pymididefs.ump
import pymididefs.ci
# Universal MIDI Packet message types
pymididefs.ump.MIDI2_CHANNEL_VOICE # 0x4
pymididefs.ump.NOTE_ON # 0x9
pymididefs.ump.PROTOCOL_MIDI2 # 0x02
# MIDI-CI
pymididefs.ci.DISCOVERY # 0x70
pymididefs.ci.PROFILE_INQUIRY # 0x20
Sources
All definitions are sourced from the official MIDI specifications published by the MIDI Association:
- MIDI 1.0 Detailed Specification (MMA/AMEI)
- General MIDI Level 1 Specification
- General MIDI 2 Specification
- Standard MIDI File 1.0 Specification
- M2-104-UM v1.1 — Universal MIDI Packet (UMP) Format and MIDI 2.0 Protocol Specification
- M2-101-UM v1.2 — MIDI-CI Specification
Some specifications require a free MIDI Association membership to download.
License
MIT -- you are free to use, copy, modify, merge, publish, distribute, sublicense, and sell copies of this software in any project, including commercial and closed-source applications. The only requirement is that you include the LICENSE file when redistributing the software. See LICENSE for the full text.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pymididefs-0.2.5.tar.gz.
File metadata
- Download URL: pymididefs-0.2.5.tar.gz
- Upload date:
- Size: 31.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a1643f398267a1fca2a9e6b290270add607b5571dca0237850e24fd5b6b766be
|
|
| MD5 |
84f30aae99e5755ad45ebece3a1af4a0
|
|
| BLAKE2b-256 |
638a0bee8571492a8d1d493fe6bdbceb0dd23ec90d353d1a502d41415c442aa0
|
Provenance
The following attestation bundles were made for pymididefs-0.2.5.tar.gz:
Publisher:
publish.yml on simonholliday/PyMidiDefs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pymididefs-0.2.5.tar.gz -
Subject digest:
a1643f398267a1fca2a9e6b290270add607b5571dca0237850e24fd5b6b766be - Sigstore transparency entry: 2199221080
- Sigstore integration time:
-
Permalink:
simonholliday/PyMidiDefs@aa6aab9edf28414db654330ec80a6401885d789b -
Branch / Tag:
refs/tags/v0.2.5 - Owner: https://github.com/simonholliday
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@aa6aab9edf28414db654330ec80a6401885d789b -
Trigger Event:
push
-
Statement type:
File details
Details for the file pymididefs-0.2.5-py3-none-any.whl.
File metadata
- Download URL: pymididefs-0.2.5-py3-none-any.whl
- Upload date:
- Size: 28.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da1df632f870145d2ab4b53c7ccdd51753181cb0ed4ce10a94cba8a0e3bfbfd2
|
|
| MD5 |
3728e9473419d9eceef36deb13c91bd9
|
|
| BLAKE2b-256 |
1244c77bad4da120732db17ef1ae23fcac81e3f38d45e77a4cc5c471770f9bd3
|
Provenance
The following attestation bundles were made for pymididefs-0.2.5-py3-none-any.whl:
Publisher:
publish.yml on simonholliday/PyMidiDefs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pymididefs-0.2.5-py3-none-any.whl -
Subject digest:
da1df632f870145d2ab4b53c7ccdd51753181cb0ed4ce10a94cba8a0e3bfbfd2 - Sigstore transparency entry: 2199221202
- Sigstore integration time:
-
Permalink:
simonholliday/PyMidiDefs@aa6aab9edf28414db654330ec80a6401885d789b -
Branch / Tag:
refs/tags/v0.2.5 - Owner: https://github.com/simonholliday
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@aa6aab9edf28414db654330ec80a6401885d789b -
Trigger Event:
push
-
Statement type: