Add MIDIUtil examples with working 90s dance compositions

- 01-basic-chord.py: chord progressions (C major)
- 02-90s-dance-track.py: 5-track 90s dance (arp, bass, pads, drums, piano)
- 03-arpeggiator.py: reusable arpeggio generator with dir/type options
- 04-single-note.py: minimal single-note example
- Rewrite compose_neon_dreams.py: cleaner track functions, proper velocity=0 note_off, tick helper
- Add README.md with setup and API reference

Uses MIDIUtil library (beats-based API) instead of mido
(clocks-based API)
This commit is contained in:
2026-04-17 21:54:54 +00:00
parent bac1bd5686
commit f19e3f0633
7 changed files with 717 additions and 225 deletions
+38 -12
View File
@@ -1,20 +1,46 @@
# pi-midi-zone
# MIDI Util Examples
A place for Pi to create music!
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.
## Contents
## Setup
### Skills
```bash
pip3 install --break-system-packages MIDIUtil
sudo apt-get install -y fluidsynth fluid-soundfont-gm
```
- **skills/90s-midi-composer/** — Skill for creating authentic 90s-style MIDI music files using Python + mido. Generates General MIDI/SC-55 aesthetic tracks with classic dance beats, synth leads, pads, bass, and piano.
## Examples
### Examples
- **examples/compose_neon_dreams.py** — Python script that composes a 90s dance track ("Neon Dreams"), 48 bars / 1.5 min / 128 BPM in A minor.
- **examples/neon_dreams.mid** — Completed 6-track MIDI file. Uses fluidsynth to listen: `fluidsynth /path/to/FluidR3_GM.sf2 examples/neon_dreams.mid`
| # | File | Description |
|---|------|------|
| 01 | basic-chord.py | Chord progressions in C major |
| 02 | 90s-dance-track.py | Full multi-track 90s dance composition (arpeggio, bass, pads, drums, piano) |
| 03 | arpeggiator.py | Automated arpeggiator with ascending/descending patterns |
| 04 | single-note.py | Minimal single-note example |
## Quick Start
1. Install: `pip3 install mido`, `sudo apt install fluidsynth fluid-soundfont-gm`
2. Run: `python3 examples/compose_neon_dreams.py`
3. Listen: `fluidsynth /usr/share/sounds/sf2/FluidR3_GM.sf2 neon_dreams.mid`
```bash
cd examples/
python3 04-single-note.py
python3 01-basic-chord.py
python3 03-arpeggiator.py
python3 02-90s-dance-track.py
# Play back with fluidsynth
fluidsynth -a alsa /usr/share/sounds/sf2/FluidR3_GM.sf2 90s-dance-track.mid
```
## API Reference
All time values are **in beats** (quarter notes):
| Method | Signature |
|--------|-----------|
| `addNote` | `(track, channel, pitch, time, duration, volume)` |
| `addTempo` | `(track, time, bpm)` |
| `addTrackName` | `(track, time, name)` |
| `addProgramChange` | `(track, channel, time, program)` |
| `addControllerEvent` | `(track, channel, time, controller, value)` |
| `writeFile` | `(fileHandle)` |