A tiny Python toolkit for sketching musical ideas fast. Go from a scale and a feel to a MIDI file — or a rough audio render — in a handful of lines, without booting up a DAW.
It grew out of my own scratchpad: I kept rewriting the same "give me a Euclidean pattern in D dorian and bounce it to MIDI" snippet, so I turned it into something reusable.
pip install sketchtuneOr from a checkout:
pip install -e .The only runtime dependency is NumPy (used for audio rendering).
from sketchtune import Scale, Rng, random_walk, euclidean, from_pattern, write_midi
scale = Scale.from_name("D", "dorian")
notes = random_walk(scale, 16, rng=Rng(42)) # 16 in-scale pitches
seq = from_pattern(notes, euclidean(11, 16), step=0.25, tempo=110)
write_midi(seq, "sketch.mid") # drop into any DAWWant to hear it without leaving Python?
from sketchtune import render_to_wav
render_to_wav(seq, "sketch.wav", waveform="triangle")- Scales & modes — church modes, pentatonics, blues and whole-tone, with
degree()lookups andsnap()to pull stray notes back into key. - Rhythms — Euclidean patterns via the Bjorklund algorithm, plus weighted probabilistic step sequences.
- Chords — chord qualities, inversions, diatonic triads and roman-numeral
progressions (
ii V7 I). - Melodies — scale-aware random walks, motif-seeded Markov chains and arpeggios.
- Export — a hand-written Standard MIDI File writer and a small offline synth that renders to WAV.
- Reproducible — every generator takes a seed, so a good accident stays good.
sketchtune euclid 5 8
sketchtune chords C major --roman ii V7 I
sketchtune melody A minor_pentatonic --length 16 --seed 3 --out idea.mid
sketchtune render C lydian --length 24 --out idea.wavMIT — see LICENSE.