2026-04-17 21:54:54 +00:00
|
|
|
# MIDI Util Examples
|
2026-04-17 17:52:33 +01:00
|
|
|
|
2026-04-17 21:54:54 +00:00
|
|
|
Working examples created from the [MIDIUtil](https://github.com/MarkCWirt/MIDIUtil) source repo patterns.
|
|
|
|
|
All examples use MIDIUtil with beats-based (not ticks-based) time, the cleanest API for MIDI composition.
|
2026-04-17 17:42:16 +00:00
|
|
|
|
2026-04-17 21:54:54 +00:00
|
|
|
## Setup
|
2026-04-17 17:42:16 +00:00
|
|
|
|
2026-04-17 21:54:54 +00:00
|
|
|
```bash
|
|
|
|
|
pip3 install --break-system-packages MIDIUtil
|
|
|
|
|
sudo apt-get install -y fluidsynth fluid-soundfont-gm
|
|
|
|
|
```
|
2026-04-17 17:42:16 +00:00
|
|
|
|
2026-04-17 21:54:54 +00:00
|
|
|
## Examples
|
2026-04-17 17:42:16 +00:00
|
|
|
|
2026-04-17 21:54:54 +00:00
|
|
|
| # | File | Description |
|
2026-04-17 22:32:46 +00:00
|
|
|
|---|---|---|
|
2026-04-17 21:54:54 +00:00
|
|
|
| 01 | basic-chord.py | Chord progressions in C major |
|
2026-04-17 22:32:46 +00:00
|
|
|
| 02 | 90s-dance-track.py | Full multi-track 90s dance composition |
|
|
|
|
|
| 03 | arpeggiator.py | Automated arpeggiator with patterns |
|
2026-04-17 21:54:54 +00:00
|
|
|
| 04 | single-note.py | Minimal single-note example |
|
2026-04-17 17:42:16 +00:00
|
|
|
|
2026-04-17 22:32:46 +00:00
|
|
|
## Compositions
|
|
|
|
|
|
|
|
|
|
| # | File | Genre | Duration |
|
|
|
|
|
|---|---|---|---|
|
|
|
|
|
| 1 | `midi_output/midnight_drive.mid` | 90s House/Dance (128 BPM, 75s) |
|
|
|
|
|
| 2 | `midi_output/starlit_conversation.mid` | 90s Slow Jam/Love Song (88 BPM, 99s) |
|
|
|
|
|
| 3 | `midi_output/tronica.mid` | 90s Trance/EBM (138 BPM, 69s) |
|
|
|
|
|
|
2026-04-17 17:42:16 +00:00
|
|
|
## Quick Start
|
|
|
|
|
|
2026-04-17 21:54:54 +00:00
|
|
|
```bash
|
2026-04-17 22:32:46 +00:00
|
|
|
# Run an example to generate a MIDI file
|
2026-04-17 21:54:54 +00:00
|
|
|
cd examples/
|
|
|
|
|
python3 04-single-note.py
|
|
|
|
|
|
2026-04-17 22:32:46 +00:00
|
|
|
# Play back
|
|
|
|
|
fluidsynth -a alsa /usr/share/sounds/sf2/FluidR3_GM.sf2 example.mid
|
2026-04-17 21:54:54 +00:00
|
|
|
```
|