lonradio

Research — how to “code” lo-fi music in Python (Aug 2026)

1. Can you “code” music in Python? Yes.

Two styles:

The lo-fi sound is 50% harmony (m7/9 chords, slow swing) and 50% texture (crackle, saturation, lowpass blanket). A good engine needs both layers.

2. Library comparison (PyPI status, Aug 2026)

Library Version Last release Verdict
music21 10.5.0 Jun 2026 ✅ Pick — key/chord/voicing theory, MIDI export, huge community. The standard for algorithmic composition
pedalboard (Spotify) 0.9.24 Jul 2026 ✅ Pick — pro audio FX (saturation, reverb, compressors, filters) that run headless. Perfect tape/master chain
numpy 2.4.6 2026 ✅ Pick — sample synthesis: EP, bass, drums, crackle, wobble. Zero deps beyond itself
pretty_midi 0.2.11 Jul 2026 Good MIDI IO, no theory — redundant next to music21
pyo 1.0.5 Mar 2023 Real-time DSP, needs audio device; stale; awkward for headless batch render
mingus 0.6.1 Dec 2020 Stale
midiutil 1.2.1 Mar 2018 Stale, barebones
abjad 3.31 Oct 2025 LilyPond engraving — classical notation, overkill
foxdot 0.9.0 Jun 2025 Live-coding via SuperCollider — real-time performance, not batch files
muspy 0.5.0 Apr 2022 ML dataset toolkit, stale
AI text-to-audio (Riffusion, MusicGen, Stable Audio) — — Rejected: no programmatic control of bass style / chord quality / drums

Picks: music21 (compose) + numpy (synthesize) + pedalboard (master). No single library does all three; this is the standard split in real algorithmic-music repos (e.g. github.com/kauanycomin-dev/lofi-composer uses pure-Python theory + music21 for export, same pattern as this repo).

3. How the lo-fi sound is made here

4. beautifului.dev teardown (how they do it)