Skip to content
zdk123Public

About

Zero-dependency Goertzel piano-roll, tuning, slow-clip, and MusicXML draft/patch toolkit for fast folk ornaments.

Topics

Resources

Contributing

Stars

1 star

Watchers

1 watching

Forks

Repository files navigation

reedroll

A zero-dependency Python library and CLI for transcribing fast folk ornaments. It prints semitone-spaced Goertzel piano rolls, detects tuning drift on old recordings, cuts pitch-preserved slow clips, and drafts MusicXML that you can clean up with replayable patch files.

Built for accordion and bayan transcription, though it works well on concertina, harmonica, fiddle, mandolin, and other fast acoustic recordings.

Demos: resolving fast ornaments vs. direct audio-to-MIDI

Each comparison pairs an openly licensed (CC0 or CC BY) solo folk recording with reedroll (--mode hps --auto-tune), Spotify's basic-pitch (ONNX) on the same clip, and 3-part audio playback (original recording -> verified MuseScore 4 notation from reedroll draft + cleanup patch -> basic-pitch direct MIDI).

Note on workflow: Fast folk ornaments still need a cleanup pass by ear. reedroll gives you a first draft and lets you zoom into disputed notes at 5-15 ms resolution, while recording every edit from the draft in a small *.patch.json file (see examples/patches/ and skills/reedroll-transcribe/SKILL.md).

Featured: Tatar solo bayan dance ("Әйдәгез биеп алыйк", CC BY)

A 2.8-second solo Tatar bayan biyü excerpt (YouTube, CC BY), scanned across the right-hand range (B4-C6).

reedroll vs. basic-pitch on CC BY Tatar solo bayan dance

Watch with 3-part audio (docs/demo_tatar_biyu.mp4)

On the left, reedroll separates the Bar 2 F5-G5-F5 upper mordent and Eb5 cut (O1), the twin Bar 3 F5-G5-F5 mordent (O2), and the Eb5-C5 descent (O3). On the right, basic-pitch drops O1's G5 and Eb5 completely and smears F5 across O2 and O3.

More folk traditions (with automated draft metrics & patch counts)

Tradition Instrument Excerpt & License Untouched reedroll draft F1 Cleanup patch What basic-pitch drops or smears 3-part audio video
Tatar Solo bayan "Әйдәгез биеп алыйк" (CC BY) 0.51 14 ops Twin F5-G5-F5 mordents, Eb5 cut, Eb5-C5 descent demo_tatar_biyu.mp4
Swedish Solo accordion "Dalapolska", Svenskt visarkiv (CC0) 0.41 21 ops 610 ms hole in O1, A4-B4-A4 mordent, B4-D5-B4 cut demo_dalapolska.mp4
Serbian Solo harmonika "Moravac", Stole1963 (CC BY) 0.67 20 ops E5-F5-E5 semitone trilers (310 ms gap + flat E5), G5-F#5 snap demo_moravac.mp4
Irish Solo fiddle "The Mountain Road", Tim Cornell (CC BY) 0.78 23 ops B4 reel cut on F#4, passing G4 and E4 eighths demo_mountain_road.mp4
Greek Solo Rebetiko accordion "Ap' tin poli enas mortis", Z. Vamvakousis (CC BY) 0.87 16 ops A5 pickup (200 ms gap), [C6]D6 & [B5]C6 snaps, hijaz G#5 turn demo_rebetiko.mp4
Swedish solo accordion: "Dalapolska" (CC0, 3/4 polska, -10c)

reedroll vs. basic-pitch on CC0 Dalapolska solo accordion

reedroll detects the -10 cent tuning offset (A4 = 437.5 Hz) and resolves O1: D5-E5-C5-B4, O2: A4-B4-A4 32nd-note mordent, and O3: B4-D5-B4 upper cut. basic-pitch leaves a 610 ms hole across O1, drops the C5 pickup and O2 mordent, and misses the O3 cut. Watch docs/demo_dalapolska.mp4.

Serbian solo harmonika: "Moravac" (CC BY, 2/4 kolo, -5c)

reedroll vs. basic-pitch on CC BY Serbian Moravac harmonika

reedroll detects the -5 cent offset (A4 = 438.7 Hz) and separates the chromatic Serbian trilers and grace snaps (O1: E5-F5-E5, O2: F#5-E5-F#5, O3: G5-F#5, and O4: E5-F5-E5, where F5 natural cuts against D major) across B4-A5. basic-pitch leaves a 310 ms gap over O1, drops E5 in O2, leaves a 280 ms gap across O3, and flattens O4 into plain E5. Watch docs/demo_moravac.mp4.

Irish solo fiddle: "The Mountain Road" (CC BY, 4/4 reel)

reedroll vs. basic-pitch on CC BY Irish solo fiddle

On unaccompanied solo fiddle, reedroll resolves the Bar 1 grace slides, the B4 upper reel cut inside the Bar 2 F#4 roll (O3), and passing G4 (O1) and E4 (O2, O4) eighths, while basic-pitch drops those notes and smears A4 across Bar 3. Watch docs/demo_mountain_road.mp4.

Greek Rebetiko solo accordion: "Ap' tin poli enas mortis" (CC BY, 2/4 hasapiko)

reedroll vs. basic-pitch on CC BY Greek Rebetiko solo accordion

Across C5-E6, reedroll catches the A5 pickup (O1), the staccato repeated-note grace snaps [C6]D6 (O2) and [B5]C6 (O3), and the hijaz A5-G#5-A5 lower mordent (O4). basic-pitch leaves a 200 ms gap at O1, drops both grace snaps, and flattens O4 into repeated A5. Watch docs/demo_rebetiko.mp4.

Reproduce any comparison with examples/build_demo.py (--list shows all presets and source URLs).

Why reedroll?

Standard FFTs smear adjacent semitones when windows are short enough (~30-35 ms) to catch 32nd-note ornaments. General audio-to-MIDI models also tend to trip over sustained left-hand chords and coupled reeds.

reedroll evaluates exact 12-TET pitch frequencies (with optional cents-offset tuning for old records) across selectable harmonic profiles. It uses only the Python standard library.

  time |  C4C#4 D4D#4 E4 F4F#4 G4G#4 A4A#4 B4
  0.00 |        ##                   ..
  0.04 |        ##                   ..
  0.09 |              ##                   ..
  0.14 |                    ##
  0.18 |                             ##
  0.24 |                    ##
  0.30 |              ##                   ..
  0.34 |        ##                   ..

Installation

Requires Python 3.9+. No third-party Python packages are needed. ffmpeg on PATH is optional and used for MP3/M4A/FLAC decoding, --lofi filtering, and clip export.

# Install from PyPI (once published)
pip install reedroll

# Or run without installing
uvx reedroll --help
pipx run reedroll --help

# Or install editable from source
pip install -e .

You can run the included synthetic demo without any audio files:

PYTHONPATH=src python3 examples/demo_ornament.py

Usage

1. Drafting a score and applying cleanup patches

Draft a monophonic score (JSON + MusicXML) with an instrument profile (accordion, fiddle, lofi, default). Pass --scale if the tune stays inside a mode like minor_pentatonic, hijaz, or dorian, and --suppress-bleed if left-hand chords ring through melody pauses:

reedroll draft phrase.mp3 --start 11.02 --dur 2.80 --bpm 171.4 --time 2/4 --key Gm \
  --scale minor_pentatonic --suppress-bleed --measures 4 --lo B4 --hi C6 \
  --profile accordion --auto-tune --out work/draft.json --musicxml work/draft.musicxml

Apply a cleanup patch file, or export a 2-staff score (compact ornament symbols on top, written-out 32nd notes underneath for playback):

reedroll patch work/draft.json work/phrase.patch.json \
  --out work/verified.json --musicxml work/verified.musicxml --strict-hash

# Export a bracketed 2-staff Compact + Written-Out score from verified.json
reedroll export work/verified.json --two-staff --auto-tag --musicxml work/verified_2staff.musicxml

Diff a draft against a finished score, or tally edit reasons across several patch files:

reedroll diff work/draft.json work/verified.json
reedroll stats examples/patches/*.patch.json --by accompaniment

See skills/reedroll-transcribe/SKILL.md for the step-by-step ear-checking workflow, and tools/render_review.py to render a side-by-side pitch-roll and MuseScore 4 review video.

2. Inspecting a fast ornament

Start with an ASCII piano roll across a phrase:

reedroll roll phrase.wav --start 0.95 --dur 4.2 --lo B3 --hi E5 --mode bright

For a disputed 32nd-note turn, narrow the note list and switch to a 15 ms hop with numeric output:

reedroll roll phrase.wav --start 0.98 --dur 0.45 \
  --notes D4,E4,F#4,G4,A4 --win 30 --hop 15 --numeric
  time |    D4    E4   F#4    G4    A4
 0.045 | 0.268     .     .     .     .
 0.090 |     . 0.268     .     .     .
 0.135 |     .     . 0.268     .     .
 0.180 |     .     .     .     . 0.267
 0.240 |     .     . 0.267     .     .
 0.300 |     . 0.268     .     .     .
 0.345 | 0.268     .     .     .     .

Export normal and slowed clips for listening by ear. Speeds below 0.5x chain multiple ffmpeg atempo filters automatically, and output can be mp3 or wav:

reedroll clip phrase.wav --start 0.95 --dur 0.70 \
  --out clips/orn01 --speeds 1.0,0.5,0.30 --format mp3

3. Old vinyl and tape recordings

Vintage recordings often drift by 20-50 cents and lose treble above ~3 kHz. Check the tuning offset first:

reedroll tune old_record.mp3 --start 5 --dur 30 --lofi
# Estimated tuning offset: +35.0 cents  (A4 = 448.99 Hz)

Then scan with --lofi (a 110 Hz-4.8 kHz bandpass that cuts rumble, 50/60 Hz hum, and hiss), --auto-tune, and --mode harmonic_safe:

reedroll roll old_record.mp3 --start 12.0 --dur 3.5 \
  --lo A3 --hi E5 --mode harmonic_safe --lofi --auto-tune

4. Python API

from reedroll import (
    apply_patch,
    draft_from_pcm,
    draft_to_musicxml,
    estimate_tuning,
    load_mono_pcm,
    load_patch_file,
    name_to_midi,
)

mono, sr = load_mono_pcm("phrase.wav", start_s=0.95, dur_s=2.0, target_sr=24000)
cents, a4_hz = estimate_tuning(mono, sr)

draft = draft_from_pcm(
    mono, sr, start_s=0.95, bpm=120.0, key_fifths=2, beats=2, beat_type=4,
    a4_hz=a4_hz, midi_lo=name_to_midi("B3"), midi_hi=name_to_midi("E5"),
    profile="accordion",
)
patched, _ = apply_patch(draft, load_patch_file("phrase.patch.json"))
xml = draft_to_musicxml(patched)

Harmonic modes

Mode Formula Best for
bright (default) 0.6*m(2f) + 0.4*m(4f) Clean modern bayan or accordion recordings where the 4' right-hand reed cuts above left-hand chords.
harmonic_safe sqrt(m(1f) * m(2f)) Good default for lofi or vintage records (treble rolled off above ~3 kHz) and for suppressing 3rd-harmonic ghosts, such as F# bleeding into C#.
fundamental m(1f) Very muffled 78 rpm, AM, or phone recordings with little upper-harmonic content.
hps (m(1f)*m(2f)*m(3f))^(1/3) Strict pitch checks on clean recordings.

Goertzel magnitudes are normalized by the Hann window sum, so --min-energy and numeric values stay comparable if you change the sample rate or window length.

Development

PYTHONPATH=src python3 -m unittest discover -s tests -v

See CONTRIBUTING.md for commit conventions.

License

MIT

About

Zero-dependency Goertzel piano-roll, tuning, slow-clip, and MusicXML draft/patch toolkit for fast folk ornaments.

Topics

Resources

Contributing

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages