hw-score-sim 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hw_score_sim-0.1.0/LICENSE +21 -0
- hw_score_sim-0.1.0/PKG-INFO +260 -0
- hw_score_sim-0.1.0/README.md +230 -0
- hw_score_sim-0.1.0/pyproject.toml +63 -0
- hw_score_sim-0.1.0/setup.cfg +4 -0
- hw_score_sim-0.1.0/src/hw_score_sim/__init__.py +152 -0
- hw_score_sim-0.1.0/src/hw_score_sim/catalog.py +733 -0
- hw_score_sim-0.1.0/src/hw_score_sim/cli.py +480 -0
- hw_score_sim-0.1.0/src/hw_score_sim/glyph_variants.py +2737 -0
- hw_score_sim-0.1.0/src/hw_score_sim/layout_quirks.py +542 -0
- hw_score_sim-0.1.0/src/hw_score_sim/ml_export.py +867 -0
- hw_score_sim-0.1.0/src/hw_score_sim/musescore_compat.py +1919 -0
- hw_score_sim-0.1.0/src/hw_score_sim/renderer.py +2043 -0
- hw_score_sim-0.1.0/src/hw_score_sim/rest_variants.py +1146 -0
- hw_score_sim-0.1.0/src/hw_score_sim/sampler.py +559 -0
- hw_score_sim-0.1.0/src/hw_score_sim/stroke_engine.py +824 -0
- hw_score_sim-0.1.0/src/hw_score_sim/structural_glyphs.py +1424 -0
- hw_score_sim-0.1.0/src/hw_score_sim/style_packs/baroque_classical.json +291 -0
- hw_score_sim-0.1.0/src/hw_score_sim/style_packs/everyday_student_folk.json +306 -0
- hw_score_sim-0.1.0/src/hw_score_sim/style_packs/jazz_studio_copyist.json +241 -0
- hw_score_sim-0.1.0/src/hw_score_sim/style_packs/modernist_20c.json +304 -0
- hw_score_sim-0.1.0/src/hw_score_sim/style_packs/romantic_autographs.json +313 -0
- hw_score_sim-0.1.0/src/hw_score_sim/style_packs/wild_20c_avantgarde_film_studio.json +1281 -0
- hw_score_sim-0.1.0/src/hw_score_sim/style_packs/wild_extreme_degraded_everyday.json +1278 -0
- hw_score_sim-0.1.0/src/hw_score_sim/style_packs/wild_historical_renaissance_baroque.json +1278 -0
- hw_score_sim-0.1.0/src/hw_score_sim/style_packs/wild_jazz_pop_world_vernacular.json +1282 -0
- hw_score_sim-0.1.0/src/hw_score_sim/style_packs/wild_romantic_virtuoso_autographs.json +1291 -0
- hw_score_sim-0.1.0/src/hw_score_sim/styles.py +1720 -0
- hw_score_sim-0.1.0/src/hw_score_sim.egg-info/PKG-INFO +260 -0
- hw_score_sim-0.1.0/src/hw_score_sim.egg-info/SOURCES.txt +44 -0
- hw_score_sim-0.1.0/src/hw_score_sim.egg-info/dependency_links.txt +1 -0
- hw_score_sim-0.1.0/src/hw_score_sim.egg-info/entry_points.txt +3 -0
- hw_score_sim-0.1.0/src/hw_score_sim.egg-info/requires.txt +6 -0
- hw_score_sim-0.1.0/src/hw_score_sim.egg-info/top_level.txt +1 -0
- hw_score_sim-0.1.0/tests/test_examples_smoke.py +103 -0
- hw_score_sim-0.1.0/tests/test_ml_export.py +310 -0
- hw_score_sim-0.1.0/tests/test_musescore_compat.py +479 -0
- hw_score_sim-0.1.0/tests/test_renderer.py +229 -0
- hw_score_sim-0.1.0/tests/test_rest_variants.py +254 -0
- hw_score_sim-0.1.0/tests/test_sampler_and_catalog.py +298 -0
- hw_score_sim-0.1.0/tests/test_stems_flags_beams.py +599 -0
- hw_score_sim-0.1.0/tests/test_stroke_engine.py +231 -0
- hw_score_sim-0.1.0/tests/test_stroke_uniqueness.py +98 -0
- hw_score_sim-0.1.0/tests/test_structural_glyphs.py +333 -0
- hw_score_sim-0.1.0/tests/test_style_architecture.py +435 -0
- hw_score_sim-0.1.0/tests/test_styles.py +369 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 hw-score-sim contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hw-score-sim
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Procedural handwritten sheet-music rendering engine for MusicXML and MuseScore scores
|
|
5
|
+
Author: Gregor Eesmaa
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/gregoreesmaa/hw-score-sim
|
|
8
|
+
Project-URL: Repository, https://github.com/gregoreesmaa/hw-score-sim
|
|
9
|
+
Project-URL: Issues, https://github.com/gregoreesmaa/hw-score-sim/issues
|
|
10
|
+
Keywords: music,sheet-music,handwriting,omr,musicxml,musescore,synthetic-data
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Multimedia :: Graphics
|
|
20
|
+
Classifier: Topic :: Multimedia :: Sound/Audio
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: numpy>=1.24
|
|
25
|
+
Requires-Dist: pillow>=10.0
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: pytest>=7.4; extra == "dev"
|
|
28
|
+
Requires-Dist: ruff>=0.4; extra == "dev"
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
|
|
31
|
+
# `hw-score-sim`
|
|
32
|
+
|
|
33
|
+
**Turn any MusicXML or MuseScore file into authentic, pixel-accurate handwritten sheet music — 159 historical & modern scribe styles, 164 discrete glyph archetypes + 18 beam leveling/grouping modes, infinite interpolated hands, zero MuseScore/LilyPond binaries, 100% MIT-licensed.**
|
|
34
|
+
|
|
35
|
+
[](LICENSE)
|
|
36
|
+
[](pyproject.toml)
|
|
37
|
+
[](ARCHITECTURE.md)
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Why `hw-score-sim`?
|
|
42
|
+
|
|
43
|
+
Optical Music Recognition (OMR) has a dirty secret: **printed sheet music is nearly solved, while real human manuscripts remain brutally hard.** Yet anyone trying to train an open-weights or commercial handwritten OMR model immediately hits two walls:
|
|
44
|
+
|
|
45
|
+
1. **The `CC-BY-NC` Wall.** Existing handwritten OMR corpora and asset-based synthesizers rely on scanned glyph libraries distributed under non-commercial (`CC-BY-NC`) licenses. If you want to ship an open-source, permissively licensed, or commercial OMR model, you cannot legally train on them.
|
|
46
|
+
2. **The "Handwritten Font" Illusion.** Stamping a static jazz or "handwritten" TrueType font onto straight computer-ruled staves fools nobody — least of all a neural network. Real composers and copyists never draw two identical noteheads or stems. A 1735 Leipzig goose quill cuts razor-thin upstrokes and pools oxidized iron-gall ink on downstrokes; a hurried Beethoven pocket sketchbook slashes diagonal noteheads across warping rastrum staves and crams the last two beats into the barline; a 1970s Real Book felt-tip marker bleeds into warm cream stock with bold chisel beams.
|
|
47
|
+
|
|
48
|
+
**`hw-score-sim` replaces static glyph stamps with procedural paleography.** Every stroke is synthesized from scratch in pure Python (`numpy` + `pillow`) using physical nib geometry, pressure taper, micro-tremor, dry-brush dropout, paper-tooth fiber absorption, curved rastrum staves, and human rhythmic spacing quirks — paired automatically with **exact pixel-accurate ground truth** (Bezier staff curves, symbol bounding boxes, COCO, YOLO, and MusicXML).
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## 30-Second Quickstart
|
|
53
|
+
|
|
54
|
+
### Install
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
pip install hw-score-sim
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Or from source for local development:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
git clone https://github.com/gregoreesmaa/hw-score-sim.git
|
|
64
|
+
cd hw-score-sim
|
|
65
|
+
pip install -e ".[dev]"
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Command Line (`hw-score-sim` & `hw-score-gallery`)
|
|
69
|
+
|
|
70
|
+
Render any `.musicxml`, `.mxl`, `.mscx`, or `.mscz` score across one or more scribe styles — no MuseScore or LilyPond installation required:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
# Render a score in three iconic styles (PNG + companion JSON ground truth)
|
|
74
|
+
hw-score-sim \
|
|
75
|
+
--input my_score.musicxml \
|
|
76
|
+
--styles bach_leipzig_late_quill,beethoven_late_sketchbook,real_book_1970s_felt_tip \
|
|
77
|
+
--out-dir out/
|
|
78
|
+
|
|
79
|
+
# Browse all 159 registered scribe styles
|
|
80
|
+
hw-score-sim --list-styles
|
|
81
|
+
|
|
82
|
+
# Export cropped per-system PNG strips + per-system MusicXML training targets
|
|
83
|
+
hw-score-sim \
|
|
84
|
+
--input my_score.mscz \
|
|
85
|
+
--styles all \
|
|
86
|
+
--out-dir out/pages \
|
|
87
|
+
--export-train-dir out/train_strips \
|
|
88
|
+
--seed 42
|
|
89
|
+
|
|
90
|
+
# Generate an interactive HTML eyeball gallery of styles or glyph archetypes
|
|
91
|
+
hw-score-gallery --mode scores --count 24 --out-dir gallery/scores
|
|
92
|
+
hw-score-gallery --mode stems-flags --out-dir gallery/stems_flags
|
|
93
|
+
hw-score-gallery --mode structural --out-dir gallery/structural
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Python API (Single Render + ML Dataset Factory)
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
from pathlib import Path
|
|
100
|
+
import hw_score_sim as hss
|
|
101
|
+
|
|
102
|
+
# 1. One-liner: render a score and get image + Schema v1.0 ground truth
|
|
103
|
+
sample = hss.render_sample(
|
|
104
|
+
"my_score.musicxml",
|
|
105
|
+
"beethoven_late_sketchbook",
|
|
106
|
+
seed=42,
|
|
107
|
+
)
|
|
108
|
+
sample.image.save("beethoven_page.png")
|
|
109
|
+
|
|
110
|
+
# 2. Export directly to COCO or YOLO detection formats for OMR training
|
|
111
|
+
coco_dict = hss.to_coco_annotations([sample])
|
|
112
|
+
yolo_lines = hss.to_yolo_labels(sample)
|
|
113
|
+
|
|
114
|
+
# 3. Filter styles by era and sample infinite interpolated unseen hands
|
|
115
|
+
romantic_styles = hss.filter_styles(era="romantic")
|
|
116
|
+
sampler = hss.ScribeSampler(
|
|
117
|
+
preset="wild_archive",
|
|
118
|
+
style_pool=romantic_styles,
|
|
119
|
+
master_seed=2026,
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
Path("out").mkdir(exist_ok=True)
|
|
123
|
+
for idx in range(5):
|
|
124
|
+
scribe, sample_seed = sampler.sample("my_score", variant_idx=idx)
|
|
125
|
+
unseen = hss.render_sample("my_score.musicxml", scribe, seed=sample_seed)
|
|
126
|
+
unseen.image.save(f"out/unseen_{idx:03d}.png")
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## Honest Comparison
|
|
132
|
+
|
|
133
|
+
`hw-score-sim` is built specifically for permissive, reproducible handwritten OMR synthesis. Here is how it compares honestly against the two most common alternatives:
|
|
134
|
+
|
|
135
|
+
| Dimension | `hw-score-sim` | Smashcima | MuseScore / LilyPond |
|
|
136
|
+
|---|---|---|---|
|
|
137
|
+
| **License** | **100% MIT** (code + procedural styles) | Engine MIT, **scanned glyph assets `CC-BY-NC`** | **GPL** binaries |
|
|
138
|
+
| **Commercial / Open-Weights ML Training** | Unrestricted | Blocked by `CC-BY-NC` assets | Requires isolating GPL pipeline; engraved look only |
|
|
139
|
+
| **Visual Authenticity** | Procedural nib physics, 159 styles, 164 glyph archetypes + 18 beam modes, 6 paper stocks | Real scanned handwritten cutouts (e.g., MUSCIMA++ / Mashcima) | Publication-grade typeset engraving (uniform fonts) |
|
|
140
|
+
| **Style Diversity** | 159 named styles + **infinite continuous interpolation** | Bound to scanned writer pools | Fixed engraving fonts |
|
|
141
|
+
| **Runtime Dependencies** | Pure Python (`numpy`, `pillow`) — **zero external binaries** | Python + external asset downloads | Headless Qt/GUI or LilyPond binary installs |
|
|
142
|
+
| **Ground Truth** | Exact Bezier staves, glyph bboxes, COCO, YOLO, MusicXML | Pixel masks & MuNG graphs | External alignment or SVG scraping required |
|
|
143
|
+
| **Best Use Case** | Large-scale permissive handwritten OMR pretraining & domain randomization | Academic-only benchmarks matching MUSCIMA++ writers | Typeset sheet music publishing |
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## The Scribe Universe
|
|
148
|
+
|
|
149
|
+
### 159 Scribe Styles Across 10 Curated Packs (+ 20 Built-In Core Profiles)
|
|
150
|
+
|
|
151
|
+
Every style is a rich paleographic profile specifying 35+ physical parameters — nib angle and contrast ratio, stroke scale, bow wobble, neuromuscular tremor, ink pooling, dry-brush dropout, slant, notehead/stem/flag/beam/clef/key-signature/barline/rest archetypes, rastrum curvature, bar-width variance, end-of-bar cramming, paper stock, foxing mottle, reverse-side bleed-through, and marginalia.
|
|
152
|
+
|
|
153
|
+
| Style Pack (`src/hw_score_sim/style_packs/`) | Count | Historical & Visual Focus |
|
|
154
|
+
|---|---|---|
|
|
155
|
+
| *(Built-in core profiles in `styles.py`)* | 20 | Foundational Baroque, Classical, Romantic, Jazz, Student, Left-Handed, Tremor, Hectograph, Red-Pencil |
|
|
156
|
+
| `baroque_classical.json` | 6 | Bach Leipzig quill, Handel London opera rush, Vivaldi furia, Telemann, Haydn, Mozart Vienna |
|
|
157
|
+
| `romantic_autographs.json` | 6 | Beethoven late sketchbook, Schubert Lieder, Schumann diary, Chopin Stichvorlage, Brahms, Liszt |
|
|
158
|
+
| `modernist_20c.json` | 6 | Debussy violet ink, Ravel microscopic precision, Stravinsky Stravigor nib, Bartók field notebook, etc. |
|
|
159
|
+
| `jazz_studio_copyist.json` | 5 | 1970s Real Book felt-tip, Hollywood Ozalid vellum, Broadway pit copyist chisel, Big Band pencil |
|
|
160
|
+
| `everyday_student_folk.json` | 6 | Conservatory exam pencil, amateur gel pen, pub fiddler pocket notebook, church organist hymnal |
|
|
161
|
+
| `wild_historical_renaissance_baroque.json` | 22 | Extreme historical hands: Scarlatti needle harpsichord, Couperin pinprick, Frescobaldi lozenge choirbook, Monteverdi |
|
|
162
|
+
| `wild_romantic_virtuoso_autographs.json` | 22 | Extreme Romantic autographs: Beethoven Op. 131 blots, Chopin Nohant pinprick, Liszt Weimar red revisions |
|
|
163
|
+
| `wild_20c_avantgarde_film_studio.json` | 22 | Stravinsky needle vellum, Prokofiev telegraphic slash, Shostakovich Soviet ballpoint, avant-garde & film scoring |
|
|
164
|
+
| `wild_jazz_pop_world_vernacular.json` | 22 | Bebop napkin ballpoint, Ellington/Strayhorn arranger slash, Blue Note hard-bop pencil, vernacular & studio |
|
|
165
|
+
| `wild_extreme_degraded_everyday.json` | 22 | 0.25 mm mechanical pencil, dry Bic ballpoint, lefty blue gel smear, arthritis tremor, extreme degradations |
|
|
166
|
+
| **Total Registered Styles** | **159** | **Plus infinite continuous interpolation via `interpolate_styles()` & `ScribeSampler`** |
|
|
167
|
+
|
|
168
|
+
### 164 Discrete Glyph Archetypes + 18 Beam Leveling/Grouping Modes + 5 Ledger Styles + 6 Paper Stocks
|
|
169
|
+
|
|
170
|
+
| Category | Count | Archetypes |
|
|
171
|
+
|---|---|---|
|
|
172
|
+
| **Noteheads** | **18** | `oval`, `slash`, `teardrop`, `compact`, `heavy_wedge`, `hollow_diamond`, **ultra-slim:** `slim_oval`, `needle_slash`, `hairline_dash`, `vertical_tick`, `pinprick_dot`, `slim_diamond`, plus `boomerang_hook`, `open_loop`, `zigzag_fill`, `broad_nib_lozenge`, `ink_blot`, `chevron_wedge` |
|
|
173
|
+
| **Stems** | **18** | `straight_classic`, `hairline_needle`, `heavy_thick`, `tapered_quill`, `bowed_right`, `bowed_left`, `s_curve_flex`, `short_stubby`, `tall_spindly`, `steep_forward_slant`, `back_slant_lefty`, `detached_gap`, `center_piercing`, `overshoot_notehead`, `tremor_shaky`, `double_stroke_sketch`, `flared_base`, `whip_taper` |
|
|
174
|
+
| **Flags** | **20** | `classic_droop`, `baroque_curl`, `sharp_angular_7`, `hurried_slash`, `tiny_flick`, `long_dramatic_s`, `closed_loop_flourish`, `broad_nib_pennant`, `detached_tick`, `wide_horizontal_wing`, `steep_vertical_drop`, `zigzag_frantic`, `hooked_j_tail`, `calligraphic_ribbon`, `stubby_wedge`, `double_back_loop`, `feathered_sweep`, `flat_bar_flag`, `reverse_kick`, `minimal_dot_tail` |
|
|
175
|
+
| **Beams** | **14** | `straight_classic`, `thick_marker`, `hairline_thin`, `arched_convex`, `sagged_concave`, `tapered_wedge`, `overhanging_ends`, `short_clipped`, `scribble_double_pass`, `calligraphic_ribbon`, `stepped_wobbly`, `gapped_broken`, `wide_spaced_bars`, `tight_crammed_bars` |
|
|
176
|
+
| **Beam Leveling & Grouping** | **18** | **10 slope styles** (`horizontal_flat`, `engraver_gentle`, `steep_contour`, `exaggerated_swoop`, `reverse_quirk`, `concave_valley`, `convex_arch`, `stepped_secondary_tilt`, `high_floating_beam`, `tight_hug_beam`) + **8 grouping modes** (`standard_beat`, `all_flags_vocal`, `mixed_split_flags`, `long_phrase_beam`, `pair_beams_2`, `uneven_3_plus_1`, `feathered_splay`, `french_broken_secondary`) |
|
|
177
|
+
| **Clefs** | **18** | `classic_engraved`, `baroque_ornate_scroll`, `hurried_single_loop`, `tall_spindly_g`, `stubby_compact`, `minimal_s_slash`, `figure_8_treble`, `beethoven_wild_slash`, `chopin_delicate_spiral`, `jazz_realbook_bold`, `sharp_angular_modern`, `detached_dot_bass`, `open_c_hook_bass`, `double_bar_c_clef`, `bracket_c_clef`, `calligraphic_broad_nib`, `tremor_shaky_clef`, `backslant_lefty_clef` |
|
|
178
|
+
| **Key Sigs & Accidentals** | **18** | `classic_neat`, `tall_narrow_sharp`, `wide_slanted_hash`, `hurried_x_sharp`, `open_loop_flat`, `pointed_teardrop_flat`, `tiny_pinprick_acc`, `oversized_bold_acc`, `crammed_tight_cluster`, `wide_spread_keysig`, `ascending_drift_keysig`, `descending_drift_keysig`, `double_stroke_sketch`, `calligraphic_nib_acc`, `baroque_vertical_flat`, `jazz_heavy_marker_acc`, `hairline_needle_acc`, `jagged_zigzag_acc` |
|
|
179
|
+
| **Barlines** | **18** | `crisp_vertical`, `tall_overshoot`, `short_clipped_inside`, `steep_forward_slant`, `back_slant_lefty`, `bowed_curved_bar`, `s_wobble_freehand`, `heavy_thick_marker`, `hairline_faint`, `tapered_quill_bar`, `double_pass_sketch`, `gapped_broken_bar`, `hooked_top_bottom_serif`, `wide_double_gap`, `tight_double_gap`, `oversized_repeat_blobs`, `tiny_pinprick_repeat_dots`, `slashed_repeat_ticks` |
|
|
180
|
+
| **Rests / Pauses** | **40** | **10 legacy quarter rests** (`lightning_z`, `backwards_7_hook`, `cursive_3`, `hurried_slash_zig`, `baroque_c_hook`, `calligraphic_s_curl`, `sharp_v_tick`, `baroque_flag_loop`, `modern_tall_z`, `scribble_s`) + **18 new quarter rests** (`baroque_reversed_r`, `beethoven_violent_zig`, `chopin_gossamer_3`, `schubert_vertical_drop`, `brahms_bold_chevron`, `liszt_sweeping_s_hook`, `debussy_floating_tilde`, `stravinsky_geometric_z`, `shostakovich_looped_2`, `realbook_chisel_bolt`, `bebop_napkin_tick`, `studio_copyist_clean_3`, `student_awkward_e`, `arthritis_tremor_zig`, `lefty_backslant_hook`, `hairline_needle_s`, `open_double_loop_r`, `pinprick_minimal_v`) + **6 flagged rests** + **6 bar/fermata rests** |
|
|
181
|
+
| **Ledger Lines** | **5** | `crisp`, `wide_sweep`, `slanted`, `short_tick`, `wavy` |
|
|
182
|
+
| **Paper Stocks** | **6** | `aged_rag`, `bright_white`, `cream_manuscript`, `spiral_notebook`, `ozalid_blue`, `soviet_green_tint` |
|
|
183
|
+
|
|
184
|
+
### 8 Iconic Hero Styles
|
|
185
|
+
|
|
186
|
+
| Style ID | Era & Medium | Signature Paleographic Traits |
|
|
187
|
+
|---|---|---|
|
|
188
|
+
| `bach_leipzig_late_quill` | 1730s Baroque · Broad goose quill & iron-gall | 43° nib contrast, 15.5° forward impetus, teardrop heads, Baroque hooked C-rests, dense contrapuntal cramming |
|
|
189
|
+
| `beethoven_late_sketchbook` | 1825 Late Classical · Blunted quill & graphite | Diagonal `slash` noteheads, heavy ink pooling, wild barline overshoot, 14.5 px staff warp, dense marginalia |
|
|
190
|
+
| `chopin_delicate_salon` | 1840s Romantic · Fine pointed steel nib | Feather-light hairlines, delicate spiral clefs, graceful slant, airy salon phrasing on cream manuscript stock |
|
|
191
|
+
| `debussy_pencil_sketch` | 1900s Impressionist · Soft graphite on textured rag | Dry paper-tooth grain, soft variable pressure, subtle eraser smudges, gentle organic drift |
|
|
192
|
+
| `real_book_1970s_felt_tip` | 1970s Jazz · Broad chisel felt-tip marker | Thick marker beams, bold Real Book clefs, wide slanted accidentals, warm cream lead-sheet stock |
|
|
193
|
+
| `hollywood_ozalid_vellum` | 1950s Film Studio · Ink on translucent Ozalid copy | Cool `ozalid_blue` tint, crisp studio-copyist verticality, disciplined spacing built for sight-reading |
|
|
194
|
+
| `student_ballpoint_blue` | Modern Everyday · Cheap blue ballpoint on spiral pad | Narrow uniform ballpoint width, occasional ink skip/dropout, uneven bar widths, `spiral_notebook` paper |
|
|
195
|
+
| `wild_ext_arthritis_tremor` | Stress-Test Extreme · Shaky nib with high tremor | High-frequency neuromuscular tremor, wavering stems & barlines, irregular spacing — OMR robustness gold |
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
## Community Style Packs: 30-Line JSON-Only PR Workflow
|
|
200
|
+
|
|
201
|
+
You do **not** need to write a single line of Python to contribute a new historical composer hand, regional copyist tradition, or modern studio style. Style packs in `src/hw_score_sim/style_packs/*.json` are auto-discovered on import and support multi-level `"extends"` inheritance:
|
|
202
|
+
|
|
203
|
+
```json
|
|
204
|
+
{
|
|
205
|
+
"my_vienna_coffeehouse_sketch": {
|
|
206
|
+
"extends": "schubert_rapid_lieder_draft",
|
|
207
|
+
"description": "Hasty Viennese coffeehouse pencil sketch on folded cream stock.",
|
|
208
|
+
"era": "early_romantic",
|
|
209
|
+
"ink_rgb": [0.28, 0.27, 0.25],
|
|
210
|
+
"nib_min_ratio": 0.65,
|
|
211
|
+
"grain_strength": 0.34,
|
|
212
|
+
"notehead_archetype": "needle_slash",
|
|
213
|
+
"stem_archetype": "bowed_right",
|
|
214
|
+
"flag_archetype": "hurried_slash",
|
|
215
|
+
"beam_archetype": "arched_convex",
|
|
216
|
+
"paper_type": "cream_manuscript",
|
|
217
|
+
"eraser_smudge_prob": 0.35
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Drop your `.json` file into `src/hw_score_sim/style_packs/`, preview it with `hw-score-gallery`, run `python -m unittest discover -s tests`, and open a PR! See [CONTRIBUTING.md](CONTRIBUTING.md) for the full guide.
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
## Runnable Examples
|
|
227
|
+
|
|
228
|
+
Explore the `examples/` directory for end-to-end recipes:
|
|
229
|
+
|
|
230
|
+
- [`examples/01_time_machine_strip.py`](examples/01_time_machine_strip.py) — Render the same musical passage across centuries (Baroque quill → Beethoven sketchbook → 1970s Real Book → modern ballpoint) into a side-by-side comparison strip.
|
|
231
|
+
- [`examples/02_scribe_morph.py`](examples/02_scribe_morph.py) — Morph smoothly between two historical scribes (`interpolate_styles`) to visualize continuous handwriting space.
|
|
232
|
+
- [`examples/03_infinite_omr_dataset.py`](examples/03_infinite_omr_dataset.py) — Build a deterministic, domain-randomized OMR training set with `ScribeSampler`, COCO JSON, and YOLO labels.
|
|
233
|
+
- [`examples/04_custom_scribe_from_json.py`](examples/04_custom_scribe_from_json.py) — Define a custom scribe in a 30-line JSON snippet using `"extends"`, register it at runtime, and render a full page.
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## Documentation
|
|
238
|
+
|
|
239
|
+
- [ARCHITECTURE.md](ARCHITECTURE.md) — End-to-end rendering pipeline, module map, determinism contract, and Ground-Truth Schema v1.0.
|
|
240
|
+
- [CONTRIBUTING.md](CONTRIBUTING.md) — How to author JSON style packs, add new glyph archetypes, and run the test suite.
|
|
241
|
+
- [CHANGELOG.md](CHANGELOG.md) — Release history.
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
## License & Citation
|
|
246
|
+
|
|
247
|
+
`hw-score-sim` is released under the **[MIT License](LICENSE)** — free for academic, open-source, and commercial use.
|
|
248
|
+
|
|
249
|
+
If you use `hw-score-sim` in your research or OMR training pipeline, please cite:
|
|
250
|
+
|
|
251
|
+
```bibtex
|
|
252
|
+
@software{eesmaa_hw_score_sim_2026,
|
|
253
|
+
title = {hw-score-sim: Procedural Handwritten Sheet-Music Rendering Engine},
|
|
254
|
+
author = {Gregor Eesmaa and hw-score-sim contributors},
|
|
255
|
+
year = {2026},
|
|
256
|
+
version = {0.1.0},
|
|
257
|
+
license = {MIT},
|
|
258
|
+
url = {https://github.com/gregoreesmaa/hw-score-sim}
|
|
259
|
+
}
|
|
260
|
+
```
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
# `hw-score-sim`
|
|
2
|
+
|
|
3
|
+
**Turn any MusicXML or MuseScore file into authentic, pixel-accurate handwritten sheet music — 159 historical & modern scribe styles, 164 discrete glyph archetypes + 18 beam leveling/grouping modes, infinite interpolated hands, zero MuseScore/LilyPond binaries, 100% MIT-licensed.**
|
|
4
|
+
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
[](pyproject.toml)
|
|
7
|
+
[](ARCHITECTURE.md)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Why `hw-score-sim`?
|
|
12
|
+
|
|
13
|
+
Optical Music Recognition (OMR) has a dirty secret: **printed sheet music is nearly solved, while real human manuscripts remain brutally hard.** Yet anyone trying to train an open-weights or commercial handwritten OMR model immediately hits two walls:
|
|
14
|
+
|
|
15
|
+
1. **The `CC-BY-NC` Wall.** Existing handwritten OMR corpora and asset-based synthesizers rely on scanned glyph libraries distributed under non-commercial (`CC-BY-NC`) licenses. If you want to ship an open-source, permissively licensed, or commercial OMR model, you cannot legally train on them.
|
|
16
|
+
2. **The "Handwritten Font" Illusion.** Stamping a static jazz or "handwritten" TrueType font onto straight computer-ruled staves fools nobody — least of all a neural network. Real composers and copyists never draw two identical noteheads or stems. A 1735 Leipzig goose quill cuts razor-thin upstrokes and pools oxidized iron-gall ink on downstrokes; a hurried Beethoven pocket sketchbook slashes diagonal noteheads across warping rastrum staves and crams the last two beats into the barline; a 1970s Real Book felt-tip marker bleeds into warm cream stock with bold chisel beams.
|
|
17
|
+
|
|
18
|
+
**`hw-score-sim` replaces static glyph stamps with procedural paleography.** Every stroke is synthesized from scratch in pure Python (`numpy` + `pillow`) using physical nib geometry, pressure taper, micro-tremor, dry-brush dropout, paper-tooth fiber absorption, curved rastrum staves, and human rhythmic spacing quirks — paired automatically with **exact pixel-accurate ground truth** (Bezier staff curves, symbol bounding boxes, COCO, YOLO, and MusicXML).
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## 30-Second Quickstart
|
|
23
|
+
|
|
24
|
+
### Install
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pip install hw-score-sim
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Or from source for local development:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
git clone https://github.com/gregoreesmaa/hw-score-sim.git
|
|
34
|
+
cd hw-score-sim
|
|
35
|
+
pip install -e ".[dev]"
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Command Line (`hw-score-sim` & `hw-score-gallery`)
|
|
39
|
+
|
|
40
|
+
Render any `.musicxml`, `.mxl`, `.mscx`, or `.mscz` score across one or more scribe styles — no MuseScore or LilyPond installation required:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# Render a score in three iconic styles (PNG + companion JSON ground truth)
|
|
44
|
+
hw-score-sim \
|
|
45
|
+
--input my_score.musicxml \
|
|
46
|
+
--styles bach_leipzig_late_quill,beethoven_late_sketchbook,real_book_1970s_felt_tip \
|
|
47
|
+
--out-dir out/
|
|
48
|
+
|
|
49
|
+
# Browse all 159 registered scribe styles
|
|
50
|
+
hw-score-sim --list-styles
|
|
51
|
+
|
|
52
|
+
# Export cropped per-system PNG strips + per-system MusicXML training targets
|
|
53
|
+
hw-score-sim \
|
|
54
|
+
--input my_score.mscz \
|
|
55
|
+
--styles all \
|
|
56
|
+
--out-dir out/pages \
|
|
57
|
+
--export-train-dir out/train_strips \
|
|
58
|
+
--seed 42
|
|
59
|
+
|
|
60
|
+
# Generate an interactive HTML eyeball gallery of styles or glyph archetypes
|
|
61
|
+
hw-score-gallery --mode scores --count 24 --out-dir gallery/scores
|
|
62
|
+
hw-score-gallery --mode stems-flags --out-dir gallery/stems_flags
|
|
63
|
+
hw-score-gallery --mode structural --out-dir gallery/structural
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Python API (Single Render + ML Dataset Factory)
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
from pathlib import Path
|
|
70
|
+
import hw_score_sim as hss
|
|
71
|
+
|
|
72
|
+
# 1. One-liner: render a score and get image + Schema v1.0 ground truth
|
|
73
|
+
sample = hss.render_sample(
|
|
74
|
+
"my_score.musicxml",
|
|
75
|
+
"beethoven_late_sketchbook",
|
|
76
|
+
seed=42,
|
|
77
|
+
)
|
|
78
|
+
sample.image.save("beethoven_page.png")
|
|
79
|
+
|
|
80
|
+
# 2. Export directly to COCO or YOLO detection formats for OMR training
|
|
81
|
+
coco_dict = hss.to_coco_annotations([sample])
|
|
82
|
+
yolo_lines = hss.to_yolo_labels(sample)
|
|
83
|
+
|
|
84
|
+
# 3. Filter styles by era and sample infinite interpolated unseen hands
|
|
85
|
+
romantic_styles = hss.filter_styles(era="romantic")
|
|
86
|
+
sampler = hss.ScribeSampler(
|
|
87
|
+
preset="wild_archive",
|
|
88
|
+
style_pool=romantic_styles,
|
|
89
|
+
master_seed=2026,
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
Path("out").mkdir(exist_ok=True)
|
|
93
|
+
for idx in range(5):
|
|
94
|
+
scribe, sample_seed = sampler.sample("my_score", variant_idx=idx)
|
|
95
|
+
unseen = hss.render_sample("my_score.musicxml", scribe, seed=sample_seed)
|
|
96
|
+
unseen.image.save(f"out/unseen_{idx:03d}.png")
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## Honest Comparison
|
|
102
|
+
|
|
103
|
+
`hw-score-sim` is built specifically for permissive, reproducible handwritten OMR synthesis. Here is how it compares honestly against the two most common alternatives:
|
|
104
|
+
|
|
105
|
+
| Dimension | `hw-score-sim` | Smashcima | MuseScore / LilyPond |
|
|
106
|
+
|---|---|---|---|
|
|
107
|
+
| **License** | **100% MIT** (code + procedural styles) | Engine MIT, **scanned glyph assets `CC-BY-NC`** | **GPL** binaries |
|
|
108
|
+
| **Commercial / Open-Weights ML Training** | Unrestricted | Blocked by `CC-BY-NC` assets | Requires isolating GPL pipeline; engraved look only |
|
|
109
|
+
| **Visual Authenticity** | Procedural nib physics, 159 styles, 164 glyph archetypes + 18 beam modes, 6 paper stocks | Real scanned handwritten cutouts (e.g., MUSCIMA++ / Mashcima) | Publication-grade typeset engraving (uniform fonts) |
|
|
110
|
+
| **Style Diversity** | 159 named styles + **infinite continuous interpolation** | Bound to scanned writer pools | Fixed engraving fonts |
|
|
111
|
+
| **Runtime Dependencies** | Pure Python (`numpy`, `pillow`) — **zero external binaries** | Python + external asset downloads | Headless Qt/GUI or LilyPond binary installs |
|
|
112
|
+
| **Ground Truth** | Exact Bezier staves, glyph bboxes, COCO, YOLO, MusicXML | Pixel masks & MuNG graphs | External alignment or SVG scraping required |
|
|
113
|
+
| **Best Use Case** | Large-scale permissive handwritten OMR pretraining & domain randomization | Academic-only benchmarks matching MUSCIMA++ writers | Typeset sheet music publishing |
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## The Scribe Universe
|
|
118
|
+
|
|
119
|
+
### 159 Scribe Styles Across 10 Curated Packs (+ 20 Built-In Core Profiles)
|
|
120
|
+
|
|
121
|
+
Every style is a rich paleographic profile specifying 35+ physical parameters — nib angle and contrast ratio, stroke scale, bow wobble, neuromuscular tremor, ink pooling, dry-brush dropout, slant, notehead/stem/flag/beam/clef/key-signature/barline/rest archetypes, rastrum curvature, bar-width variance, end-of-bar cramming, paper stock, foxing mottle, reverse-side bleed-through, and marginalia.
|
|
122
|
+
|
|
123
|
+
| Style Pack (`src/hw_score_sim/style_packs/`) | Count | Historical & Visual Focus |
|
|
124
|
+
|---|---|---|
|
|
125
|
+
| *(Built-in core profiles in `styles.py`)* | 20 | Foundational Baroque, Classical, Romantic, Jazz, Student, Left-Handed, Tremor, Hectograph, Red-Pencil |
|
|
126
|
+
| `baroque_classical.json` | 6 | Bach Leipzig quill, Handel London opera rush, Vivaldi furia, Telemann, Haydn, Mozart Vienna |
|
|
127
|
+
| `romantic_autographs.json` | 6 | Beethoven late sketchbook, Schubert Lieder, Schumann diary, Chopin Stichvorlage, Brahms, Liszt |
|
|
128
|
+
| `modernist_20c.json` | 6 | Debussy violet ink, Ravel microscopic precision, Stravinsky Stravigor nib, Bartók field notebook, etc. |
|
|
129
|
+
| `jazz_studio_copyist.json` | 5 | 1970s Real Book felt-tip, Hollywood Ozalid vellum, Broadway pit copyist chisel, Big Band pencil |
|
|
130
|
+
| `everyday_student_folk.json` | 6 | Conservatory exam pencil, amateur gel pen, pub fiddler pocket notebook, church organist hymnal |
|
|
131
|
+
| `wild_historical_renaissance_baroque.json` | 22 | Extreme historical hands: Scarlatti needle harpsichord, Couperin pinprick, Frescobaldi lozenge choirbook, Monteverdi |
|
|
132
|
+
| `wild_romantic_virtuoso_autographs.json` | 22 | Extreme Romantic autographs: Beethoven Op. 131 blots, Chopin Nohant pinprick, Liszt Weimar red revisions |
|
|
133
|
+
| `wild_20c_avantgarde_film_studio.json` | 22 | Stravinsky needle vellum, Prokofiev telegraphic slash, Shostakovich Soviet ballpoint, avant-garde & film scoring |
|
|
134
|
+
| `wild_jazz_pop_world_vernacular.json` | 22 | Bebop napkin ballpoint, Ellington/Strayhorn arranger slash, Blue Note hard-bop pencil, vernacular & studio |
|
|
135
|
+
| `wild_extreme_degraded_everyday.json` | 22 | 0.25 mm mechanical pencil, dry Bic ballpoint, lefty blue gel smear, arthritis tremor, extreme degradations |
|
|
136
|
+
| **Total Registered Styles** | **159** | **Plus infinite continuous interpolation via `interpolate_styles()` & `ScribeSampler`** |
|
|
137
|
+
|
|
138
|
+
### 164 Discrete Glyph Archetypes + 18 Beam Leveling/Grouping Modes + 5 Ledger Styles + 6 Paper Stocks
|
|
139
|
+
|
|
140
|
+
| Category | Count | Archetypes |
|
|
141
|
+
|---|---|---|
|
|
142
|
+
| **Noteheads** | **18** | `oval`, `slash`, `teardrop`, `compact`, `heavy_wedge`, `hollow_diamond`, **ultra-slim:** `slim_oval`, `needle_slash`, `hairline_dash`, `vertical_tick`, `pinprick_dot`, `slim_diamond`, plus `boomerang_hook`, `open_loop`, `zigzag_fill`, `broad_nib_lozenge`, `ink_blot`, `chevron_wedge` |
|
|
143
|
+
| **Stems** | **18** | `straight_classic`, `hairline_needle`, `heavy_thick`, `tapered_quill`, `bowed_right`, `bowed_left`, `s_curve_flex`, `short_stubby`, `tall_spindly`, `steep_forward_slant`, `back_slant_lefty`, `detached_gap`, `center_piercing`, `overshoot_notehead`, `tremor_shaky`, `double_stroke_sketch`, `flared_base`, `whip_taper` |
|
|
144
|
+
| **Flags** | **20** | `classic_droop`, `baroque_curl`, `sharp_angular_7`, `hurried_slash`, `tiny_flick`, `long_dramatic_s`, `closed_loop_flourish`, `broad_nib_pennant`, `detached_tick`, `wide_horizontal_wing`, `steep_vertical_drop`, `zigzag_frantic`, `hooked_j_tail`, `calligraphic_ribbon`, `stubby_wedge`, `double_back_loop`, `feathered_sweep`, `flat_bar_flag`, `reverse_kick`, `minimal_dot_tail` |
|
|
145
|
+
| **Beams** | **14** | `straight_classic`, `thick_marker`, `hairline_thin`, `arched_convex`, `sagged_concave`, `tapered_wedge`, `overhanging_ends`, `short_clipped`, `scribble_double_pass`, `calligraphic_ribbon`, `stepped_wobbly`, `gapped_broken`, `wide_spaced_bars`, `tight_crammed_bars` |
|
|
146
|
+
| **Beam Leveling & Grouping** | **18** | **10 slope styles** (`horizontal_flat`, `engraver_gentle`, `steep_contour`, `exaggerated_swoop`, `reverse_quirk`, `concave_valley`, `convex_arch`, `stepped_secondary_tilt`, `high_floating_beam`, `tight_hug_beam`) + **8 grouping modes** (`standard_beat`, `all_flags_vocal`, `mixed_split_flags`, `long_phrase_beam`, `pair_beams_2`, `uneven_3_plus_1`, `feathered_splay`, `french_broken_secondary`) |
|
|
147
|
+
| **Clefs** | **18** | `classic_engraved`, `baroque_ornate_scroll`, `hurried_single_loop`, `tall_spindly_g`, `stubby_compact`, `minimal_s_slash`, `figure_8_treble`, `beethoven_wild_slash`, `chopin_delicate_spiral`, `jazz_realbook_bold`, `sharp_angular_modern`, `detached_dot_bass`, `open_c_hook_bass`, `double_bar_c_clef`, `bracket_c_clef`, `calligraphic_broad_nib`, `tremor_shaky_clef`, `backslant_lefty_clef` |
|
|
148
|
+
| **Key Sigs & Accidentals** | **18** | `classic_neat`, `tall_narrow_sharp`, `wide_slanted_hash`, `hurried_x_sharp`, `open_loop_flat`, `pointed_teardrop_flat`, `tiny_pinprick_acc`, `oversized_bold_acc`, `crammed_tight_cluster`, `wide_spread_keysig`, `ascending_drift_keysig`, `descending_drift_keysig`, `double_stroke_sketch`, `calligraphic_nib_acc`, `baroque_vertical_flat`, `jazz_heavy_marker_acc`, `hairline_needle_acc`, `jagged_zigzag_acc` |
|
|
149
|
+
| **Barlines** | **18** | `crisp_vertical`, `tall_overshoot`, `short_clipped_inside`, `steep_forward_slant`, `back_slant_lefty`, `bowed_curved_bar`, `s_wobble_freehand`, `heavy_thick_marker`, `hairline_faint`, `tapered_quill_bar`, `double_pass_sketch`, `gapped_broken_bar`, `hooked_top_bottom_serif`, `wide_double_gap`, `tight_double_gap`, `oversized_repeat_blobs`, `tiny_pinprick_repeat_dots`, `slashed_repeat_ticks` |
|
|
150
|
+
| **Rests / Pauses** | **40** | **10 legacy quarter rests** (`lightning_z`, `backwards_7_hook`, `cursive_3`, `hurried_slash_zig`, `baroque_c_hook`, `calligraphic_s_curl`, `sharp_v_tick`, `baroque_flag_loop`, `modern_tall_z`, `scribble_s`) + **18 new quarter rests** (`baroque_reversed_r`, `beethoven_violent_zig`, `chopin_gossamer_3`, `schubert_vertical_drop`, `brahms_bold_chevron`, `liszt_sweeping_s_hook`, `debussy_floating_tilde`, `stravinsky_geometric_z`, `shostakovich_looped_2`, `realbook_chisel_bolt`, `bebop_napkin_tick`, `studio_copyist_clean_3`, `student_awkward_e`, `arthritis_tremor_zig`, `lefty_backslant_hook`, `hairline_needle_s`, `open_double_loop_r`, `pinprick_minimal_v`) + **6 flagged rests** + **6 bar/fermata rests** |
|
|
151
|
+
| **Ledger Lines** | **5** | `crisp`, `wide_sweep`, `slanted`, `short_tick`, `wavy` |
|
|
152
|
+
| **Paper Stocks** | **6** | `aged_rag`, `bright_white`, `cream_manuscript`, `spiral_notebook`, `ozalid_blue`, `soviet_green_tint` |
|
|
153
|
+
|
|
154
|
+
### 8 Iconic Hero Styles
|
|
155
|
+
|
|
156
|
+
| Style ID | Era & Medium | Signature Paleographic Traits |
|
|
157
|
+
|---|---|---|
|
|
158
|
+
| `bach_leipzig_late_quill` | 1730s Baroque · Broad goose quill & iron-gall | 43° nib contrast, 15.5° forward impetus, teardrop heads, Baroque hooked C-rests, dense contrapuntal cramming |
|
|
159
|
+
| `beethoven_late_sketchbook` | 1825 Late Classical · Blunted quill & graphite | Diagonal `slash` noteheads, heavy ink pooling, wild barline overshoot, 14.5 px staff warp, dense marginalia |
|
|
160
|
+
| `chopin_delicate_salon` | 1840s Romantic · Fine pointed steel nib | Feather-light hairlines, delicate spiral clefs, graceful slant, airy salon phrasing on cream manuscript stock |
|
|
161
|
+
| `debussy_pencil_sketch` | 1900s Impressionist · Soft graphite on textured rag | Dry paper-tooth grain, soft variable pressure, subtle eraser smudges, gentle organic drift |
|
|
162
|
+
| `real_book_1970s_felt_tip` | 1970s Jazz · Broad chisel felt-tip marker | Thick marker beams, bold Real Book clefs, wide slanted accidentals, warm cream lead-sheet stock |
|
|
163
|
+
| `hollywood_ozalid_vellum` | 1950s Film Studio · Ink on translucent Ozalid copy | Cool `ozalid_blue` tint, crisp studio-copyist verticality, disciplined spacing built for sight-reading |
|
|
164
|
+
| `student_ballpoint_blue` | Modern Everyday · Cheap blue ballpoint on spiral pad | Narrow uniform ballpoint width, occasional ink skip/dropout, uneven bar widths, `spiral_notebook` paper |
|
|
165
|
+
| `wild_ext_arthritis_tremor` | Stress-Test Extreme · Shaky nib with high tremor | High-frequency neuromuscular tremor, wavering stems & barlines, irregular spacing — OMR robustness gold |
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## Community Style Packs: 30-Line JSON-Only PR Workflow
|
|
170
|
+
|
|
171
|
+
You do **not** need to write a single line of Python to contribute a new historical composer hand, regional copyist tradition, or modern studio style. Style packs in `src/hw_score_sim/style_packs/*.json` are auto-discovered on import and support multi-level `"extends"` inheritance:
|
|
172
|
+
|
|
173
|
+
```json
|
|
174
|
+
{
|
|
175
|
+
"my_vienna_coffeehouse_sketch": {
|
|
176
|
+
"extends": "schubert_rapid_lieder_draft",
|
|
177
|
+
"description": "Hasty Viennese coffeehouse pencil sketch on folded cream stock.",
|
|
178
|
+
"era": "early_romantic",
|
|
179
|
+
"ink_rgb": [0.28, 0.27, 0.25],
|
|
180
|
+
"nib_min_ratio": 0.65,
|
|
181
|
+
"grain_strength": 0.34,
|
|
182
|
+
"notehead_archetype": "needle_slash",
|
|
183
|
+
"stem_archetype": "bowed_right",
|
|
184
|
+
"flag_archetype": "hurried_slash",
|
|
185
|
+
"beam_archetype": "arched_convex",
|
|
186
|
+
"paper_type": "cream_manuscript",
|
|
187
|
+
"eraser_smudge_prob": 0.35
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
Drop your `.json` file into `src/hw_score_sim/style_packs/`, preview it with `hw-score-gallery`, run `python -m unittest discover -s tests`, and open a PR! See [CONTRIBUTING.md](CONTRIBUTING.md) for the full guide.
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## Runnable Examples
|
|
197
|
+
|
|
198
|
+
Explore the `examples/` directory for end-to-end recipes:
|
|
199
|
+
|
|
200
|
+
- [`examples/01_time_machine_strip.py`](examples/01_time_machine_strip.py) — Render the same musical passage across centuries (Baroque quill → Beethoven sketchbook → 1970s Real Book → modern ballpoint) into a side-by-side comparison strip.
|
|
201
|
+
- [`examples/02_scribe_morph.py`](examples/02_scribe_morph.py) — Morph smoothly between two historical scribes (`interpolate_styles`) to visualize continuous handwriting space.
|
|
202
|
+
- [`examples/03_infinite_omr_dataset.py`](examples/03_infinite_omr_dataset.py) — Build a deterministic, domain-randomized OMR training set with `ScribeSampler`, COCO JSON, and YOLO labels.
|
|
203
|
+
- [`examples/04_custom_scribe_from_json.py`](examples/04_custom_scribe_from_json.py) — Define a custom scribe in a 30-line JSON snippet using `"extends"`, register it at runtime, and render a full page.
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## Documentation
|
|
208
|
+
|
|
209
|
+
- [ARCHITECTURE.md](ARCHITECTURE.md) — End-to-end rendering pipeline, module map, determinism contract, and Ground-Truth Schema v1.0.
|
|
210
|
+
- [CONTRIBUTING.md](CONTRIBUTING.md) — How to author JSON style packs, add new glyph archetypes, and run the test suite.
|
|
211
|
+
- [CHANGELOG.md](CHANGELOG.md) — Release history.
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## License & Citation
|
|
216
|
+
|
|
217
|
+
`hw-score-sim` is released under the **[MIT License](LICENSE)** — free for academic, open-source, and commercial use.
|
|
218
|
+
|
|
219
|
+
If you use `hw-score-sim` in your research or OMR training pipeline, please cite:
|
|
220
|
+
|
|
221
|
+
```bibtex
|
|
222
|
+
@software{eesmaa_hw_score_sim_2026,
|
|
223
|
+
title = {hw-score-sim: Procedural Handwritten Sheet-Music Rendering Engine},
|
|
224
|
+
author = {Gregor Eesmaa and hw-score-sim contributors},
|
|
225
|
+
year = {2026},
|
|
226
|
+
version = {0.1.0},
|
|
227
|
+
license = {MIT},
|
|
228
|
+
url = {https://github.com/gregoreesmaa/hw-score-sim}
|
|
229
|
+
}
|
|
230
|
+
```
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "hw-score-sim"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Procedural handwritten sheet-music rendering engine for MusicXML and MuseScore scores"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { text = "MIT" }
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Gregor Eesmaa" },
|
|
14
|
+
]
|
|
15
|
+
keywords = [
|
|
16
|
+
"music",
|
|
17
|
+
"sheet-music",
|
|
18
|
+
"handwriting",
|
|
19
|
+
"omr",
|
|
20
|
+
"musicxml",
|
|
21
|
+
"musescore",
|
|
22
|
+
"synthetic-data",
|
|
23
|
+
]
|
|
24
|
+
classifiers = [
|
|
25
|
+
"Development Status :: 4 - Beta",
|
|
26
|
+
"Intended Audience :: Developers",
|
|
27
|
+
"Intended Audience :: Science/Research",
|
|
28
|
+
"License :: OSI Approved :: MIT License",
|
|
29
|
+
"Programming Language :: Python :: 3",
|
|
30
|
+
"Programming Language :: Python :: 3.10",
|
|
31
|
+
"Programming Language :: Python :: 3.11",
|
|
32
|
+
"Programming Language :: Python :: 3.12",
|
|
33
|
+
"Topic :: Multimedia :: Graphics",
|
|
34
|
+
"Topic :: Multimedia :: Sound/Audio",
|
|
35
|
+
]
|
|
36
|
+
dependencies = [
|
|
37
|
+
"numpy>=1.24",
|
|
38
|
+
"pillow>=10.0",
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
[project.optional-dependencies]
|
|
42
|
+
dev = [
|
|
43
|
+
"pytest>=7.4",
|
|
44
|
+
"ruff>=0.4",
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
[project.urls]
|
|
48
|
+
Homepage = "https://github.com/gregoreesmaa/hw-score-sim"
|
|
49
|
+
Repository = "https://github.com/gregoreesmaa/hw-score-sim"
|
|
50
|
+
Issues = "https://github.com/gregoreesmaa/hw-score-sim/issues"
|
|
51
|
+
|
|
52
|
+
[project.scripts]
|
|
53
|
+
hw-score-sim = "hw_score_sim.cli:main"
|
|
54
|
+
hw-score-gallery = "hw_score_sim.cli:gallery_main"
|
|
55
|
+
|
|
56
|
+
[tool.setuptools]
|
|
57
|
+
package-dir = { "" = "src" }
|
|
58
|
+
|
|
59
|
+
[tool.setuptools.packages.find]
|
|
60
|
+
where = ["src"]
|
|
61
|
+
|
|
62
|
+
[tool.setuptools.package-data]
|
|
63
|
+
hw_score_sim = ["style_packs/*.json"]
|