Overview
PicoMidi provides core MIDI protocol functionality with a clean, type-safe API. Built for developers who need reliable MIDI message handling without the bloat.
Features
- Type-safe MIDI values:
Note,Velocity,ControlValue,ProgramNumber,PitchBendValue - Message classes:
NoteOn,NoteOff,ControlChange,ProgramChange,PitchBend - Parser: Convert raw MIDI bytes to message objects
- Utilities: Value conversions, validation, formatting, timing calculations
- Core constants: Status bytes, channels, bitmasks
Installation
pip install picomidi
Quick Start
Creating Messages
from picomidi import NoteOn, NoteOff, ControlChange, ProgramChange, PitchBend
from picomidi.core import Channel, Note, Velocity, ControlValue, ProgramNumber, PitchBendValue
# Create a Note On message (Middle C, full velocity, channel 1)
note_on = NoteOn(
channel=Channel.CH1,
note=Note(60), # Middle C
velocity=Velocity(127)
)
# Convert to bytes
bytes_data = note_on.to_bytes() # b'\x90<\x7f'
# Convert to hex string
hex_str = note_on.to_hex_string() # "90 3C 7F"
Using Note Names
from picomidi.core import Note
# Create note from name
note = Note.from_name("C4") # Middle C
note = Note.from_name("A#3") # A sharp, octave 3
note = Note.from_name("Bb5") # B flat, octave 5
# Convert to name
name = note.to_name() # "C4"
name = note.to_name(use_sharps=False) # "Db4" instead of "C#4"
Parsing Messages
from picomidi.parser import Parser
parser = Parser()
# Feed raw MIDI bytes
raw_bytes = b'\x90<\x7f' # Note On message
for message in parser.feed(raw_bytes):
print(message) # NoteOn(channel=1, note=Note(C4), velocity=127)
print(message.to_hex_string()) # "90 3C 7F"
Value Conversions
from picomidi.utils.conversion import (
combine_7bit_msb_lsb,
split_14bit_to_7bit,
clamp_midi_value
)
# Combine two 7-bit values into 14-bit
msb, lsb = 0x40, 0x20
value_14bit = combine_7bit_msb_lsb(msb, lsb) # 8256
# Split 14-bit value
msb, lsb = split_14bit_to_7bit(value_14bit) # (64, 32)
# Clamp values
clamped = clamp_midi_value(200) # 127 (max MIDI value)
Timing Calculations
from picomidi.utils.timing import (
bpm_to_microseconds_per_quarter,
ticks_to_milliseconds
)
# Convert BPM to microseconds per quarter note (for MIDI files)
usec = bpm_to_microseconds_per_quarter(120) # 500000
# Convert ticks to milliseconds
ms = ticks_to_milliseconds(
ticks=480,
ticks_per_beat=480,
bpm=120
) # 1000.0 (1 second)
Project Structure
picomidi/
├── core/ # Core protocol definitions
│ ├── bitmask.py # Bit masks
│ ├── constant.py # MIDI constants
│ ├── status.py # Status bytes
│ ├── channel.py # Channel handling
│ └── types.py # Type-safe value classes
├── message/ # Message classes
│ ├── base.py # Base message class
│ └── channel_voice/ # Channel voice messages
├── parser/ # Message parsing
│ └── parser.py # Parser implementation
└── utils/ # Utilities
├── conversion.py # Value conversions
├── validation.py # Value validation
├── formatting.py # Message formatting
└── timing.py # Timing calculations
Design Principles
- Lightweight: Minimal dependencies, focused on core MIDI protocol
- Type-safe: Use dataclasses and type hints throughout
- Composable: Messages can be easily combined and extended
- Well-tested: Each module should have comprehensive tests
- Documented: Clear docstrings and examples
License
This project is licensed under the MIT License - see the LICENSE file for details.
Made with ❤️ for the MIDI community
Metadata
Release files for picomidi 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| picomidi-0.3.0.tar.gz | 60.0 kB | With provenance | Details for picomidi-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| picomidi-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for picomidi-0.3.0-py3-none-any.whl |
Total release size: 137.5 kB
Release files / picomidi-0.3.0.tar.gz
| Download URL | picomidi-0.3.0.tar.gz |
|---|---|
| Size | 60.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5836be6cbf18d4418286d7d4c0f9841df55a53ffeee424e3361296f99d277812
|
|
BLAKE2b-256 checksum How to use checksums |
99adb393bdc85f51e1dc8255cc9647898010bd0511fd56383084b8f21d8f1ddd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.
Transparency logRelease files / picomidi-0.3.0-py3-none-any.whl
| Download URL | picomidi-0.3.0-py3-none-any.whl |
|---|---|
| Size | 77.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
603527695cbada1f44dc066ef499fe0eff5c20c838de5b9235957a020b54165c
|
|
BLAKE2b-256 checksum How to use checksums |
4f7a1dcbd98c4dae0a07bc69b7559b95b75227b649c1d22a0ee4baba5165d24a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.
Transparency logSecurity for picomidi 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for picomidi-0.3.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.