Compare commits

...

17 Commits

Author SHA1 Message Date
khodowany 150394d598 Toggle Solos
ci / checks (push) Failing after 24m18s
2026-10-08 22:11:34 -05:00
khodowany 1bacfd0f33 Fix
ci / checks (push) Successful in 53m31s
2026-10-08 20:25:59 -05:00
khodowany 3f63b255ac Fix Playability
ci / checks (push) Failing after 23m26s
2026-10-08 19:04:06 -05:00
khodowany bc7baea7c4 Cleanup
ci / checks (push) Failing after 23m22s
2026-10-08 02:13:45 -05:00
khodowany 300097a37e PDF Render
ci / checks (push) Successful in 52m51s
2026-10-08 00:07:07 -05:00
khodowany 841a3f974e Construction 2026-10-07 23:45:17 -05:00
khodowany 3a01b4b6bd Rhythm Comping Pairs
ci / checks (push) Successful in 56m36s
2026-10-07 20:57:23 -05:00
khodowany a0e13434e4 Rhythm Patterns
ci / checks (push) Successful in 51m14s
2026-10-07 00:22:19 -05:00
khodowany 23b606e47f Rhythm Patterns 2026-10-06 23:55:58 -05:00
khodowany d2f493c17b Playback Mode Pages
ci / checks (push) Successful in 50m29s
2026-10-06 23:11:25 -05:00
khodowany 125aaa1637 Comping Gen 2026-10-06 22:13:50 -05:00
khodowany 2f21ec1f16 Acoustic Comping 2026-10-06 21:50:59 -05:00
khodowany c7f6a30a13 Comping 2026-10-06 21:28:42 -05:00
khodowany e15dc31568 Remove XML Solo Gen
ci / checks (push) Successful in 49m36s
2026-10-06 04:27:29 -05:00
khodowany bb3bba6bbb Fix
ci / checks (push) Successful in 50m4s
2026-10-06 04:05:50 -05:00
khodowany 8423f3d788 Chord Families 2026-10-06 03:18:02 -05:00
khodowany e71385dad1 Chord Families 2026-10-06 02:57:37 -05:00
141 changed files with 38770 additions and 2625 deletions
+21 -12
View File
@@ -11,7 +11,7 @@ The catalog stores shared, immutable menu metadata. Complete score bundles stay
Device controls:
On the Zero, tap menu rows and switches directly; Tempo has minus/plus buttons. The main menu offers **Performance** and **Settings**.
On the Zero, tap menu rows and switches directly; Tempo has minus/plus buttons. The main menu offers **Performance** and **Settings**. **Settings → Solos** switches both guitar parts between written solos (On) and beat slashes for improvisation (Off), including any solo pickup. Chord symbols and the rest of the arrangement stay in place. Solos starts On and remembers your choice until the app restarts; it applies when you next open a part on either device.
On the Pico (and on the Zero while viewing a score):
@@ -100,17 +100,23 @@ Uncompressed MusicXML 3.1/4.0 source scores exported from Soundslice or MuseScor
Six roles generate independently: acoustic accompaniment/solo; electric accompaniment/melody/solo; vocal melody. A process pool and per-role caches support parallel and incremental builds. Each role uses the source and its own inputs without reading another generated role. Canonical accompaniment repeats at corresponding source-form positions and does not react to generated solos. Vocal melody preserves the authored notes and lyrics. Electric melody preserves source pitches and harmonizes eligible sustained notes, reattacking them at chord changes.
Electric accompaniment uses the electric melody's three/four-note voicing families on strings 1–4. Acoustic accompaniment uses one bass note on string 5 or 6 and three upper notes on strings 2, 3 and 4. Its bass can be the root or written fifth, or any triad member for plain major/minor chords; an explicit slash bass or inversion takes priority. Each instrument selects a connected voicing path across the source form to reduce hand movement, then reuses it through the arrangement.
Electric accompaniment and electric melody share compact chord families on strings 1–4. Melody harmonization adapts these to keep the original melody on the lowest-numbered feasible string, preferring it above the added chord tones. The separate Electric Solo stays monophonic. Acoustic accompaniment uses one bass note on string 5 or 6 and three upper notes on strings 2, 3 and 4. Transposable degree families cover triads, sevenths/sixths, suspensions, diminished/augmented and extended/altered chords, with root/fifth bass alternatives on both bass strings. Plain major/minor chords also allow third basses; explicit slash basses and inversions take priority. Unplayable variants are discarded. Each instrument selects a connected voicing path across the source form to reduce hand movement, then reuses it through the arrangement.
Accompaniment rhythm is light at every tempo: normally 0–2 electric chord attacks, 1–2 acoustic bass attacks, and 1–3 acoustic upper-chord attacks per full measure. Bass attacks beat one wherever harmony is available. Stabs, sustains and space follow the original melody and harmonic rhythm. Separate acoustic voices allow bass and upper notes to overlap; their combined attacks are evaluated for crowding. An extra attack is permitted only for harmonic changes and reported. Compatible holds can tie across barlines. The selected accompaniment repeats at corresponding form positions, with source-defined pickup/handoff exceptions, and does not change when only tempo changes.
Accompaniment uses independently authored two-bar jazz pattern families, chosen against each song's original melody and harmonic rhythm. Acoustic repeats two patterns (A–B); electric repeats four (A–B–C–D). Occasional source-phrase-ending fills recur at the same positions in every iteration; both instruments allow at most one per eight full measures, including the repeat join. Acoustic normally has 1–3 attack positions per full bar with quarter/eighth bass and upper-chord notes played together or in sequential pairs. Electric has distinct patterns with normally 0–2 attacks per bar, stabs, sustains and space. Cross-bar holds use ties; repeated attacks remain attacks. Pattern phase follows source-form position, including partial entries and odd-length forms. Meter changes use compatible cycles, with explicit diagnostics if fewer distinct patterns are available. Tempo changes do not reshuffle the accompaniment.
Each instrument has 24 distinct two-bar patterns in 4/4, 24 in 3/4, and 24 for each of the 3+2 and 2+3 groupings in 5/4. Written additive grouping takes precedence. Otherwise, the original chord changes and melody choose one consistent 5/4 grouping per continuous meter section, shared as source analysis by the independently generated parts. Explicit meter matching prevents treating 6/8 as 3/4. The learned solo model and playback count-in are unchanged by this accompaniment expansion.
Both accompaniment parts balance movement with sounding register and a soft cost for mean fret positions above nine; comfortable shifts can win over staying high. Acoustic uses a register center of MIDI 53 and electric uses 60. Compact spans and preferred chord families remain higher priorities, including for the final sustained chord. Electric melody's supporting chords use the same balance after the existing melody-string and foreground priorities; the original melody pitches and rhythm remain fixed. Voicing preferences do not reseed accompaniment rhythms.
Acoustic attacks normally play bass and upper chord together. Consecutive attacks exactly an eighth note apart split into bass–upper pairs within the same harmony; an odd leftover attack plays both together. Pairing continues across barlines and two-bar pattern boundaries, but stops at chord changes, chorus boundaries and source-defined entries/handoffs. The first attack for each new chord therefore includes bass, including a qualified anticipated entrance. Delayed entrances remain delayed. Every new acoustic attack releases the previous sound: a bass eighth followed by an upper-chord quarter has no bass underneath the quarter. Complete-cycle selection, fills and final realization use this same release rule. Bass and upper notes share one engraved part; uninterrupted holds may still tie across barlines.
Each song has six canonical roles: electric melody, electric accompaniment, electric solo, acoustic accompaniment, acoustic solo, and vocal melody. Matching source-form positions reuse the same musical events and TAB whenever a role returns. Final-turnaround omission changes only affected harmony; source-defined pickups/handoffs and the three-bar instrumental closing sustain remain explicit exceptions.
**Registered Solo 1 is notated exactly in the acoustic part and Solo 2 exactly in the electric part.** Unregistered song/slot pairs use deterministic prediction from one pooled statistical model trained on both slots. There is no learned acoustic/electric style distinction. Prediction uses up to four recent pitch/rhythm events, source-melody features, harmony, and metrical position; it does not plan complete themes or guarantee long-range phrase development. The current corpus is four authored solos from Autumn Leaves and All of Me.
Training, authored score reuse, and prediction share contextual harmony validation based on actual notes, timing, and chords. Explanatory labels and justification tags are not required. Unsupported relationships fail with a diagnostic rather than silently changing notes. Both solo roles use strings 1–6 and frets 1–12 without open strings. No dynamics, accents, velocity shaping, or random timing are added.
`--export-solo-xml` (CMake `VAMP_EXPORT_SOLO_XML=ON`) writes `solo_xml/*-solo1.xml` for acoustic and `*-solo2.xml` for electric under the generated asset directory, with actual notes and TAB. These exports do not recompose music. `./modulus.py python -m generator.compose --song ... --role acoustic_solo --data-dir data --output ... --solo-xml ...` builds one independent role. To exercise prediction for a registered song, pass `--settings` with a JSON file containing `{"predict": true}`.
Optional comparison runs through `./modulus.py python -m tests.solo_compare`. Point `--generated-dir` at the exported `solo_xml/` directory and supply explicit `--reference SONG/ROLE=PATH`, `--form-start SONG/ROLE=MEASURE`, `--reference-pitch guitar-written`, and `--output /tmp/product-vamp-solo-review`. Keys match `manifest.solo`, such as `all_of_me/acoustic`. Add `--require-exact` to fail on sounding-note or rest differences, or `--baseline-dir` to compare an earlier MusicXML export. Comparison results never feed production; registered authored playback and explicit training use the paired solos separately. The supplied solos sound one octave below encoded pitches; All of Me aligns at measure 1 and Autumn Leaves at measure 2, preserving the lead-in. Matching notes or technical validity do not establish musical preference.
`./modulus.py python -m generator.compose --song ... --role acoustic_solo --data-dir data --output ...` builds one independent role as JSON. To exercise prediction for a registered song, pass `--settings` with a JSON file containing `{"predict": true}`. Each song produces five score bundles: the normal acoustic, electric and vocal parts, plus acoustic and electric `_improv` variants. The variants reuse the same accompaniment and melody, replacing the full solo allocation (including pickup rests) with meter-aware slashes in notation and TAB. Their subtitles identify them as Improvisation. Normal scores retain written solos; separate solo MusicXML files are not generated. Authored XMLs remain under `data/training`, and regression tests compare their sounding events directly with generated score data.
See [Shared Part Generation](TECHNICAL_GUIDE.md#shared-part-generation) and [Authored Repertoire and Learned Solos](TECHNICAL_GUIDE.md#authored-repertoire-and-learned-solos) for the active pipeline and limitations. Keep temporary comparisons and one-off diagnostics under `/tmp/`; `build/` retains product outputs, tools and dependencies.
@@ -136,25 +142,25 @@ Add a source and its authored solo, then retrain the pooled model, without chang
To retrain existing pairs, run `./modulus.py python -m generator.train`; add `--leave-one-song-out` for held-out likelihood diagnostics. Training writes `data/models/solo.json` and `build/training/report.json`. Ordinary builds use registered authored music or the saved model and never retrain automatically. Exact registered playback verifies authored reuse; it does not demonstrate model memorization or musical quality on unfamiliar songs. [Training and playback details](TECHNICAL_GUIDE.md#authored-repertoire-and-learned-solos) cover pairing, timing, pitch convention, data migration, and limitations.
The build-time pipeline is MusicXML -> source analysis -> independent roles -> assembled parts -> semantic JSON, supplied recordings, engraved PNG pages, Pico title artwork, and a read-only catalog database. Each source produces the six-section performance form as Acoustic, Electric, and Vocal parts in its authored key, without key variants or a key-selection menu. Performance measure numbers run continuously across the complete arrangement, starting at 1 in the lead-in; they do not restart with a new section or chorus. Pickups occupy the preceding measure. Standalone comparison XMLs use local measure numbers and retain the original arrangement numbers in `manifest.solo`.
The build-time pipeline is MusicXML -> source analysis -> independent roles -> assembled parts -> semantic JSON, supplied recordings, engraved PNG pages, Pico title artwork, and a read-only catalog database. Each source produces the six main performance sections plus the held Ending as Acoustic, Electric, and Vocal parts in its authored key, without key variants or a key-selection menu. Performance measure numbers run continuously across the complete arrangement, starting at 1 in the lead-in; they do not restart with a new section or chorus. Pickups occupy the preceding measure.
All generated monophonic guitar material uses frets 1–12 without open strings. Accompaniment uses all legal compact positions; a chord can extend to fret 20 while retaining at least one sounding anchor at fret 12 or below and the existing three-fret span restriction. Electric source-melody harmonization retains its separate placement and chord-change reattack policy. Import preserves exact source pitches and ties; unplayable or unsupported input fails explicitly rather than being silently octave-folded.
All generated monophonic guitar material uses frets 1–12 without open strings. Chords use two span tiers: **one to three consecutive fret positions share the primary tier; exactly four positions are a fallback** (e.g. 7–9 is primary, 7–10 is fallback). Five or more positions are forbidden. Selection minimizes fallback use before family, melody-string, movement or register preferences. A chord can extend to fret 20 while retaining at least one sounding anchor on frets 1–12 throughout its duration. Acoustic bass remains within frets 1–12 and upper chords need their own anchor when played separately. Some chord/key combinations still have no legal inversion; generation reports them instead of removing required tones. Electric source-melody harmonization retains its chord-change reattack policy. Import preserves exact source pitches and ties; unplayable or unsupported input fails explicitly rather than being silently octave-folded.
There are no genre presets or runtime composition. The complete arranged score is played in reading order. The source-defined form and continuous whole-arrangement measure numbering remain unchanged.
All parts use two music systems per page, with a single system only when the score ends on an odd system. Lines break only between measures and share consistent staff/TAB widths. A measure that cannot fit at readable spacing fails with a diagnostic instead of being split. Tall notation is scaled uniformly to fit the two rows; guitar notation and TAB stay together and aligned. TAB displays frets and ties without duplicate rests; standard notation retains the complete rhythm. The generated `.pages/*.png` files are the same page images displayed by the product.
Normal browsing uses two music systems per page, with a single system only when the score ends on an odd system. Playback uses overlapping pairs (1–2, 2–3, 3–4): each new active line moves to the top, revealing the next below. The final line moves to the top with an empty lower half. Measure numbers sit above their starting barlines in a clear lane; playback outlines the active measure number in the accent color. Lines break only between measures and share consistent staff/TAB widths. A measure that cannot fit at readable spacing fails with a diagnostic instead of being split. Tall notation is scaled uniformly to fit the two rows; guitar notation and TAB stay together and aligned. TAB displays frets and ties without duplicate rests; standard notation retains the complete rhythm. The generated `.pages/*.png` files are the same page images displayed by the product.
Write all music in reading order: repeat bars, numbered endings, navigation jumps, and pass-specific ties are rejected. The six-section performance arrangements remain fully written out. Chord labels use `M`, `m`, `aug`, `dim`, `sus`, and `mM7`, including explicit major triads such as `CM`. Recognized Soundslice text-only harmonies are normalized into structured chords; parenthesized chords mark optional turnarounds omitted from the final vocal pass.
Write all music in reading order: repeat bars, numbered endings, navigation jumps, and pass-specific ties are rejected. The performance arrangements, including the held Ending, remain fully written out. Chord labels use `M`, `m`, `aug`, `dim`, `sus`, and `mM7`, including explicit major triads such as `CM`. Recognized Soundslice text-only harmonies are normalized into structured chords; parenthesized chords mark optional turnarounds omitted from the final vocal pass.
Settings provides independent **Metronome** and **Backing** toggles, both off by default, plus **Tempo**. Song -> Part -> Score navigation stays the same. With both toggles off, pages turn manually. With either enabled, opening a part starts a one-bar count-in and an automatic performance; tap/double-tap page commands are ignored, and hold exits to the part menu. Natural completion also returns there.
A performance is an eight-bar intro followed by five complete passes: Vocal Melody, Guitar Melody, Acoustic Solo, Electric Solo, and Vocal Melody. There is no separate Ending section. The current 32-bar songs contain 168 numbered bars. Optional turnaround chords are omitted from the final vocal pass.
A performance is an eight-bar intro followed by five complete passes: Vocal Melody, Guitar Melody, Acoustic Solo, Electric Solo, and Vocal Melody. A final Ending section adds one guitar chord attack sustained across three full measures, with vocal rests. The current 32-bar songs contain 171 numbered bars. The ending holds the final performed harmony (GM6 for All of Me, Dm for Autumn Leaves). Optional turnaround chords are omitted from the final vocal pass.
Audio comes exclusively from supplied WAV files: `package/assets/sounds/beat1.wav` accents each measure's first beat, and `beat2.wav` plays its other beats. Backing tracks belong in `package/assets/backing/<song_id>_<bpm>.wav`, for example `all_of_me_120.wav`. The normalized song ID comes from the source filename. Files are copied unchanged; the app never synthesizes notes or stretches recordings.
Tempo choices are 60, 70, 80, 90, 100, 110, and 120 BPM. With Backing on, choices are the tempos available for every catalog song; currently that is 120 BPM. Enabling Backing selects the closest available tempo, preferring the slower choice on a tie. If no tempo is shared, Backing is unavailable. Add recordings at the other tempos and rebuild to enable them.
Backing recordings include one bar of count-in, the complete score, and the held ending with decay. The recorded count-in plays alone. When both toggles are on, metronome clicks start at the score and stop at its end, leaving the last three held bars and decay unclicked. Metronome-only mode supplies its own count-in and stops at score end. Pages follow the rendered audio clock, using each engraved page's actual measure range; the final page stays visible through the backing tail.
Backing recordings include one bar of count-in, the complete arrangement including its three-bar held ending, and decay. The existing WAVs are copied unchanged. The recorded count-in plays alone. Metronome clicks stop at the start of the written Ending section; those three measures and the decay remain unclicked. Metronome-only mode supplies its own count-in, waits silently through the ending, and then stops. Playback line turns and measure highlighting follow the rendered audio clock through all 171 measures, including rests and ties; the final line stays visible through the recording decay. Preparation and count-in have no highlighted measure.
Code style is managed by Modulus, using compact two-space formatting. Python imports modules by their full names and qualifies imported symbols; only `from __future__ import annotations` is exempt, and imports have no aliases. Run `./modulus.py format` to format C++ and Python, or `./modulus.py format --check` to check formatting and prohibited aliases. The project-local Neovim integration routes Conform formatting through the same container tools, including format on save and existing LazyVim toggles. Run configure first when the image or exported tooling needs updating. Use `tooling.editor.clang_format` for C++ overrides and `tooling.format.exclude` for project-relative exclusion globs; do not edit generated `.clang-format` files.
@@ -164,6 +170,8 @@ See [Score Generation](TECHNICAL_GUIDE.md#score-generation) for supported MusicX
Build-time engraving is implemented in Python in `generator/engraving`, using the bundled Petaluma OTF fonts and SMuFL metadata. MuseScore is an optional authoring tool, not a build dependency or rendering backend. Configure installs the optional Modulus asset dependencies. Exact musical timing is retained through layout, with line breaks between complete measures. Missing glyphs, unrepresentable page geometry, and failed notation audits stop generation before replacing existing assets.
Every normal build also writes printable PDFs to `build/<target>/generated_assets/print/`: written-solo and improvisation versions of each acoustic and electric part, plus one vocal part per song, including every arranged iteration and the ending. Print at actual size on portrait US Letter paper. Pages have white backgrounds, black notation, at least half-inch printer margins, and multiple systems per sheet; guitar parts include TAB. These are fresh 300 DPI renders, without the duplicated lines used by playback transition pages. PDFs use the existing Modulus-managed Pillow dependency, are cached separately, and remain build-only artifacts rather than being installed on the device.
`generator/palette.json` preserves the sheet music’s existing dark palette across Zero, Pico, score pages, and previews. Menus use the same Petaluma Script lettering, quiet rules, tune/composer hierarchy and restrained accent colors for a jazz Real Book feel. Performance status shows Count-in, Playing or Sustain, BPM, page progress and a hold-to-exit hint. CMake generates the shared C++ colors from the same palette used by Python. Palette changes invalidate the engraving cache without changing music, spacing, or pagination.
Petaluma is from Steinberg under the SIL Open Font License. Petaluma supplies music glyphs, and Petaluma Script supplies all visible text on score pages and both device interfaces. The Zero uses packaged `PetalumaScript.otf` for dynamic UI text; the Pico displays prerendered Petaluma Script artwork. Runtime packages retain `OFL.txt`; the music font and engraver stay build-only.
@@ -181,3 +189,4 @@ To inspect the fixed artwork independently, run `./modulus.py python -m generato
## License
Product Vamp is released under the MIT License. Bundled third-party fonts keep their own licenses next to the font files.
+2 -2
View File
@@ -59,6 +59,6 @@ Controls:
- Double tap: previous menu item, or previous page when both audio toggles are off.
- Tap and hold: select the highlighted menu row, enter/leave tempo editing, or return from score view to the part menu. While editing tempo, tap increases BPM and double tap decreases it.
Settings has independent Metronome and Backing toggles. Either starts automatic playback when a part opens; both off enables manual reading. Backing plays the recorded count-in and held ending. Metronome clicks accompany the score but stop before the three-bar held tail. Hold exits at any time.
Settings has independent Metronome and Backing toggles. Either starts automatic playback when a part opens; both off enables manual reading. Backing plays the recorded count-in and held ending. Metronome clicks stop at the written three-bar Ending section; page timing continues through the hold. Hold exits at any time.
Keep the two metronome samples under `package/assets/sounds/`. Put song recordings under `package/assets/backing/`, named `<normalized_song_id>_<bpm>.wav`. Supply separate files at 60, 70, 80, 90, 100, 110 and 120 BPM, each with one bar of count-in, the complete eight-bar intro plus five body passes, and its held ending. Rebuild/package after adding recordings. Backing tempo choices include only tempos supplied for every song; the current package has 120 BPM for both songs.
Keep the two metronome samples under `package/assets/sounds/`. Put song recordings under `package/assets/backing/`, named `<normalized_song_id>_<bpm>.wav`. Supply separate files at 60, 70, 80, 90, 100, 110 and 120 BPM, each with one bar of count-in, the complete eight-bar intro plus five body passes, and its three-bar held ending plus decay (171 written bars for the current songs). Rebuild/package after adding recordings. Backing tempo choices include only tempos supplied for every song; the current package has 120 BPM for both songs.
+119 -20
View File
@@ -37,9 +37,9 @@ The AP setup pins NetworkManager to 2.4 GHz channel 6 with WPA2/RSN and CCMP cip
On Raspberry Pi OS Lite, the installed display service owns `tty1`, conflicts with `getty@tty1.service`, and starts the Zero container through `product_vamp_start_zero`. The wrapper switches to the display VT when `chvt` is available and runs `vamp_zero` inside the container through `setsid --wait --ctty` with `/dev/tty1` as stdin, giving raylib's DRM backend a real virtual terminal while keeping Docker attached to the long-running display process. SSH remains the normal admin path and `tty2` is enabled as the fallback local console.
At startup the Zero validates the packaged `catalog.db` application identifier and required table structure, opens it read-only through Noto, and loads menu metadata. It never creates or migrates a database, scans score JSON, or repairs metadata. The main menu contains Performance and Settings. Settings holds Backing, Metronome, and Tempo; its values apply for the current session. Song -> Part -> Score navigation offers Acoustic, Electric, and Vocal without key selection. Musical interpretation, spacing, beaming, ties, accidentals, and pagination happen on the build host. The Zero displays engraved PNGs and retains at most two page textures.
At startup the Zero validates the packaged `catalog.db` application identifier and required table structure, opens it read-only through Noto, and loads menu metadata. It never creates or migrates a database, scans score JSON, or repairs metadata. The main menu contains Performance and Settings. Settings holds Backing, Metronome, Solos, and Tempo; its values apply for the current session. Song -> Part -> Score navigation offers Acoustic, Electric, and Vocal without key selection. Musical interpretation, spacing, beaming, ties, accidentals, and pagination happen on the build host. The Zero displays engraved PNGs and retains at most two page textures.
Runtime catalogs contain immutable metadata shared by navigation, the HTTP service, and the UI. Song groups reference canonical records by index. SQLite retains complete bundles, while cached measure/page counts let menu queries avoid reading musical JSON. Python constructs the complete database in one transaction before deployment; metadata and embedded JSON are published together after an integrity check. The `songs` table uses strict column types, primary-key and path uniqueness constraints, and JSON validity checks. Menu rows are ordered by title, composer, part, and ID with binary collation, using the matching `songs_menu` index; C++ groups the ordered rows in one pass without sorting them again. Noto provides read-only connections, bound score lookups, application-ID checks, and quick integrity checks. Product-specific schema and asset-path validation remain in the application. There are no custom rows, runtime imports, metadata-repair triggers, or persisted page-state tables. Selecting a score loads only that bundle asynchronously, discarding stale results after navigation; the view keeps at most two page textures.
Runtime catalogs contain immutable metadata shared by navigation, the HTTP service, and the UI. Song groups reference canonical records by index. SQLite retains complete bundles, while cached measure/page counts let menu queries avoid reading musical JSON. Python constructs the complete database in one transaction before deployment; metadata and embedded JSON are published together after an integrity check. The `songs` table includes a required integer `solos_enabled` flag (0 or 1), matching the boolean in music metadata. Catalog generation and startup validate paired variants for arranged guitar parts and a single shared Vocal. This schema requires rebuilt assets and updated Zero/Pico software; runtime migration is not supported. The `songs` table uses strict column types, primary-key and path uniqueness constraints, and JSON validity checks. Menu rows are ordered by title, composer, part, and ID with binary collation, using the matching `songs_menu` index; C++ groups the ordered rows in one pass without sorting them again. Noto provides read-only connections, bound score lookups, application-ID checks, and quick integrity checks. Product-specific schema and asset-path validation remain in the application. There are no custom rows, runtime imports, metadata-repair triggers, or persisted page-state tables. Selecting a score loads only that bundle asynchronously, discarding stale results after navigation; the view keeps at most two page textures.
`--once` (also `runtime.exit_after_startup`) is a headless readiness check: it checks database integrity and validates the catalog and referenced page assets, checks runtime-directory writes and the configured server bind, and exits without opening audio/display devices or publishing a readiness heartbeat. Page checks include containment, checksums, CPU-only PNG decoding, and exact 976x484 dimensions. The configured heartbeat destination must be absent or a regular file, never a directory, symlink, or special file. Runtime writes and readiness probes use exclusive sibling temporary files; readiness leaves an existing heartbeat unchanged and removes its probes. `--health-check` instead probes the running service's read-only `/api/health` endpoint using the configured timeout. A stopped/unresponsive service or an invalid response fails the check; it does not create or repair files. `--check-config` remains configuration-only.
@@ -49,16 +49,26 @@ The Zero menus use direct taps: release on a row to select it, tap switches to t
In score view, Zero and Pico share one gesture state machine: a second release within 220 ms of the first release produces previous, a hold of at least 700 ms produces select once, and other taps produce next. A late second release preserves both single taps; holding consumes a pending first tap. Zero schedules pending-tap deadlines without polling and discards canceled or obsolete timer callbacks.
Score loading uses a dedicated single-worker executor for SQLite reads and JSON parsing. Completion returns to the control executor. The loader retains one in-flight request, coalesces pending selections, and discards stale results, keeping database work off HTTP and playback polling.
## Score Generation
The build runs `./modulus.py python -m generator` against `data/` and writes build-only assets under the CMake binary tree. Every song produces acoustic, electric, and vocal parts in its authored musical key. Source counts are discovered, not fixed in code. Generator-only optional chord markers are consumed before publishing.
Songs live directly in `data/songs/`. Each source produces acoustic, electric, and vocal parts under `songs/`, with matching page directories. Adding, renaming, or removing a source requires no registry edit. Regeneration replaces the output tree and catalog. The two current songs generate six parts.
Songs live directly in `data/songs/`. Each source produces acoustic, electric, and vocal parts under `songs/`, with matching page directories. Adding, renaming, or removing a source requires no registry edit. Regeneration replaces the output tree and catalog. Each song generates five bundles: the usual three parts and acoustic/electric `_improv` alternatives. The two current songs generate ten bundles. Solos defaults to On at each app start; Off selects the improvisation guitar variants while Vocal is shared. Part menus retain three rows, using the selected variant’s normal and playback page counts. Pico status includes `solos=0/1`.
The pipeline is Soundslice/MuseScore -> uncompressed `.xml` -> musical model and rhythm plans -> part generation -> semantic JSON, supplied WAVs, engraved pages, and Pico title artwork -> packaged SQLite catalog and assets. Export MusicXML 3.1 or 4.0, `score-partwise`, with one part and one staff. The musical model retains independent voices and per-tone durations/ties. Packaged music describes each generated part, not an archival copy of the XML.
### Musical Data
Generator dependencies run from pure musical values and source analysis toward composition, assembly, and publication. `model` contains primitive values; `validation` checks score documents; `score` contains pure score operations; and `score_io` owns bundle/file validation. `source` owns canonical source identity and immutable source events. `arrange.form.FormPlan` supplies source-derived sections, ownership windows, and pickup stops to both accompaniment and role assembly.
`composition` generates one role from an explicit immutable `vocabulary.CompositionContext`; `production` schedules typed worker requests and publishes the assembled parts. Lower musical functions receive that context explicitly. The scoped vocabulary API remains available for standalone callers and tests. Cached vocabulary loads return owned copies so one caller cannot alter another caller's resources.
Role cache identities include the transitive generator imports of the composition entrypoint. Engraving cache identities similarly include renderer dependencies. Cache identities never seed musical choices. `cache` provides shared content identity and staged-file publication mechanics, while role, PNG, and PDF adapters retain their own validation. `engraving.worker` owns rendering and its bounded image cache; `engraving.pipeline` groups and schedules work. `performance` contains pure timing contracts, and `audio_assets` validates and copies supplied recordings.
The reviewed output contract is checked by `tests.test_output_contract` for complete synthetic role scores, including learned solos, and by `python -m tests.asset_contract <generated-assets-directory>` for every non-diagnostic asset. CTest runs the asset check against the normal build output. Musical output, JSON/catalog serialization, PNGs, and PDFs must remain unchanged during structural refactors; diagnostic text and cache identities may change.
`data/songs/` contains authoritative source scores. `data/training/manifest.json` pairs each authored solo with a source and a slot (1 or 2), and declares its pitch convention. Both slots train **one pooled model**. Slot 1 maps to acoustic playback and slot 2 to electric playback; slot and instrument names are not model features. The four XML files retain their notes, harmony, timing, ties, rests, Autumn Leaves pickup and All of Me's full-bar opening. Explanatory labels such as `Lead in`, `b9` and `6` were removed; they were not model features. Written chord extensions remain intact.
`data/models/solo.json` is an explicitly trained, versioned statistical model. Its short-context counts, rhythm and register statistics are learned from the paired examples. Provenance records input hashes and the training version. This is supervised use of the supplied solos, not independence from them and not a neural network pretrained on an external corpus.
@@ -97,11 +107,13 @@ Parenthesized chord symbols mark optional turnarounds, including Soundslice's te
### Linear Reading Order
There is no repeat analyzer, expansion pass, or repeat/ending engraver. Performance writes an eight-bar intro and five full passes (vocal, guitar melody, acoustic solo, electric solo, vocal) explicitly onto successive pages; neither display nor playback jumps backward.
There is no repeat analyzer, expansion pass, or repeat/ending engraver. Performance writes an eight-bar intro and five full passes (vocal, guitar melody, acoustic solo, electric solo, vocal), followed by three held ending measures, explicitly onto successive pages; neither display nor playback jumps backward.
Repeat signs, numbered endings, D.C./D.S./coda navigation, and `time-only` ties fail import rather than being ignored or expanded. Write the intended notes and rests explicitly, including any alternate ending. Legacy repeat fields in generated musical documents are rejected; regenerate assets instead of retaining a compatibility interpreter. Full leading-rest measures remain full measures, not inferred pickups. Missing titles fall back to readable, spaced filename titles and missing composer credits remain empty, as with the current Soundslice exports.
An explicitly marked opening pickup is excluded from the repeated song body. At each vocal or electric melody entry, it is right-aligned within the preceding arrangement bar. Outgoing music continues until the pickup's first sounding note, then releases as the incoming melody takes over; pickup rests do not erase earlier accompaniment. Lyrics, ties into the following downbeat, tuplets, and octave spans retain their timing. Pickup harmony changes also apply to the accompanying parts at their relocated offsets. All parts share the same bar count, and a pickup longer than its destination bar fails generation. Autumn Leaves uses a four-beat padded pickup and a 32-bar body, yielding 168 arrangement bars, including the eight-bar intro.
An explicitly marked opening pickup is excluded from the repeated song body. At each vocal or electric melody entry, it is right-aligned within the preceding arrangement bar. Outgoing music continues until the pickup's first sounding note, then releases as the incoming melody takes over; pickup rests do not erase earlier accompaniment. Lyrics, ties into the following downbeat, tuplets, and octave spans retain their timing. Pickup harmony changes also apply to the accompanying parts at their relocated offsets. All parts share the same bar count, and a pickup longer than its destination bar fails generation. Autumn Leaves uses a four-beat padded pickup and a 32-bar body, yielding 171 arrangement bars: the eight-bar intro, five 32-bar passes, and three written held-ending measures.
Improvisation assembly reuses the independent accompaniment and melody roles and fills each source-defined solo window with regular beat slashes. The complete pickup allocation also becomes slashes, including rests within that allocation; music before a partial pickup and subsequent melody handoffs are preserved. Slash events carry no pitches or fret positions, and render in both the staff and TAB. This does not rerun solo composition or change backing recordings, measure numbering, harmony, or performance duration. Both variants receive normal/playback pages and build-only printable PDFs.
Ordinary ties still link adjacent matching tones across measures and systems. Tuplets, independent voices, local staff changes, and manual page navigation are unchanged. The recording’s three-bar sustain tail has no added score section or metronome clicks.
@@ -123,17 +135,80 @@ Measure durations, event onsets/durations, harmony offsets, span times, and pitc
`parts.py` retains exact source notes, rests, lyrics and ties. `melody.py` harmonizes eligible sustained electric source-melody notes using their actual chord, preserving source pitches while splitting and reattacking held notes at harmony changes. Guitar notation applies its octave transposition once. `comping.Canonical` independently chooses compact chord voicings and rhythm from the source form and shared policy, then reuses that part at the same source-form position throughout the arrangement. There is no generated-solo response or reuse of a generated melody's grips. Sparse bars and deliberate releases are legal.
Electric accompaniment shares the electric melody's `guitar.chord_positions(..., profile='electric')` families: strings 1–3 or 1–4, with a preference for four-note grips. It uses the same written chord requirements without taking responsibility for the slash bass. Acoustic accompaniment uses `acoustic_voicing.candidates`: exactly one bass on string 5/6 and one upper note each on strings 4/3/2. Without an explicit slash bass or inversion, its bass is a root or written fifth (including an altered fifth); plain major/minor triads also permit the third. Plain triads retain all three chord members. Explicit bass/inversion requirements override this choice. Unsupported grips fail with the source measure, beat and chord rather than weakening the layout or harmonic requirements.
Electric accompaniment shares the electric melody's `guitar.chord_positions(..., profile='electric')` families: strings 1–3 or 1–4, with a preference for four-note grips. `chord_families.py` classifies actual shapes as drop-two, close-position, compact-open, compact-doubled or three-note shells, ranked by versioned policy. Electric melody chords must also use strings 1–3 or 1–4, always including string 1. The exact source pitch is retained even when a legal supporting chord tone must sound above it. Within the selected span tier, the melody's lowest feasible string number and foreground position precede chord size. A primary grip with the melody on string 2 beats a four-fret grip with it on string 1. Short monophonic melody notes and solos use the shared hand-window placement objective. A harmonization with no legal chord retains the existing reported single-note fallback. These electric roles use the same written chord requirements without taking responsibility for the slash bass. Acoustic accompaniment uses `acoustic_voicing.candidates`: exactly one bass on string 5/6 and one upper note each on strings 4/3/2. Without an explicit slash bass or inversion, its bass is a root or written fifth (including an altered fifth); plain major/minor triads also permit the third. Plain triads retain all three chord members. Explicit bass/inversion requirements override this choice.
The active voicing selector compares complete paths with dynamic programming over concrete grips. Electric costs prioritize the shared melody family's string count, then grip effort plus hand-center travel, missing optional tones and register preference. Acoustic costs prioritize travel of the bass and all three upper voices, then optional-tone coverage and register preference. Stable role-specific keys resolve equal costs. Silent spans retain the preceding hand position. A continuous accompaniment repeat includes the last-to-first transition. Source-harmony variants, such as relocated pickup harmony, are solved between fixed canonical neighbors without mutating a shared previous-grip state; request order cannot change them. Per-span composition reports include candidate counts, selected string/fret positions, bass degree and movement.
Acoustic families are transposable degree orders for triads, tetrads and extended chords, with root/fifth alternatives on both bass strings. Slots resolve to the written third/suspension, sixth/seventh, fifth and extension, including alterations and omissions. They are not per-song grip tables. Only harmonically and physically valid realizations enter selection; unavailable bass/inversion variants are discarded. Coverage checks exercise 35 common qualities in all 12 keys. Four-fret fallbacks support previously unavailable acoustic Bb9, BbM9, Bb7#9 and Bb6add9; for example, Bb9 uses fifth-bass frets 8/10/7/9 on strings 5/4/3/2. Acoustic Bbm9 and Bm9 still have no grip meeting all constraints. Unsupported chords fail with source measure, beat and chord rather than silently omitting defining tones.
`comping_rhythm.py` constructs whole-measure rhythms from version 2 of `composition/accompaniment.json`. Normal full-measure ranges are 0–2 electric chord attacks, 1–2 acoustic bass attacks and 1–3 acoustic upper-chord attacks. Bass starts on beat one whenever harmony is available there. An absent harmony or N.C. remains silent. Candidates mix half-beat stabs, quarters, longer holds and alternating durations. Exact chord offsets constrain sounding intervals; short partial bars have bounded gestures. Rapid harmonic changes can authorize one extra attack per layer, recorded as an exception, without assigning a fresh density budget to every chord.
The active voicing selector compares complete paths with dynamic programming over concrete grips. The leading cost minimizes four-fret grip selections: every span of one, two or three positions has zero cost in this tier. Existing criteria then apply within the tier. Electric accompaniment prioritizes chord size and shared family rank; acoustic prefers declared degree-order families on either bass string. Both then minimize hand-window travel, the passage maximum hand position, secondary finger/grip effort, missing optional tones and sounding-register distance, in that order. Stable role-specific keys resolve equal costs. Since accompaniment transitions have travel costs but no hard travel cutoff, four-fret candidates are safely removed from a span when any primary grip exists; this exact dominance reduction keeps the repeat search small. Electric placement retains distinct alternatives where future held/tied notes can constrain feasibility, and does not charge tied continuations as fresh grip choices. The remaining acoustic placement helper uses the same leading fallback tier.
The original head supplies entrances, moving-note intervals and space; the actual progression supplies harmonic support requirements and release boundaries. Candidates retain distinct attack counts and articulation families before the cutoff. Acoustic bass/upper candidates are paired and scored for combined crowding, counting coincident attacks as one action. A bounded dynamic program selects the form's complete rhythm path using source-context costs and preferences against immediate whole-bar repetition. This chooses from retained candidates, not every possible rhythm. Compatible sustained neighbors with identical harmony and grip can then join across a barline without reattack; the upper layer retains at least one new attack per bar and bass always reattacks. Changing only tempo leaves these musical decisions unchanged. Tempo remains in the concrete asset cache key so score metadata refreshes correctly.
Silent spans retain the preceding hand position. A continuous accompaniment repeat includes the last-to-first transition. Source-harmony variants, such as relocated pickup harmony, are solved between fixed canonical neighbors without mutating a shared previous-grip state; request order cannot change them. Per-span composition reports include candidate counts, selected family, bass/string family availability, selected positions, bass degree and movement, plus `fret_span`, `span_group` and `span_candidates` (primary/fallback counts before dominance reduction). These are diagnostic sidecar fields; the score/runtime format is unchanged.
Acoustic bass and upper events retain independent voice lanes through assembly and notation, so either layer may sustain under another attack. Validation also checks the combined sounding grip across those voices. The product build audits canonical accompaniment reuse across arrangement iterations, allowing only source-derived changes in harmony, pickups and role handoffs. The `.roles` sidecars report per-measure families, attack counts, overlaps, ties and exceptions. Their `selection_cost` records local rhythm-candidate contributions before cross-bar joining; the form selector also applies the documented transition cost. Solos retain their existing learned source-melody/harmony conditioning and registered exact performances.
`comping_rhythm.py` selects recurring source-only figures from version 6 of `composition/accompaniment.json`. The normal acoustic cycle has two two-bar slots; electric has four. Each template and anticipation mode is evaluated at every occurrence of its slot before retrieval limits apply. Up to eight diverse candidates per slot enter bounded complete-cycle comparison. Distinct slots differ in attack/duration relationships, not just IDs, bass/upper assignments or anticipation flags. Repetition is not penalized. The source melody and harmonic rhythm affect selection; title, iteration, generated solo and tempo do not. `groove_cycles` reports slot identities, anticipation modes, aggregate cost, compared cycles and any reduction caused by vocabulary or form length.
Monophonic solos use strings 1–6 and frets 1–12, with no open strings or acoustic/electric string restrictions. Placement compares complete paths through legal positions, accounting for hand-region changes, travel time and string crossings. Ties retain their position. Chord placement retains its separate policy: frets 1–20 with a sounding anchor at fret 12 or below and the existing inclusive three-fret span. Acoustic accompaniment additionally keeps its bass within frets 1–12 and requires an independent anchor in its upper three-note cluster, preserving the option of separate bass/upper attacks. These costs approximate physical feasibility; they do not assign fingers or guarantee comfortable playing.
Meter-specific full patterns declare `meter` and, for 5/4, `grouping: [3, 2]` or `[2, 3]`; `meter: partial` marks the bounded one-bar pickup vocabulary. The loader checks nominal lengths, grouping, quarter/eighth arithmetic, electric lane overlap and distinct acoustic/electric onset patterns. Acoustic lane overlap is checked after automatic assignment. Each role has 24 distinct attack/duration figures per selectable pool: 4/4 (11 families), 3/4 (12 families), and each 5/4 grouping (12 families). The 4/4 pool removes one duplicate acoustic figure, develops another previously duplicated answer, and adds three electric variants. Patterns are independently authored from general principles, with research URLs and provenance in the resource, rather than transcriptions. The counts describe available choices, not required musical activity.
`grouping_for` is a pure source-only decision. It honors written 3+2 or 2+3, otherwise compares actual chord changes at the secondary boundary, then melody entrances following at least an eighth-note rest, then other melody attacks; equal evidence defaults to 3+2. An unchanged chord marking is not a change. The selection stays fixed through a continuous meter section, and each role derives it independently from the same source. Fills cannot borrow another grouping. No accents or playback swing changes are inferred. `groove_cycles` additionally reports grouping, its evidence and the eligible pattern count. Equal-duration compound meters (such as 6/8) do not borrow the 3/4 vocabulary; unsupported comping meters fail explicitly.
Accompaniment dependency keys and choice streams include only full-pattern meters and partial lengths present in that source, plus the applicable instrument policy. Adding unused-meter patterns therefore does not reseed an existing song; unrelated role policies remain excluded. Research prose is excluded from musical seeds. This schema migration changes the accompaniment choice-key domain once; it does not promise identical previous 4/4 tie-break winners. Source melodies, registered solos, notation format and playback count-in are unchanged.
The cycle begins at the first full source-body measure. A partial-form entry first fits the incoming harmony, then slices the sounded figure instead of restarting it; this prevents a previously clipped chord hold from reappearing as a new attack. An odd final bar uses the appropriate half-pattern. Meter changes restart a compatible cycle. Unsupported durations fail explicitly, and limited vocabularies report a shorter cycle. Optional final-harmony changes rebind the same selected pattern. Canonical grips are fixed wherever the chord and interval start remain unchanged, so a new turnaround cannot move neighboring unaffected voicings.
Fills replace only a two-bar figure's ending bar, using a same-family variation that improves the existing source-fit objective. Eligible boundaries are source section endings, form endings, or a melody breath of at least one quarter-note beat at the block end. Carried events from the opening bar are protected. The largest improvements are retained with an eight-measure minimum separation around the whole cyclic form, equally for both roles; no fill quota applies. Fills do not change cycle phase and recur at identical source positions. Reports record the base slot, selected fill, source index and reason.
Normal acoustic patterns use 1–3 attack positions per full bar. Their event layer is `acoustic`; the instrument's versioned `attack_assignment` policy is `combined_except_eighth_pairs`. Authored bass/upper decisions are replaced by chronological assignment across the complete canonical source form: ordinary attacks are combined, while adjacent half-beat-separated attacks in the same effective harmony become bass then upper. Pairs do not overlap; an odd leftover attack is combined. Bar and two-bar pattern boundaries do not reset pairing. Source-defined entries, handoffs and chorus boundaries do; the same boundary set applies at repeated form positions. Chord changes break pairs, but repeated identical chord labels do not. An anticipation uses its upcoming harmonic region for this decision. First attacks of new harmonic spans still include bass (`first_attack: bass_per_harmony`).
Quarter/eighth articulations and explicitly authored sustains release at the earliest of their intended end, the next acoustic attack in either lane, or a required harmonic/handoff boundary. Bass cannot ring beneath a later upper attack, nor can an upper chord ring beneath a later bass attack. Combined attacks have one shared release. Shortening that would strand an anticipation first rebinds it to current harmony and recomputes assignment. `acoustic_context` and `realize_acoustic_form` implement the shared source-form contract used by cycle comparison, fill selection and final source-harmony variants, before grip placement or notation splitting. Raw candidates retain authored releases so a changed neighboring attack can be evaluated afresh. Fills must improve the resolved whole-form cost without changing events outside their editable second bar. Concrete block caches include their assigned event signature: a neighboring chord change can break a pair even when this block's own harmony is unchanged. The renderer verifies actual sounding lane events against the selected assignment. The completed validator follows sounding tie chains and rejects any overlap between distinct acoustic attacks, even across different lanes. Placement validates all simultaneously sounding strings, fret spans and anchors. Bass and upper events merge into one notated part. Uninterrupted cross-bar holds and the combined three-bar closing sustain remain intact.
Electric normally uses 0–2 attack positions per bar, with stabs, sustains and space. Direct events release at changed harmony. An eligible acoustic/electric template can anticipate a chord by half a beat when it continues into that chord; the grip comes from the upcoming harmony and releases by its following change. Acoustic anticipations also include bass on the new chord's first attack. Missing harmony remains silent. Protected participation limits retain the chosen figure, shortening only its affected releases and recording exceptions. Cross-bar sounding notes become ties, never automatic merging of repeated attacks.
All six production roles receive reuse audits. Musical comparisons include rests, pitch durations, ties and TAB while ignoring regenerated event IDs and global measure numbers. Source-defined pickup/participation changes and effective final-turnaround harmony are reported separately. The final three-bar hold remains instrumental.
Named activity, melody-support, harmonic-support and articulation contributions evaluate complete figures. Cycle selection aggregates them over all occurrences, retaining family diversity before the final bounded comparison. `groove_cycles.retrieval_cost` is the isolated-figure estimate used for shortlisting. `cost` is the actual selected base cycle's cost before optional fills; acoustic cycles are assigned and released together before this comparison. Acoustic `final_cost` reports the complete source-form result after fills and any meter-section joins. The selected score is never overwritten by a post-selection report. Reports identify the base slot, realized pattern, projected events, continuations, anticipation target times and source-context exceptions. Tempo affects metadata/cache identity but never musical choice. This release correction leaves musical data and role choice seeds unchanged; code fingerprints invalidate stale concrete caches.
Acoustic events use temporary bass/upper notation lanes for projection; then `acoustic.combine` converts their sounding intervals to one rhythmic voice before assembly. It splits notes at attack/release boundaries and ties only continuing pitches; repeated attacks stay separate. Staff and TAB share the result, with no competing rests or opposing layer stems. This preserves exact sounding durations instead of truncating overlaps. The older truncating `prepare` helper serves only the noncanonical legacy/test path. The product build audits canonical accompaniment reuse across arrangement iterations, allowing only source-derived changes in harmony, pickups and role handoffs. The `.roles` sidecars report pattern IDs, exact projected layer events, continuations, anticipation targets and exceptions. Their `selection_cost` records the complete figure’s local contributions, repeated on each projected bar for context; the cycle selector aggregates these by the number of measures in each occurrence, without an anti-repetition transition cost. Accompaniment dependency keys contain only that instrument's policy; electric melody consumes the shared electric voicing families. Solos retain their existing learned source-melody/harmony conditioning and registered exact performances.
Acoustic sequential-release verification on October 7, 2026: `python3 modulus.py python -m unittest discover -s tests -p 'test_*.py'` passed 451 tests in 162.318 seconds. Coverage includes release in both lane directions, cross-bar pairing in 3/4, 4/4 and both 5/4 groupings, expired and surviving anticipations, complete-cycle ranking versus isolated retrieval, fills protecting neighboring assignments, malformed overlap before/after notation merging, canonical reuse, cold/warm caches and parallel roles. `python3 modulus.py format --check` passed. `python3 modulus.py build --target x86_64_gcc12_debug --target arm_64_gcc12_release` passed both generator/asset checks; 394 score JSON/PNG artifacts match across targets. Acoustic composition took 2.1 seconds for All of Me and 2.2 seconds for Autumn Leaves; native assets finished in 31 seconds and the cached ARM build in 11 seconds. Compared with the saved pre-change output, all attack pitches, onsets and TAB positions are identical: only 67 Autumn Leaves bass releases are shorter. Its arrangement measure 3 now contains bass [0, 1/2), upper chord [1/2, 3/2), and combined chord [2, 3), without ties. All of Me and the ten other-role documents are unchanged. Canonical reuse audits pass, and both three-bar instrumental endings retain one twelve-beat attack. Both acoustic opening pages were visually inspected; no audio audition was performed. The comparison baseline remains outside the repository under `/tmp/vamp-sequential-acoustic-yt_irkfd`.
Monophonic solos use strings 1–6 and frets 1–12, with no open strings or acoustic/electric string restrictions. Placement compares complete paths through legal positions, accounting for hand-region changes, travel time and string crossings. Ties retain their position. Chord placement retains its separate policy: frets 1–20, a sounding anchor on frets 1–12, primary spans of up to three consecutive positions and fallback spans of exactly four. The span is inclusive: 7–9 is three positions, 7–10 is four. Five positions are always invalid. The anchor must remain sounding, including after shorter notes release. Acoustic accompaniment additionally keeps its bass within frets 1–12 and requires an independent anchor in its upper three-note cluster, preserving the option of separate bass/upper attacks. These costs approximate physical feasibility; they do not assign fingers or guarantee comfortable playing.
Guitar placement shares the `hand-window-2` model in `generator/hand_position.py`. **Both chords and single notes** may occupy any legal four-consecutive-fret window. Position 7 covers frets 7–10; a chord occupying only frets 7–8 can use positions 5, 6 or 7, according to its neighbors. Position is the bottom of the selected window, not necessarily an occupied fret. This is an approximate positioning model, not an anatomical finger assignment. Sounded-note limits remain binding: a solo note cannot exceed fret 12 merely because its hand window extends farther.
After the existing compact-span, chord-family and electric-melody foreground priorities, selection minimizes **total absolute hand-position travel**, then the **maximum hand position across the complete path**. Finger changes and string crossings within the same window contribute zero travel. Only after those two criteria tie do relative finger adjustment, string crossings, grip complexity and time pressure decide between paths. Acoustic bass is one voice even across strings 5 and 6; upper voices follow their strings. Added/removed chord voices contribute one secondary adjustment each. Solo secondary effort uses elapsed time from the preceding attack, not a tied notation fragment. A genuine continuation retains pitch, TAB and hand position without another movement charge.
A low fret is not rewarded independently at every event. All three voicing policies retain only `register_weight` (default 1), weighting distance from their sounding-register center after travel, peak position, secondary effort and optional-tone coverage. Centers remain 53 for acoustic accompaniment and 60 for electric accompaniment/melody. Exact melody and solo pitches are never transposed to meet these preferences. Canonical accompaniment selection includes source-form repeat joins and solves source-derived variations between actual selected neighboring grips **and hand positions**. Unchanged intervals retain both. The instrumental ending receives the last accompaniment grip and selected window; it does not infer the hand from the lowest occupied fret.
The dynamic programs retain concrete grips/held strings, selected hand position and distinct earlier peaks. A later high position can equalize two earlier peaks and expose a subordinate tie-break, so retaining only one lowest-peak history is unsafe. Strictly worse primary travel at an identical endpoint/hand can still be discarded. Equal fret averages do not imply equal placement states. Stable ordering resolves equal complete costs.
Role reports expose `total_travel`, `shift_count`, `largest_shift`, `peak_position` and actual selected hand positions. Accompaniment costs separate travel from secondary `effort`; individual spans separate hand shift, finger adjustment, string changes, grip effort and register tie-breaking. Repeat travel is assigned to the first canonical span. Solo reports call the time-weighted subordinate value `secondary_effort`. Cache fingerprints include placement code while accompaniment rhythm seeds remain unchanged. Every role remains independently composed; the solo model, pitches and rhythms are unchanged.
The pre-window baseline is preserved outside production inputs under `/tmp/vamp-hand-window-baseline-dwh4anzh`. Verification compares sounded content and rhythms separately from TAB, and checks all electric melody chords for strings 1–3 or 1–4. Independent exhaustive test oracles cover complete grip/window paths, fixed neighbors, cyclic repeats and single-note paths; tests also cover a greedy-position trap, future peak equalization, zero-cost within-window string changes and tied-event invariance.
Hand-window verification on October 8, 2026: `python3 modulus.py python -m unittest discover -s tests -p 'test_*.py'` passed 472 tests in 100.928 seconds. The subsequent asset build exposed a print-footer overlap: Letter pagination had reserved a nominal font height instead of the actual page-number outline. The new tight-page regression reproduced that failure, and `python3 modulus.py python -m unittest tests.test_printing` passed all eight tests after measured footer bounds replaced the estimate. Content and collision audits remain enabled.
`python3 modulus.py build --target x86_64_gcc12_debug --target arm_64_gcc12_release` then passed both asset checks and produced six complete PDFs (42 pages). Native regeneration took 33 seconds with cached roles and a cold engraving namespace; ARM reused the assets in six seconds. Before the footer repair, uncached composition completed in five seconds for all twelve roles, with solos taking about 0.5 seconds each. `python3 modulus.py test --target x86_64_gcc12_debug` passed in 13.27 seconds. All 400 score JSON, normal/playback PNG, report and PDF files match between native and ARM.
Against the saved pre-window baseline, all four solos retain exactly the same pitches, timing and ties; vocal documents and accompaniment rhythm reports remain identical. Electric melody retains its exact source notes and timing; supporting chord tones may change to enforce string 1. All 46 All of Me and 33 Autumn Leaves electric melody chord fragments now use strings 1–3 or 1–4; previously 13 and three fragments respectively omitted string 1. Short monophonic melody remains permissible.
| Solo | Total hand travel, before → after | Number of shifts, before → after | Peak hand position, before → after |
|---|---:|---:|---:|
| All of Me acoustic | 131 → 12 | 87 → 10 | 9 → 7 |
| All of Me electric | 128 → 9 | 87 → 7 | 9 → 7 |
| Autumn Leaves acoustic | 141 → 2 | 85 → 2 | 9 → 3 |
| Autumn Leaves electric | 106 → 6 | 77 → 6 | 9 → 5 |
Travel is the sum of absolute window-position changes, measured in frets. An independent dynamic program over every legal string/fret/window confirmed that each new solo achieves the minimum raw travel for its unchanged sounding notes. This verifies the placement objective, not anatomical comfort or musical preference. The canonical accompaniment cycles now travel 10/14 frets for All of Me/Autumn Leaves acoustic, and 0/6 for electric; they retain source-based repeat consistency. No listening assessment was performed.
The sibling Modulus Conan helper was repaired to call `modulus.build_context.build_context`, replacing the removed `modulus.cli.build_context` API. Its Python suite passed 132 tests with four existing skips. A locally exported and built Modulus package passed `python3 modulus.py configure --target x86_64_gcc12_release`, followed by the release build and runtime test above. The offline attempt first identified missing cached Ligo sources; allowing ordinary Conan source retrieval completed configuration. An unwritable generated engraving cache was also restored to the build user's ownership. The Modulus source fix must be published through that repository's normal release process before remote CI using `modulus/latest` receives it; no remote package was published during this repair.
Recurring-groove verification on October 6, 2026: the full Python regression command passed 423 tests in 149.85 seconds. After the final partial-entry grip fix and one additional real-evaluator fill test, the focused accompaniment/arrangement command passed 59 tests in 21.64 seconds. The native test target passed in 30.58 seconds. The initial native rebuild took 42 seconds, including 7 seconds for independently generated roles and 33.62 seconds of engraving; accompaniment roles took 0.8–1.6 seconds each. The following ARM build reused all role/score caches and took 11 seconds. All four solo documents, both electric melodies and both vocals exactly matched the prechange baseline; native/ARM score assets matched byte for byte. The chosen base cycles differed by song and retained all two/four requested slots. Autumn Leaves selected the authored overlapping-quarter acoustic pattern. No optional fill improved these production winners, so no fills were forced; independently authored tests verify real source-fit selection of a fill. An acoustic score/TAB page was visually checked for overlap ties in a single part. Recordings were unchanged and no listening assessment was performed. Baseline snapshots stayed under `/tmp/`.
Shared-preference and bass-first verification on October 6, 2026: `python3 modulus.py python -m unittest discover -s tests -p 'test_*.py'` passed 408 tests in 61.35 seconds, and the native test target passed all 124 cases. Both product builds passed asset checks; 139 native/ARM score and page files matched byte for byte. All 273 acoustic measures containing new attacks started with bass, including 69 delayed entrances. Tied carries did not trigger new attacks. Both solos, vocals, electric accompaniment rhythms, and electric foreground melody pitches/timing/TAB matched the saved baseline exactly. Some All of Me melody support chords changed; Autumn Leaves' complete electric melody document did not. All of Me's canonical electric accompaniment mean fret dropped from 7.26 to 4.13 and movement cost from 57 to 48; Autumn Leaves stayed at 2.95 and 46. Recordings were unchanged. These are score checks and page inspections, not a listening assessment.
With no concurrent build, isolated cold role generation measured 0.56–0.57 seconds for acoustic accompaniment, 0.35–0.37 for electric accompaniment, and 0.26–0.29 for electric melody; cache hits took 0.02–0.04 seconds and matched clean regeneration for both songs. The normal two-worker native asset stage took about 14 seconds (4 composing, 9 engraving, 1 other); ARM reused the caches in about 4 seconds. Application compilation is separate from these asset-stage timings.
Lower-position verification on October 6, 2026: all 400 Python tests and 124 native test cases passed. Native and ARM builds passed asset checks; all 139 score/page files matched byte for byte. Against the saved production output, acoustic rhythms and all other five role documents were identical for both songs. Mean fret across canonical active acoustic grips changed from 8.90 to 4.50 in Autumn Leaves and 5.19 to 4.29 in All of Me; movement costs rose from 144 to 190 and 128 to 140 respectively. In the requested six-chord passage, five suggested grips won; Em7b5 instead chose its valid fifth-bass shape on strings 6/4/3/2 at frets 6/5/7/5. Tests also verify that the complete suggested sequence beats the previous higher sequence with fixed neighbors, and that sufficiently costly travel can still retain a higher grip. These are score/selection facts, not an ear-based audition.
Isolated uncached acoustic role generation took 0.61–0.62 seconds per song, versus 0.56–0.58 seconds before this change; cache hits took about 0.048 seconds and matched clean output. With two composition and engraving workers, the native asset rebuild took approximately 11 seconds (4 composing, 6 engraving, 1 other); ARM reused caches and took approximately 6 seconds. These are individual local measurements, not a statistical benchmark. Supplied recordings remain byte-identical.
### Recording Playback and Page Timing
@@ -141,11 +216,15 @@ Vamp uses only supplied PCM16 WAVs. `package/assets/sounds/beat1.wav` and `beat2
Settings exposes `audio.backing_enabled`, `audio.metronome_enabled` and `audio.tempo_bpm`; both toggles default off and tempo defaults to 120. The fixed tempo set is 60 through 120 in steps of 10. Backing restricts it to the intersection available for all catalog songs. Turning it on snaps to the nearest available tempo, with ties going slower; an empty intersection makes it unavailable. Obsolete playback and configurable tempo-range settings are rejected. Recordings are never stretched or trimmed.
The existing recordings contain one bar of count-in, 168 score bars, then three held bars and decay. Backing-only plays the complete file. Both toggles play the recorded count-in alone, then backing plus sample clicks during the score; no clicks play over the held ending. Metronome-only supplies its own one-bar count-in and completes at score end. Both off enables manual page navigation. Opening a part with either toggle on starts automatic mode. Next/previous are ignored during automatic mode; hold exits, and natural completion returns to the selected part menu. The final page remains displayed through a recording tail.
The existing recordings contain one bar of count-in, 168 main-form bars, three held bars and decay. `arrange/ending.py` now writes that existing tail as measures 169–171, without extending or transforming the recordings. Both accompaniment roles choose a valid closing voicing using their own outgoing position and hold it with ties; melody/solo roles are silent there and the vocal has three full rests. The chord is the final effective harmony after omitting optional turnarounds, including carried harmony. Missing/N.C. final harmony fails accompaniment generation explicitly. The original final bar is untouched.
Preparation runs on a worker: checksums and samples are loaded before publishing a Sonus recording transport. Sonus streams backing audio through miniaudio’s background resource manager and mixes preloaded stereo clicks on the same rendered-frame clock. Callback work uses preallocated buffers, and resource retirement occurs on control threads. Stream failures stop progress and surface an error. Absolute rational beat positions are rounded to frames at 48 kHz once per position, avoiding accumulated rounding drift. The UI polls that audio clock for page boundaries and Count-in/Playing/Sustain status; wall-clock timers never determine musical progress.
Score timing includes `sustain_start`, an exact measure boundary, as well as the total written duration. Ending measures carry `ending_sustain`; Python and C++ validate a contiguous tail and consistent timing. Older scores without the new timing field retain their previous full-duration click behavior. Both toggles play the recorded count-in alone, then backing plus sample clicks until `sustain_start`. No clicks sound over the ending. Metronome-only supplies its own count-in and completes after the three silent held bars. Backing-only plays the complete file and decay. Both off enables manual navigation; hold exits and natural completion returns to the part menu. The final page remains visible through decay.
Page metadata comes from actual system pagination and is preserved and revalidated in engraving caches. The UI prepares the current and next page before playback starts and retains a two-texture cache. Session and catalog identities reject stale preparation, page updates and completion after cancellation. Missing or corrupt pages/audio leave a visible error and permit hold/back. `--once` validates packaged recording checksums and all score pages without opening audio/display hardware.
Preparation runs on a worker: checksums and samples are loaded before publishing a Sonus recording transport. Sonus streams backing audio through miniaudio’s background resource manager and mixes preloaded stereo clicks on the same rendered-frame clock. Callback work uses preallocated buffers, and resource retirement occurs on control threads. Stream failures stop progress and surface an error. Absolute rational beat positions are rounded to frames at 48 kHz once per position, avoiding accumulated rounding drift. The UI polls that audio clock for system and measure boundaries and Count-in/Playing/Sustain status; wall-clock timers never determine musical progress.
Page metadata comes from actual system pagination and is preserved and revalidated in engraving caches. `presentation.pages` partitions the music into normal two-system pages. `presentation.playback_pages` holds one view per system: that system and its successor, or a final single top system. Both reuse the same system breaks, horizontal geometry, and part-wide scale, fitted against every adjacent pair. Each descriptor carries system measure ranges, exact beat boundaries, and page-coordinate rectangles for its measure labels. Normal systems partition the score; overlapping playback views must match that canonical partition. Bundles missing playback metadata require regeneration.
Measure numbers are centered over their starting barlines (the staff’s left edge at system start), in a reserved lane above notation and below harmony/section labels. The display outlines the current label using the page texture’s letterbox transform; count-in, preparation, exit, and playback error clear it. Measure updates publish even when the line stays unchanged. Normal catalog page counts remain unchanged; the loader reads the separate playback count from bundle metadata. During automatic playback, navigation bounds, the header’s Line counter, and Pico’s page/pages fields refer to overlapping views. Manual browsing uses the normal sequence. The UI prepares the current and next page before playback starts and retains a two-texture cache. Session and catalog identities reject stale preparation, page updates and completion after cancellation. Missing or corrupt pages/audio leave a visible error and permit hold/back. `--once` validates packaged recording checksums and both normal and playback score pages without opening audio/display hardware.
### Authored Repertoire and Learned Solos
@@ -189,7 +268,7 @@ Files are copied into `data/songs` and `data/training` without overwriting diffe
Production input traces distinguish authored reuse from learned prediction. Caches include source, role, relevant data and code; authored cache keys include the selected XML's content and convention. Build and package inputs include the model, manifest and authored repertoire. Changes to another solo do not change an already registered part's notes. Updating the pooled model can legitimately change predictions for any unregistered part. CMake defaults to two composition processes (`VAMP_COMPOSITION_JOBS`, 1–16) and caches each role under `build/build_common/composition_cache`. Direct generator runs use `--composition-jobs` and opt into persistent caching with `--composition-cache`; single-role builds use `--cache-dir`.
The generated `solo_xml/*-solo1.xml` and `*-solo2.xml` exports use local measure numbers, preserve pickups, and store whole-arrangement positions in `manifest.solo`. Exact reuse means complete sounding pitches, onsets, releases, repeated attacks and silence agree. XML whitespace, note splitting, measure labels and exporter-specific annotation containers need not be identical. Optional `./modulus.py python -m tests.solo_compare` compares these completed exports; it never feeds a production decision. Its `--generated-dir` is the directory containing `manifest.solo`, and `--reference`/`--form-start` use the manifest's `SONG/ROLE` keys. `--require-exact` fails if any requested reference differs in complete sounding events or rests. Training and authored reuse are the explicitly permitted dependencies on the supplied music.
Solos are published inside the arranged score JSON and engraved pages, without separate solo MusicXML exports or comparison manifests. Exact-repertoire tests compare generated sounding pitches, onsets, releases, repeated attacks, measure timing and silence directly with the authored XMLs. Tied notation fragments are merged into sounding events for this check, and generated TAB is checked against the guitar constraints. Training and authored reuse remain the explicitly permitted dependencies on the supplied music.
Migration inventory:
@@ -199,11 +278,11 @@ Migration inventory:
| `data/training/` (four XMLs + manifest) | Explicit trainer and registered authored playback. All slots are pooled for learning. Annotation-only cleanup preserves the music and learned counts. |
| `data/models/solo.json` | Frozen prediction model; reproducible by `generator.train`. |
| `data/composition/{roles,harmony,lead_ins}.json` | Physical/difficulty settings and generic harmonic validity. Fixed-map permissions removed. |
| `data/composition/accompaniment.json` | Version 2: independently authored duration families, per-layer ranges and bounded retrieval settings, consumed by `comping_rhythm.py`. Replaces the old per-chord figure list; no reference-derived material. |
| `data/composition/accompaniment.json` | Version 3: independently authored per-instrument duration families, layer ranges, bounded retrieval and generic chord-degree/geometry families. Consumers: `comping_rhythm.py`, `comping.py`, `chord_families.py` and `guitar.py`. Migrates the v2 shared-duration schema; no parallel legacy data or reference-derived material. |
| `generator/harmonic_time.py` | Exact chord/key spans retained from the removed scale subsystem. |
| Solo event, expression, placement, notation and export helpers | Retained physical/timing safeguards shared by authored and predicted music. |
Removed: `data/{scales,sequences,rhythms}`, old `composition/solo.json` and mixed `rhythms.json`, catalog import/cache code, old solo construction/phrase/selection/scoring/sequence modules, unused accompaniment catalog planner, three evaluation-song excerpts, and tests specific to those retired algorithms. Shared importer, timing, guitar, playback, engraving, arrangement and independence tests remain, with new pooled-learning, registration and exact-repertoire tests. No `docs/` or `audition/` directory is required. Temporary comparisons and diagnostics belong under `/tmp/`; old comparison pages, diagnostic reports, formatter-debug scripts and the copied verification bundle have been removed from `build/`. Product builds, caches and toolchains remain. The installed `build/sonus_arm` dependency remains because the configured ARM build uses it; its unused separate compilation directory has been removed.
Removed: `data/{scales,sequences,rhythms}`, old `composition/solo.json` and mixed `rhythms.json`, catalog import/cache code, old solo construction/phrase/selection/scoring/sequence modules, unused accompaniment catalog planner, three evaluation-song excerpts, and tests specific to those retired algorithms. Shared importer, timing, guitar, playback, engraving, arrangement and independence tests remain, with new pooled-learning, registration and exact-repertoire tests. No `docs/` or `audition/` directory is required. Temporary comparisons and diagnostics belong under `/tmp/`; old comparison pages, diagnostic reports, formatter-debug scripts and the copied verification bundle have been removed from `build/`. Product builds, caches and toolchains remain. Desktop and ARM builds resolve Sonus through Conan; separate local Sonus installations and temporary CMake dependency overrides are unnecessary. Refresh both with `python3 modulus.py configure --update --target x86_64_gcc12_debug --target arm_64_gcc12_release` when dependency packages change. The obsolete playback-test assets are superseded by the current performance-test fixtures.
Verification on October 5, 2026: `unittest discover -s tests -p 'test_*.py'` passed 361 tests in 78.62 seconds. These include all four approved solos without annotations or authored-role privileges, source-form pickup context, invalid resolutions, passing endpoints, anticipated colors, tied-event partition invariance and active prediction construction. The normal six-part asset build passed `--check`, including playback, engraving, TAB and catalog validation. With two composition workers, newly generated solo results, cached accompaniment/melody and a warm engraving cache, it took 5.10 seconds; performance-part generation occupied 2.37 seconds. Each registered solo took 0.36–0.40 seconds. The subsequent `cmake --build build/build_x86_debug --target vamp_generated_assets` also passed. These measurements describe registered playback, not novel prediction; the disposable diagnostic reports have since been removed.
@@ -211,9 +290,17 @@ Voicing-only verification on October 6, 2026, before the rhythm update: the suit
Rhythm verification on October 6, 2026: `unittest discover -s tests -p 'test_*.py'` passed all 375 tests in 83.57 seconds. Coverage includes attack ranges, bass downbeats, mixed durations, harmonic-change budgets, overlapping voices, tied joins, 3/4 and 5/4, melody-conditioned rhythm costs, tempo invariance, canonical reuse, and serial/parallel role identity. A synthetic learned-model test also confirms that changing original melody rhythm or upcoming harmony changes solo duration probabilities with a fixed seed. Both songs' solo, electric melody and vocal role documents remain exactly equal to the saved pre-rhythm baseline; no model retraining was performed.
The ordinary six-score rebuild with `--check --export-solo-xml --composition-jobs 2 --jobs 2` passed in 13.39 seconds: 4.44 seconds generating parts and 8.48 seconds engraving. All role composition results were newly generated; the warm engraving namespace reused two unchanged vocal scores. The subsequent `cmake --build build/build_x86_debug --target vamp_generated_assets` passed with all role/score caches reused. Actual selected acoustic upper rhythms use one or two attacks in these songs; three-attack alternatives are available and tested but are not forced. All of Me electric has three zero-attack source/harmony contexts; Autumn Leaves electric uses one or two attacks. Neither song required a density exception. Reuse audits checked 103/62 acoustic/electric repeated bars for Autumn Leaves and 102/62 for All of Me, with only source-defined pickups and final-harmony exceptions. Sample acoustic notation/TAB pages were visually inspected. Supplied audio recordings remain unchanged; no ear-based audition of the new accompaniment was performed. Disposable logs, profiles and comparisons are under `/tmp/`, outside product assets.
The ordinary six-score rebuild with `--check --composition-jobs 2 --jobs 2` passed in 13.39 seconds: 4.44 seconds generating parts and 8.48 seconds engraving. All role composition results were newly generated; the warm engraving namespace reused two unchanged vocal scores. The subsequent `cmake --build build/build_x86_debug --target vamp_generated_assets` passed with all role/score caches reused. Actual selected acoustic upper rhythms use one or two attacks in these songs; three-attack alternatives are available and tested but are not forced. All of Me electric has three zero-attack source/harmony contexts; Autumn Leaves electric uses one or two attacks. Neither song required a density exception. Reuse audits checked 103/62 acoustic/electric repeated bars for Autumn Leaves and 102/62 for All of Me, with only source-defined pickups and final-harmony exceptions. Sample acoustic notation/TAB pages were visually inspected. Supplied audio recordings remain unchanged; no ear-based audition of the new accompaniment was performed. Disposable logs, profiles and comparisons are under `/tmp/`, outside product assets.
The optional exact comparison confirmed all four exports: 137/141 attacks for All of Me and 121/115 for Autumn Leaves, with no pitch, onset, release or rest differences. All four now pass contextual harmony validation as well. Removing 69 explanatory annotations left the complete event streams and learned musical count tables identical to the pre-edit baseline; only model provenance hashes changed. This verifies authored reuse rather than learned reproduction. Commands used the ordinary asset generator with `--export-solo-xml --check` and `python -m tests.solo_compare` with four explicit `--reference` pairs, `--reference-pitch guitar-written` and `--require-exact`. No ear-based audition or claim of transfer quality was made.
Chord-family and unified-acoustic verification on October 6, 2026: `unittest discover -s tests -p 'test_*.py'` passed 386 tests in 81.67 seconds. New cases cover 35 chord qualities in three keys for both instruments, discarded bass variants and explicit unsupported combinations, the six suggested acoustic grips, highest feasible electric melody strings, scoped policy dependencies, and one-voice tie preservation including repeated attacks and cross-bar ties. Quarter/eighth acoustic attack durations and available consecutive-eighth patterns are tested. The acoustic sounding events in both complete arrangements contain only quarter/eighth durations, even where notation splits them into ties.
The full checked rebuild with two composition and two engraving workers took 13.76 seconds: 4.68 seconds for all parts and 8.63 seconds engraving. All role caches missed after the code change; two unchanged vocal engravings were reused. Serial composition-only generation into a disposable directory also passed in 5.58 seconds. The subsequent CMake asset build passed and reproduced every role document from warm caches. Both registered solos and vocal documents are exactly unchanged from the saved prechange baseline; the electric melody's original pitches/onsets/durations also match. Reuse audits retain the same 103/62 and 102/62 repeated-bar counts. Acoustic upper rhythms now select one to three attacks in Autumn Leaves and one or two in All of Me. Acoustic and electric melody pages were visually inspected; this is notation/constraint verification, not an ear-based audition. Only product artifacts and normal caches were written under `build/`; diagnostic logs and baseline comparisons remain under `/tmp/`.
Four-fret fallback verification on October 6, 2026: `unittest discover -s tests -p 'test_*.py'` passed 392 tests in 85.65 seconds. This includes primary-tier precedence over family, arbitrary movement savings and melody-string height; a complete held-note path that needs an earlier four-fret option; tied-fragment cost invariance; and anchor release checks. The first full run exposed one obsolete C5 rejection expectation, now replaced by a test verifying its legal four-fret voicings contain only C/G. Coverage tests check 35 qualities in 12 keys for each instrument: 418/420 acoustic contexts and 420/420 electric contexts have a legal grip. Acoustic Bbm9/Bm9 remain explicitly unsupported; this is measured coverage, not a guarantee for every written extension or slash chord.
The checked six-score rebuild with `--composition-jobs 2 --jobs 2` passed in 9.21 seconds (4.58 seconds composing all 12 roles, 3.90 seconds processing six cached engravings). All composition caches missed after the code change. Every resulting role document and accompaniment rhythm report exactly matches the saved baseline: current production chords already have primary grips, so none needed fallback substitutions. New sidecar span diagnostics identify the tiers and available candidates. The subsequent `cmake --build build/build_x86_debug --target vamp_generated_assets` passed with all role caches reused and identical per-role musical hashes. Acoustic and electric score/TAB pages were visually checked; supplied recordings are unchanged. Formatter and diff checks passed. Temporary verification files remain under `/tmp/`.
Earlier exact-repertoire verification confirmed all four authored solos: 137/141 attacks for All of Me and 121/115 for Autumn Leaves, with no pitch, onset, release or rest differences. All four also passed contextual harmony validation. Removing 69 explanatory annotations left the complete event streams and learned musical count tables identical to the pre-edit baseline; only model provenance hashes changed. This verifies authored reuse rather than learned reproduction. These checks now compare generated score data directly with the training inputs instead of producing standalone XML exports. No ear-based audition or claim of transfer quality was made.
Forced prediction, without reading the training XMLs, completed all four source/role combinations with valid harmony. These were composition-only runs on the training-source songs, not held-out transfer tests. Their notes intentionally differ from registered playback and were not published as replacements. The expanded treatment candidates initially took 99.03–120.33 seconds per role with one worker and no concrete-result cache. Removing repeated validation of identical resolution endpoints reduced the isolated All of Me acoustic check from 104.30 to 60.13 seconds, with an identical complete output hash. Six additional contexts retained all 32,566 ordered action candidates exactly. These expanded prediction choices remain slower than the earlier 21.81–27.16-second decoder; registered playback is unaffected. Training the pooled 2,860-context model took 0.57 seconds. Prediction remains the slower path, chiefly candidate construction and event-likelihood evaluation; further profiling is needed before expanding its choices again.
@@ -231,7 +318,7 @@ Voices retain separate stems and collision offsets; chord tones retain their own
Generated guitar tones carry `tablature: {string, fret}`; their staff is marked `tablature: true`. `engraving/tablature.py` draws a six-line TAB view below standard notation, sharing onset columns, barlines, and page breaks. Both views belong to one system and never duplicate the semantic timeline or playback events. Standard notation carries rhythm, rests, and tuplets; TAB carries positions, solo slashes, and tied continuations without rest glyphs. Strings and frets are validated against sounding pitch, and the layout audit checks each visible TAB numeral's position and alignment.
Every part uses two music systems per page; only an odd final system occupies a row alone. A compact title/composer/part header reserves the same height on every page, wrapping credits if necessary. Pagination fits the two systems using their individual heights and distributes extra whitespace around them while retaining minimum system and header/footer clearances. One uniform scale applies throughout the entire part, reducing the ordinary notation size only when required by the tallest pair. Notation, TAB, text, and anchors scale together without changing musical content. Guitar layout starts with 10-pixel notation spacing, 10.5-pixel TAB spacing, 12-pixel fret labels, and a 14-pixel minimum gap between systems. The unscaled TAB spacing accommodates Petaluma numerals up to 9.75 pixels tall. Tempo markings consume neither ink nor spacing; their semantic data is preserved. Existing `.pages/*.png` preview files are the exact packaged page textures.
Normal pages use two music systems; only an odd final system occupies a row alone. Playback pages use overlapping adjacent pairs and always finish with the last system alone on top. A compact title/composer/part header reserves the same height on every page, wrapping credits if necessary. Pagination fits the two systems using their individual heights and distributes extra whitespace around them while retaining minimum system and header/footer clearances. One uniform scale applies throughout the entire part, reducing the ordinary notation size only when required by the tallest adjacent pair, including transition pages. Notation, TAB, text, and anchors scale together without changing musical content. Guitar layout starts with 10-pixel notation spacing, 10.5-pixel TAB spacing, 12-pixel fret labels, and a 14-pixel minimum gap between systems. The unscaled TAB spacing accommodates Petaluma numerals up to 9.75 pixels tall. Tempo markings consume neither ink nor spacing; their semantic data is preserved. Existing `.pages/*.png` preview files are the exact packaged page textures.
Line breaks occur only at measure boundaries. Each line fits as many complete measures as readable spacing allows; it never fills remaining space with a partial measure. A complete measure exceeding the available width or height fails with source and measure context instead of being split or squeezed to fit. Authored ties, beams, tuplets, and lyric spans can continue across whole-measure line breaks. Column measurement and fit trials reuse a score index and bounded column cache. Page placement then re-spaces columns for the final height-fitting scale, keeping every notation/TAB staff at the same physical left and right margins without stretching glyphs. Non-final lines are justified; a short final line retains natural note spacing while staff lines extend to the same right margin. Layout audits enforce these margins as well as musical coverage.
@@ -241,6 +328,18 @@ Bundles preserve the complete `music` object. Presentation identifies the `Vamp
Pages are 976x484 pixels with nominal 10-pixel guitar or 12-pixel vocal staff spacing, 28-pixel horizontal margins and 18-pixel vertical margins. The two acoustic rest lanes sit closer to the staff, with collision offsets preserving their separation. Systems and pages contain complete measures; tied notes and notation spans may continue across their boundaries. Presentation fragments preserve exact timing and never change the semantic JSON. A measure that cannot fit at readable spacing fails with source and measure context; the uniform part-wide scaling described above fits pairs of complete systems vertically. Blank pages, incorrect dimensions, and ink reaching the page edge are rejected. Runtime letterboxing preserves aspect ratio. Luma's `load_texture_uncached()` lets Product Vamp retain at most two textures without a hidden strong asset-cache reference. The UI reports missing/corrupt assets instead of falling back to the removed renderer. Runtime validates bundle metadata, paths, dimensions, and page checksums; the build validates musical semantics.
### Printable Parts
`generator.printing.generate_tree` runs after screen engraving inside the normal asset staging transaction. It reads each completed song/part's musical document, not its screen PNGs or overlapping playback views, and writes `print/<score-stem>.pdf`. Every arranged measure and the instrumental ending appear once in order. Acoustic/electric parts retain standard notation and TAB; vocal parts retain lyrics and rests. No music, runtime bundle fields or catalog rows are changed. Both CMake installation and runtime image copying exclude the `print` directory.
Print layout uses portrait US Letter (612 × 792 PDF points), a minimum half-inch clear margin, and fixed five-point guitar/six-point vocal staff spacing. It reserves the actual overhang of centered measure numbers inside the margin. Complete systems fill the available page height with consistent notation size; the final page keeps natural vertical spacing. Headers identify the tune, composer and instrument; printed page numbers are independent of device pagination. The existing musical/fragment/TAB audits remain active, with variable systems per page allowed only by the print caller. Screen audits still require two systems except the odd final system.
The shared primitive renderer accepts explicit colors and output scale while retaining unchanged screen defaults. Print draws black on white directly at 2550 × 3300 pixels (300 DPI), then writes grayscale image pages through Pillow's PDF writer at quality 95. This is a raster PDF, not searchable/vector notation. One page is rendered and appended at a time to bound image memory. The pinned Pillow parser checks page count, Letter media boxes and image resolution/color; tests decode the embedded JPEGs and verify clear margins. No new Python package is required: Modulus's existing `assets` group owns Pillow, fonttools and aggdraw. Timestamps and output-path metadata are omitted for byte-reproducible PDFs.
With `--engraving-cache`, print results use a separate `print/<print-renderer>/<score-key>/` namespace. Keys cover score content, print settings, fonts, renderer source and dependency versions. Cached PDFs have checked hashes and page metadata; missing or corrupt entries regenerate. Native and ARM builds share the cache locally. This print namespace is separate from the screen-only CI cache snapshot. Output PDFs are validated before the build publishes; failure preserves the previous complete asset directory. Stale PDFs disappear when source parts disappear. Temporary print files live only in build/cache staging.
Print rollout verification: `python3 modulus.py python -m unittest discover -s tests -p 'test_*.py'` passed 458 tests; the seven `tests.test_printing` tests were rerun after the final footer-margin adjustment. `python3 modulus.py build --target x86_64_gcc12_debug --target arm_64_gcc12_release` passed with byte-identical PDFs on both targets. All of Me has 10/8/5 acoustic/electric/vocal pages and Autumn Leaves has 9/7/4, totaling 43. All pages were checked for Letter size, 300 DPI grayscale images and pure-white half-inch margins; representative opening, solo, lyric and ending pages were visually inspected. All 394 preexisting score JSON/screen PNG files stayed byte-identical. PDF generation took 9.7 seconds uncached and 0.1 seconds cached on this development machine; this is the print stage only, not a clean whole-product build benchmark. Physical printing was not tested.
### Validation And Publication
Generation validates sources and complete staged output before replacing the previous asset directory. Replacement is always complete; deleted sources cannot leave stale JSON, pages, audio, or Pico title assets. CMake tracks the input list as well as file contents, so additions and removals regenerate the catalog. Runtime packages contain `catalog.db` with embedded semantic JSON and title-image identifiers, PNG pages, supplied WAV recordings, Pico title images, and the OTF UI text font, not MusicXML, MuseScore, or Python dependencies. Python test discovery runs model/import/export tests; the normal asset build additionally qualifies and audits every catalog score.
+1 -1
View File
@@ -1,4 +1,4 @@
if(NOT EXISTS "${SOURCE}/catalog.db")
message(FATAL_ERROR "Missing generated catalog: ${SOURCE}/catalog.db")
endif()
file(COPY "${SOURCE}/" DESTINATION "${DESTINATION}" PATTERN "*.json" EXCLUDE PATTERN "analysis" EXCLUDE)
file(COPY "${SOURCE}/" DESTINATION "${DESTINATION}" PATTERN "*.json" EXCLUDE PATTERN "analysis" EXCLUDE PATTERN "print" EXCLUDE)
+2 -8
View File
@@ -157,11 +157,6 @@ set(VAMP_GENERATED_ASSETS_DIR ${CMAKE_CURRENT_BINARY_DIR}/generated_assets)
set(VAMP_GENERATED_ASSETS_STAMP ${CMAKE_CURRENT_BINARY_DIR}/generated_assets.stamp)
set(VAMP_ENGRAVING_JOBS 2 CACHE STRING "Maximum parallel Python engraving workers (1-16)")
set(VAMP_COMPOSITION_JOBS 2 CACHE STRING "Maximum independent musical role workers (1-16)")
option(VAMP_EXPORT_SOLO_XML "Export completed solo roles as comparison MusicXML" OFF)
set(VAMP_SOLO_EXPORT_ARGS)
if(VAMP_EXPORT_SOLO_XML)
list(APPEND VAMP_SOLO_EXPORT_ARGS --export-solo-xml)
endif()
set(VAMP_ENGRAVING_CACHE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/build/build_common/engraving_cache" CACHE PATH "Shared build-only page cache; empty disables caching")
set(VAMP_ENGRAVING_CACHE_ARGS)
if(VAMP_ENGRAVING_CACHE_DIR)
@@ -169,7 +164,7 @@ if(VAMP_ENGRAVING_CACHE_DIR)
endif()
string(JOIN "\n" VAMP_GENERATOR_INPUT_MANIFEST ${VAMP_GENERATOR_INPUTS})
file(CONFIGURE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/generated_assets.inputs
CONTENT "@VAMP_GENERATOR_INPUT_MANIFEST@\nsolo_xml=@VAMP_EXPORT_SOLO_XML@\n" @ONLY)
CONTENT "@VAMP_GENERATOR_INPUT_MANIFEST@\n" @ONLY)
add_custom_command(
OUTPUT ${VAMP_GENERATED_ASSETS_STAMP}
BYPRODUCTS ${VAMP_GENERATED_ASSETS_DIR}/catalog.db
@@ -184,7 +179,6 @@ add_custom_command(
--composition-cache ${CMAKE_CURRENT_SOURCE_DIR}/build/build_common/composition_cache
--progress
${VAMP_ENGRAVING_CACHE_ARGS}
${VAMP_SOLO_EXPORT_ARGS}
COMMAND ${CMAKE_COMMAND} -E touch ${VAMP_GENERATED_ASSETS_STAMP}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${VAMP_GENERATOR_INPUTS} ${CMAKE_CURRENT_BINARY_DIR}/generated_assets.inputs
@@ -201,7 +195,7 @@ install(TARGETS vamp_zero
)
install(FILES package/config/vamp.example.json DESTINATION zero/config)
install(DIRECTORY ${VAMP_GENERATED_ASSETS_DIR}/ DESTINATION zero/share/product_vamp
PATTERN "*.json" EXCLUDE PATTERN "analysis" EXCLUDE)
PATTERN "*.json" EXCLUDE PATTERN "analysis" EXCLUDE PATTERN "print" EXCLUDE)
install(PROGRAMS
package/zero/install_zero.sh
package/zero/start_ap.sh
File diff suppressed because it is too large Load Diff
+13 -3
View File
@@ -8,15 +8,25 @@
"acoustic_accompaniment": {
"seed": "acoustic_comp",
"bass": "primary",
"center": 53
"center": 53,
"voicing": {
"register_weight": 1
}
},
"electric_accompaniment": {
"seed": "electric_comp",
"bass": "essential",
"center": 60
"center": 60,
"voicing": {
"register_weight": 1
}
},
"electric_melody": {
"seed": "head"
"seed": "head",
"center": 60,
"voicing": {
"register_weight": 1
}
},
"vocal_melody": {
"seed": "voice"
+14 -15
View File
@@ -2,14 +2,14 @@ from __future__ import annotations
import argparse
import json
import os
import pathlib
import platform
import shutil
import tempfile
import time
import modulus.filesystem
import generator.arrange.generate
import generator.audio_assets
import generator.catalog
import generator.engraving.cache
import generator.engraving.fonts
@@ -17,12 +17,12 @@ import generator.engraving.pipeline
import generator.engraving.types
import generator.parts
import generator.pico_artwork
import generator.performance
import generator.printing
import generator.production
import generator.score
import generator.score_io
import generator.summary
import generator.solo.export
import platform
import os
import modulus.filesystem
RUNTIME_FONT_FILES = ("PetalumaScript.otf", "OFL.txt")
@@ -44,7 +44,6 @@ def parse_args() -> argparse.Namespace:
parser.add_argument("--jobs", type=int, default=1, choices=range(1, 17), metavar="1-16")
parser.add_argument("--composition-jobs", type=int, default=2, choices=range(1, 17), metavar="1-16")
parser.add_argument("--composition-cache", type=pathlib.Path)
parser.add_argument("--export-solo-xml", action="store_true", help="Export completed solo roles as comparison MusicXML, without recomposing.")
parser.add_argument("--trace-level", choices=("summary", "full"), default="summary", help="Diagnostic detail only; does not seed composition.")
parser.add_argument("--profile-output", type=pathlib.Path, help="Write build and per-role elapsed timings (not a search timeout).")
parser.add_argument("--progress", action="store_true")
@@ -88,7 +87,7 @@ def generate_assets(args: argparse.Namespace) -> None:
staged.mkdir(parents=True, exist_ok=True)
copy_runtime_fonts(static_assets_dir, staged)
report('generating performance parts')
performance_count = generator.arrange.generate.generate_performance_scores(data_dir / 'songs', staged / 'songs', composition_jobs=getattr(args, 'composition_jobs', 2), cache_dir=getattr(args, 'composition_cache', None), progress=progress, timings=timings)
performance_count = generator.production.generate_tree(data_dir / 'songs', staged / 'songs', jobs=getattr(args, 'composition_jobs', 2), cache_dir=getattr(args, 'composition_cache', None), progress=progress, timings=timings)
if getattr(args, 'trace_level', 'summary') == 'summary':
for path in (staged / 'analysis').glob('*.roles'):
roles = json.loads(path.read_text())
@@ -96,21 +95,21 @@ def generate_assets(args: argparse.Namespace) -> None:
trace = role.get('details', {}).get('selection_trace', {})
trace.pop('decisions', None)
path.write_text(json.dumps(roles, sort_keys=True, indent=2))
if getattr(args, 'export_solo_xml', False):
generator.solo.export.export_tree(staged)
generator.score.validate_generated_tree(staged)
generator.score_io.validate_generated_tree(staged)
if args.check:
generator.summary.validate_expected_performance_summary(pathlib.Path(__file__).resolve().parents[1] / 'tests' / 'fixtures' / 'performance_summary.json', staged / 'songs')
report('copying supplied recordings')
song_ids = {generator.score.slugify(path.stem) for path in (data_dir / 'songs').glob('*.xml')}
audio_assets = generator.performance.copy_audio(static_assets_dir, staged, song_ids)
generator.performance.validate_recording_lengths(staged, audio_assets)
audio_assets = generator.audio_assets.copy_audio(static_assets_dir, staged, song_ids)
generator.audio_assets.validate_recording_lengths(staged, audio_assets)
report('engraving pages')
validated_pages = generator.engraving.pipeline.engrave_tree(staged, static_assets_dir / 'fonts' / 'petaluma', cache_dir=cache_dir, jobs=getattr(args, 'jobs', 1), progress=progress)
report('generating printable parts')
generator.printing.generate_tree(staged, static_assets_dir / 'fonts' / 'petaluma', cache_dir=cache_dir, progress=progress)
report('rendering Pico titles')
generator.pico_artwork.generate_titles(staged, static_assets_dir / 'fonts' / 'petaluma')
report('validating score, page, and audio assets')
generator.score.validate_generated_tree(staged, validated_pages)
generator.score_io.validate_generated_tree(staged, validated_pages)
report('building catalog database')
generator.catalog.build_catalog(staged, audio_assets=audio_assets)
with modulus.filesystem.publish_directories([(staged, output_dir)]):
+102 -20
View File
@@ -6,6 +6,8 @@ import itertools
import generator.accompaniment
import generator.model
import generator.score
import generator.harmonic_time
@dataclasses.dataclass
class HarmonySpan:
@@ -76,27 +78,107 @@ def prepare(document: dict) -> None:
generator.accompaniment.normalize_beams(notes)
def combine(document: dict) -> None:
"""Write prepared bass/upper attacks as one voice with shared stems and rests."""
"""One rhythmic voice; split held pitches into ties rather than release them."""
originals = {p['id']: p for m in document['staves'][0]['measures'] for v in m['voices'] for n in v['notes'] for p in n['pitches']}
edges = [(p['id'], p['tie_to']) for p in originals.values() if p.get('tie_to')]
fragments = {}
for measure in measures(document):
length = generator.model.fraction(measure['duration'])
attacks = sorted((n for v in measure['voices'] for n in v['notes'] if n['pitches']), key=lambda n: generator.model.fraction(n['onset']))
notes, cursor = [], fractions.Fraction()
def rest(end):
nonlocal cursor
for duration, written in generator.accompaniment.written_durations(end - cursor):
notes.append(generator.model.make_event(f'{measure["id"]}_acoustic_{len(notes) + 1}', cursor, duration, 'rest', written=written) | {'voice': 'voice_arranged'})
cursor += duration
for start, group in itertools.groupby(attacks, key=lambda n: generator.model.fraction(n['onset'])):
rest(start)
group = list(group)
pitches = sorted((p for n in group for p in n['pitches']), key=lambda p: (generator.model.pitch_number(p), p['tablature']['string']))
pitches = [{k: v for k, v in p.items() if k != 'stem'} for p in pitches]
duration = generator.model.fraction(group[0]['duration'])
notes.append(generator.model.make_event(f'{measure["id"]}_acoustic_{len(notes) + 1}', start, duration, 'note', pitches, group[0]['written']) | {'voice': 'voice_arranged'})
cursor = start + duration
rest(length)
if not attacks and length == generator.model.meter_length(measure['meter']):
sounding = [(generator.model.fraction(n['onset']), generator.model.fraction(n['onset']) + generator.model.fraction(p['duration']), p)
for v in measure['voices'] for n in v['notes'] for p in n['pitches']]
boundaries = sorted({fractions.Fraction(), length, *(t for a, b, _ in sounding for t in (a, b))})
notes = []
for a, b in zip(boundaries, boundaries[1:]):
active = sorted((p for start, end, p in sounding if start <= a < end), key=lambda p: (generator.model.pitch_number(p), p['tablature']['string']))
for duration, written in generator.accompaniment.written_durations(b - a):
pitches = [{k: v for k, v in p.items() if k not in ('tie_from', 'tie_to', 'stem')} for p in active]
note = generator.model.make_event(f'{measure["id"]}_acoustic_{len(notes) + 1}', a, duration, 'note' if pitches else 'rest', pitches, written)
note['voice'] = 'voice_arranged'
for old, new in zip(active, note['pitches']):
fragments.setdefault(old['id'], []).append(new)
notes.append(note)
a += duration
if not sounding and length == generator.model.meter_length(measure['meter']):
notes = [generator.model.make_event(f'{measure["id"]}_acoustic_1', fractions.Fraction(), length, 'rest', written={'type': 'whole', 'dots': 0}) | {'voice': 'voice_arranged', 'measure_rest': True}]
measure['voices'] = [{'id': 'voice_arranged', 'notes': notes}]
for pieces in fragments.values():
for a, b in zip(pieces, pieces[1:]):
a['tie_to'], b['tie_from'] = b['id'], a['id']
for start, end in edges:
if start in fragments or end in fragments:
a = fragments[start][-1] if start in fragments else originals[start]
b = fragments[end][0] if end in fragments else originals[end]
a['tie_to'], b['tie_from'] = b['id'], a['id']
def sounding_lanes(measures):
"""Recover complete string-lane events, preserving ties versus reattacks."""
tones, starts, cursor = {}, {}, fractions.Fraction()
for measure in measures:
for note in generator.score.measure_notes(measure):
for pitch in note['pitches']:
tones[pitch['id']] = pitch
starts[pitch['id']] = cursor + generator.model.fraction(note['onset'])
cursor += generator.model.fraction(measure['duration'])
groups = {}
for identifier, pitch in tones.items():
if pitch.get('tie_from') in tones:
if tones[pitch['tie_from']].get('tie_to') != identifier:
raise ValueError('broken acoustic sustain link')
continue
start, tail = starts[identifier], pitch
seen = {identifier}
while tail.get('tie_to') in tones:
target = tail['tie_to']
if target in seen:
raise ValueError('cyclic acoustic sustain')
continuation = tones[target]
if continuation.get('tie_from') != tail['id'] or starts[target] != starts[tail['id']] + generator.model.fraction(tail['duration']):
raise ValueError('broken acoustic sustain link or timing')
if generator.model.pitch_number(continuation) != generator.model.pitch_number(tail) or continuation.get('tablature') != tail.get('tablature'):
raise ValueError('acoustic sustain changes pitch or position')
seen.add(target)
tail = continuation
end = starts[tail['id']] + generator.model.fraction(tail['duration'])
string = pitch.get('tablature', {}).get('string')
if string is None:
raise ValueError('acoustic comping requires placed notes')
groups.setdefault((start, end), set()).add('bass' if string >= 5 else 'upper')
return groups
def validate_assignment(measures, events):
expected = {}
for e in events:
lanes = ['bass', 'upper'] if e.lane == 'combined' else [e.lane]
expected.setdefault((e.start, e.end), set()).update(lanes)
if sounding_lanes(measures) != expected:
raise ValueError('rendered acoustic attacks disagree with the selected bass/upper assignment')
def validate_comping(document: dict) -> None:
"""Check complete sounding events, not barline or notation fragments."""
groups = sounding_lanes(document['staves'][0]['measures'])
events = []
for (start, end), lanes in groups.items():
if end <= start or (end - start < 1 and end - start != fractions.Fraction(1, 2)):
raise ValueError('acoustic comping requires quarter/eighth notes or authored sustains')
events.append((start, end))
events.sort()
# A combined attack is one interval with both lanes. Separate attacks must
# be sequential, including bass/upper alternation and cross-bar ties.
for i, a in enumerate(events):
for b in events[i + 1:]:
if a[1] > b[0]:
raise ValueError('acoustic sound must release before the next attack')
spans = []
for span in generator.harmonic_time.read(document['staves'][0]):
if spans and generator.accompaniment.same_chord(spans[-1].chord, span.chord):
spans[-1] = dataclasses.replace(spans[-1], end=span.end)
else:
spans.append(span)
for span in spans:
if span.chord is None:
continue
first = next((event for event in events if span.start <= event[0] < span.end), None)
# A bounded anticipated bass can already be sounding into this harmony.
anticipated = any(span.start - fractions.Fraction(1, 2) <= a < span.start < b and 'bass' in groups[a, b] for a, b in events)
if first and not anticipated and not any('bass' in groups[e] for e in events if e[0] == first[0]):
raise ValueError(f'measure {span.source_measure}, beat {span.beat}: first acoustic attack for a chord must include bass')
+16 -6
View File
@@ -8,6 +8,7 @@ import typing
import generator.acoustic
import generator.fretboard
import generator.harmony
import generator.hand_position
class Voicing(typing.NamedTuple):
bass: generator.fretboard.TabPosition
@@ -35,11 +36,14 @@ def candidates(requirements: generator.fretboard.ChordRequirements, complete_tri
return tuple(sorted(result))
@functools.lru_cache(maxsize=16384)
def movement(previous: Voicing, current: Voicing) -> int:
return sum(abs(a.fret - b.fret) for a, b in zip(previous, current)) + abs(previous.bass.string_number - current.bass.string_number)
def movement(previous: Voicing, current: Voicing, old_hand: int, hand: int) -> int:
return generator.hand_position.motion(previous, current, old_hand, hand, True).shift
class Cost(typing.NamedTuple):
extended_grips: int = 0
travel: int = 0
peak_position: int = 0
effort: int = 0
missing_tones: int = 0
@dataclasses.dataclass
@@ -47,14 +51,20 @@ class Placement:
cost: Cost
voicing: Voicing | None = None
previous: Placement | None = None
hand: int = 0
def advance(options: tuple[Voicing, ...], requirements: generator.fretboard.ChordRequirements, states: list[Placement]) -> list[Placement]:
result = []
result = {}
for voicing in options:
missing = len(set(requirements.allowed) - {p.midi % 12 for p in voicing})
cost, index = min((Cost(p.cost.travel + (movement(p.voicing, voicing) if p.voicing else 0), p.cost.missing_tones + missing), i) for i, p in enumerate(states))
result.append(Placement(cost, voicing, states[index]))
return result
for hand in generator.hand_position.regions(voicing):
for previous in states:
motion = generator.hand_position.motion(previous.voicing, voicing, previous.hand, hand, True)
cost = Cost(previous.cost.extended_grips + generator.fretboard.span_penalty(voicing), previous.cost.travel + motion.shift, max(previous.cost.peak_position, hand), previous.cost.effort + motion.ergonomics, previous.cost.missing_tones + missing)
key = (voicing, hand, cost.peak_position)
if key not in result or cost < result[key].cost:
result[key] = Placement(cost, voicing, previous, hand)
return list(result.values())
def select(spans: list[generator.acoustic.HarmonySpan]) -> list[Voicing]:
states = [Placement(Cost())]
+25 -22
View File
@@ -1,20 +1,13 @@
"""One learned accompaniment per instrument, reused at authored form positions."""
from __future__ import annotations
import copy
import fractions
import generator.accompaniment
import generator.acoustic
import generator.acoustic_voicing
import generator.electric
import generator.guitar
import generator.fretboard
import generator.model
import generator.parts
import generator.score
import generator.arrange.form
import generator.arrange.pickup
import generator.model
import generator.score
def harmonic_key(measure, previous):
@@ -25,43 +18,53 @@ def harmonic_key(measure, previous):
return (key(active), tuple((generator.model.fraction(h['onset']), key(h)) for h in measure['harmonies']
if generator.model.fraction(h['onset']) > 0), measure['duration'], measure['time_signature'])
def audit(source, documents):
def audit(source, documents, *, role_documents=False):
"""Compare music, not generated IDs, at every reused form position."""
authored = generator.score.source_staff(source)['measures']
result = {}
for part, document in documents.items():
if part == 'vocal':
for name, document in documents.items():
part = name.split('_')[0] if role_documents else name
wanted = {'solo': 'slash', 'melody': 'vocal' if part == 'vocal' else 'melody'}.get(name.split('_')[-1], 'accompaniment') if role_documents else 'accompaniment'
if part == 'vocal' and not role_documents:
continue
sections = generator.arrange.form.full_arrangement_sections(authored, part)
entry_positions = {s.source_measure_index for s in sections if s.role == 'accompaniment'}
entry_positions = {s.source_measure_index for s in sections if s.role == wanted}
measures = document['staves'][0]['measures']
carried = generator.accompaniment.carried_chords(measures)
seen, exceptions, offset, reused = {}, [], 0, 0
for si, section in enumerate(sections):
following = sections[si + 1] if si + 1 < len(sections) else None
for j in range(section.measure_count):
if section.role != 'accompaniment':
if section.role != wanted:
continue
m = measures[offset + j]
if j == section.measure_count - 1 and following and following.role == 'melody' and generator.arrange.pickup.enters(following, authored):
if wanted == 'accompaniment' and j == section.measure_count - 1 and following and following.role == 'melody' and generator.arrange.pickup.enters(following, authored):
exceptions.append({'measure': m['number'], 'reason': 'protected melody pickup'})
continue
if j == section.measure_count - 1 and following and following.role == 'slash' and generator.score.body_start_measure_index(authored):
if wanted == 'accompaniment' and j == section.measure_count - 1 and following and following.role == 'slash' and generator.score.body_start_measure_index(authored):
exceptions.append({'measure': m['number'], 'reason': 'source-defined solo pickup allocation'})
continue
position = section.source_measure_index + j
key = (section.source_measure_index + j, repr(harmonic_key(m, carried[offset + j])))
# A complete figure depends on both measures' effective harmony and
# source-defined participation. Changed final turnarounds/pickups are
# explicit contexts, not incidental changes between iterations.
first = generator.score.body_start_measure_index(authored)
block_start = first + 2 * ((position - first) // 2)
neighbors = range(max(section.source_measure_index, block_start), min(section.source_measure_index + section.measure_count, block_start + 2))
context = tuple(repr(harmonic_key(measures[offset + k - section.source_measure_index], carried[offset + k - section.source_measure_index])) for k in neighbors)
boundary = following.role if following and block_start + 2 >= section.source_measure_index + section.measure_count and generator.score.body_start_measure_index(authored) and following.role in ('slash', 'melody') else ''
key = (position, context, boundary)
signature = tuple((v['id'], generator.model.fraction(n['onset']), generator.model.fraction(n['duration']),
tuple((generator.model.pitch_number(p), generator.model.fraction(p['duration']), p['tablature']['string'], p['tablature']['fret'], bool(p.get('tie_from')) if position not in entry_positions or generator.model.fraction(n['onset']) else False) for p in n['pitches']))
for v in m['voices'] for n in v['notes'] if n['pitches'])
tuple((generator.model.pitch_number(p), generator.model.fraction(p['duration']), p.get('tablature', {}).get('string'), p.get('tablature', {}).get('fret'), bool(p.get('tie_from')) if position not in entry_positions or generator.model.fraction(n['onset']) else False, bool(p.get('tie_to'))) for p in n['pitches']))
for v in m['voices'] for n in v['notes'])
if key in seen:
if signature != seen[key]:
raise ValueError(f'{part}, arrangement measure {m["number"]}: canonical accompaniment changed')
raise ValueError(f'{name}, arrangement measure {m["number"]}: canonical {wanted} changed')
reused += 1
else:
if any(k[0] == key[0] for k in seen):
exceptions.append({'measure': m['number'], 'reason': 'changed effective harmony or duration'})
exceptions.append({'measure': m['number'], 'reason': 'changed two-bar harmony, duration, or protected participation'})
seen[key] = signature
offset += section.measure_count
result[part] = {'reused_bars': reused, 'distinct_form_bars': len(seen), 'exceptions': exceptions}
result[name] = {'reused_bars': reused, 'distinct_form_bars': len(seen), 'exceptions': exceptions}
return result
+119
View File
@@ -0,0 +1,119 @@
"""Assemble source-defined role windows without composing or respelling."""
from __future__ import annotations
import copy
import fractions
import generator.accompaniment
import generator.arrange.form
import generator.arrange.pickup
import generator.composition_types
import generator.fretboard
import generator.model
import generator.parts
import generator.score
import generator.validation
def mask(document, allowed):
"""Apply source-defined role exclusions, without observing another part."""
absolute = fractions.Fraction()
for measure in document['staves'][0]['measures']:
length = generator.model.fraction(measure['duration'])
for voice in measure['voices']:
selected = []
for n in voice['notes']:
start = absolute + generator.model.fraction(n['onset'])
end = start + generator.model.fraction(n['duration'])
intervals = [(max(start, a), min(end, b)) for a, b in allowed if a < end and b > start]
for a, b in intervals:
note = copy.deepcopy(n)
if a != start:
note['onset'] = generator.model.rational(a - absolute)
for pitch in note['pitches']:
pitch.pop('tie_from', None)
generator.arrange.pickup.truncate(note, b - absolute)
if a < b:
selected.append(note)
voice['notes'] = fill(selected, length, measure['id'] + '_' + voice['id'], voice['id'])
absolute += length
staff = document['staves'][0]
staff['tuplets'] = generator.arrange.pickup.retain_links(staff['measures'], staff.get('tuplets', []))
def fill(notes, length, prefix, voice='voice_arranged'):
notes = sorted(notes, key=lambda n: generator.model.fraction(n['onset']))
result = []
cursor = fractions.Fraction()
def rests(end):
nonlocal cursor
for duration, written in generator.accompaniment.written_durations(end - cursor):
result.append(generator.model.make_event(prefix + '_rest_' + str(len(result)), cursor, duration, 'rest', written=written) | {'voice': voice})
cursor += duration
for n in notes:
start = generator.model.fraction(n['onset'])
if start < cursor:
raise ValueError(prefix + ': overlapping independently generated roles')
rests(start)
n['voice'] = voice
result.append(n)
cursor = start + generator.model.fraction(n['duration'])
rests(length)
return result
def improvisation(source, template, part):
"""Fill the source's solo allocation, including pickups, with beat slashes."""
document = copy.deepcopy(template)
staff = document['staves'][0]
for field in ('tuplets', 'octave_shifts', 'scale_spans'):
staff[field] = []
for measure in staff['measures']:
measure['id'] = part + '_improv_' + measure['id']
measure['voices'] = [{'id': 'voice_arranged', 'notes': generator.parts.generated_voice(measure, 'slash')}]
generator.score.reidentify(staff['measures'], [])
plan = generator.arrange.form.FormPlan.read(source.document(), part)
mask(document, [(a, b) for a, b, role in plan.windows if role == part + '_solo'])
return document
def assemble(source, results, *, solos_enabled=True):
"""Union prevalidated role windows; no selection or pitch/fingering rewrite."""
documents = {}
for part in generator.parts.PART_TYPES:
selected = [results[r]['document'] for r in generator.composition_types.ROLES
if r.startswith(part + '_') and (solos_enabled or not r.endswith('_solo'))]
if not solos_enabled and part != 'vocal':
selected.append(improvisation(source, selected[0], part))
document = copy.deepcopy(selected[0])
staff = document['staves'][0]
if part == 'vocal':
documents[part] = document
continue
staff['tuplets'] = []
staff['octave_shifts'] = []
staff['scale_spans'] = []
for other in selected:
for field in ('tuplets', 'octave_shifts', 'scale_spans'):
staff[field].extend(copy.deepcopy(other['staves'][0].get(field, [])))
for i, m in enumerate(staff['measures']):
# Tuplet rests belong to the source/role rhythm and must survive union.
lanes = {}
for d in selected:
for voice in d['staves'][0]['measures'][i]['voices']:
lane = voice['id'] if part == 'acoustic' and voice['id'] in ('upper', 'bass') else 'voice_arranged'
sounding = [copy.deepcopy(n) for n in voice['notes'] if n['pitches'] or n.get('tuplet_ids') or n.get('notehead') == 'slash']
if sounding:
lanes.setdefault(lane, []).extend(sounding)
lanes = lanes or {'voice_arranged': []}
m['voices'] = [{'id': lane, 'notes': fill(notes, generator.model.fraction(m['duration']), m['id'] + '_' + lane, lane)} for lane, notes in lanes.items()]
# Attribute changes belong to source melody pickups and are assembly metadata.
for d in selected:
other = d['staves'][0]['measures'][i]
if other.get('attributes'):
m['attributes'] = copy.deepcopy(other['attributes'])
staff['tuplets'] = generator.arrange.pickup.retain_links(staff['measures'], staff['tuplets'])
owners = {n['id']: v['id'] for m in staff['measures'] for v in m['voices'] for n in v['notes']}
for span in staff['tuplets']:
span['voice'] = owners[span['start']]
generator.validation.validate_document(document)
generator.fretboard.validate_document(document)
documents[part] = document
return documents
+72
View File
@@ -0,0 +1,72 @@
"""The recorded three-bar hold, expressed once as source-derived score time."""
import copy
import fractions
import generator.accompaniment
import generator.acoustic_voicing
import generator.arrange.ending_plan
import generator.comping
import generator.fretboard
import generator.model
import generator.parts
import generator.score
import generator.vocabulary
def chord(source):
effective = [{**m, 'harmonies': [h for h in m['harmonies'] if not h.get('chord_optional')]} for m in source]
prior = generator.accompaniment.carried_chords(effective)[-1]
return generator.accompaniment.active_chord(effective[-1], generator.model.fraction(effective[-1]['duration']), prior)
def append(source, output, part, *, sounding=False, center=55, composition=None, incoming=None):
composition = composition or generator.vocabulary.current()
if not source or not output:
return
model = generator.arrange.ending_plan.template(source)
harmony = chord(source)
grip = ()
if sounding:
if harmony is None:
raise ValueError('Ending: final performed harmony is missing or N.C.; cannot invent a closing chord')
options = generator.comping.voicings(generator.comping.semantic_key(harmony), part, composition=composition)
recent = {}
for m in reversed(output):
for n in sorted(generator.score.measure_notes(m), key=lambda n: generator.model.fraction(n['onset']), reverse=True):
for p in n['pitches']:
if 'tablature' in p:
tab = p['tablature']
recent.setdefault(tab['string'], generator.fretboard.TabPosition(tab['string'], tab['fret'], int(generator.model.pitch_number(p)) - 12))
if len(recent) >= 4:
break
previous = tuple(recent[s] for s in sorted(recent, reverse=True))
if part == 'acoustic':
bass = next((recent[s] for s in (5, 6) if s in recent), None)
previous = generator.acoustic_voicing.Voicing(bass, *(recent[s] for s in (4, 3, 2))) if bass and all(s in recent for s in (4, 3, 2)) else ()
if incoming is not None:
previous, hand = incoming
else:
hand = None
costs = {v: generator.comping.local_cost(part, generator.comping.semantic_key(harmony), v, center, composition=composition) for v in options}
path, _, _ = generator.comping.select_grips((options,), (costs,), part, 'ending-position', left=previous, left_hand=hand)
grip = path[0]
length = generator.model.fraction(model['duration'])
previous = None
for index in range(generator.arrange.ending_plan.BARS):
measure = generator.parts.build_measure(model, f'measure_{len(output) + 1}', 'rest', part, None, 'Ending' if index == 0 else '')
measure['ending_sustain'] = True
if index == 0 and harmony:
measure['harmonies'] = [{**copy.deepcopy(harmony), 'onset': generator.model.rational(0)}]
measure['harmonies'][0].pop('chord_optional', None)
if grip:
notes, cursor = [], fractions.Fraction()
for duration, written in generator.accompaniment.written_durations(length):
n = generator.model.make_event(f'ending_{part}_{index}_{len(notes)}', cursor, duration, 'note', generator.fretboard.chord_pitches(harmony, grip), written)
n['voice'] = 'voice_arranged'
if previous:
for a, b in zip(previous['pitches'], n['pitches']):
a['tie_to'], b['tie_from'] = b['id'], a['id']
notes.append(n)
previous = n
cursor += duration
measure['voices'] = [{'id': 'voice_arranged', 'notes': notes}]
output.append(measure)
generator.score.reidentify(output[-generator.arrange.ending_plan.BARS:], [])
+22
View File
@@ -0,0 +1,22 @@
"""Source-derived ending geometry, independent of instrument composition."""
import copy
import fractions
import generator.model
BARS = 3
def template(source):
result = copy.deepcopy(source[-1])
# An ending is three full bars in the final active meter, never a pickup.
for change in result.get('attributes', []):
for key in ('meter', 'key', 'clef', 'transpose', 'staff_details'):
if key in change:
result[key] = copy.deepcopy(change[key])
result.update(duration=generator.model.rational(generator.model.meter_length(result['meter'])), implicit=False,
attributes=[], harmonies=[], voices=[], tempos=[], section_label='')
result['time_signature'] = generator.model.meter_label(result['meter'])
return result
def duration(source):
return BARS * generator.model.fraction(template(source)['duration']) if source else fractions.Fraction()
+58
View File
@@ -1,8 +1,12 @@
from __future__ import annotations
import dataclasses
import fractions
import typing
import generator.arrange.ending_plan
import generator.arrange.pickup
import generator.model
import generator.score
@dataclasses.dataclass(frozen=True)
@@ -55,3 +59,57 @@ def full_arrangement_sections(measures: list[dict], part_type: str) -> list[Arra
for label, start, count, index in specs
if count > 0
]
@dataclasses.dataclass(frozen=True)
class FormPlan:
sections: tuple[ArrangementSection, ...]
windows: tuple[tuple[fractions.Fraction, fractions.Fraction, str], ...]
stops: tuple[tuple[int, fractions.Fraction] | None, ...]
@classmethod
def read(cls, document, part):
source = generator.score.source_staff(document)['measures']
sections = tuple(full_arrangement_sections(source, part))
stops = tuple(section_stop(source, section, sections[i + 1] if i + 1 < len(sections) else None) for i, section in enumerate(sections))
return cls(sections, _windows(document, part, sections), stops)
def section_stop(source, section, following):
if following is None or not generator.score.body_start_measure_index(source):
return None
last = section.source_measure_index + section.measure_count - 1
pad = generator.arrange.pickup.offset(source[last], source[0])
if following.role == 'slash':
return last, pad
if following.role == 'melody' and generator.arrange.pickup.enters(following, source):
attacks = [generator.model.fraction(note['onset']) for note in generator.score.measure_notes(source[0]) if note['pitches']]
if attacks:
return last, pad + min(attacks)
return None
def windows(document, part):
return FormPlan.read(document, part).windows
def _windows(document, part, sections):
source = generator.score.source_staff(document)['measures']
result, cursor = [], fractions.Fraction()
for section in sections:
duration = sum((generator.model.fraction(m['duration']) for m in source[section.source_measure_index:section.source_measure_index + section.measure_count]), fractions.Fraction())
role = {'slash': 'solo', 'vocal': 'melody'}.get(section.role, section.role)
if section.role in ('vocal', 'melody') and generator.arrange.pickup.enters(section, source) and result:
attacks = [generator.model.fraction(n['onset']) for n in generator.score.measure_notes(source[0]) if n['pitches']]
if attacks:
start = cursor - generator.model.fraction(source[0]['duration']) + min(attacks)
a, _, old = result[-1]
result[-1] = (a, start, old)
result.append((start, cursor, part + '_' + role))
end = cursor + duration
start = cursor
if section.role == 'slash' and generator.score.body_start_measure_index(source) and result:
# Allocate the source's complete pickup bar before composition. This
# does not inspect either generated solo; a role may leave it silent.
start = cursor - generator.model.fraction(source[0]['duration'])
a, _, old = result[-1]
result[-1] = (a, start, old)
result.append((start, end, part + '_' + role))
cursor = end
result.append((cursor, cursor + generator.arrange.ending_plan.duration(source), part + ('_accompaniment' if part != 'vocal' else '_rest')))
return tuple(result)
+26 -21
View File
@@ -2,35 +2,31 @@ from __future__ import annotations
import copy
import fractions
import pathlib
import generator.accompaniment
import generator.arrange.accompaniment
import generator.acoustic
import generator.acoustic_voicing
import generator.arrange.ending
import generator.arrange.form
import generator.arrange.pickup
import generator.comping
import generator.electric
import generator.fretboard
import generator.guitar
import generator.melody
import generator.model
import generator.musicxml
import generator.parts
import generator.score
import generator.solo.arrangement
import generator.comping
import generator.vocabulary
import generator.production
FINAL_SECTION_INDEX = 5
def arrange_document(document: dict, part_type: str) -> dict:
def arrange_document(document: dict, part_type: str, *, composition=None) -> dict:
"""Canonical source-only template; solos are inserted by production roles."""
composition = composition or generator.vocabulary.CompositionContext.create(generator.vocabulary.load(), part_type + '_accompaniment')
document = generator.parts.prepare_document(document)
with generator.vocabulary.using(generator.vocabulary.load(), part_type + '_accompaniment'):
backing = generator.comping.Canonical(document, part_type, 'canonical') if part_type != 'vocal' else None
return _arrange_document(document, part_type, accompaniment=backing)
backing = generator.comping.Canonical(document, part_type, 'canonical', composition=composition) if part_type != 'vocal' else None
return _arrange_document(document, part_type, accompaniment=backing, composition=composition)
def section_source(source: list[dict], section, next_section=None) -> list[dict]:
result = copy.deepcopy(source)
@@ -43,12 +39,14 @@ def section_source(source: list[dict], section, next_section=None) -> list[dict]
generator.arrange.pickup.harmonies(destination, result[0])
return result
def _arrange_document(document: dict, part_type: str, plans=None, *, owned=None, accompaniment=None) -> dict:
def _arrange_document(document: dict, part_type: str, plan=None, *, owned=None, accompaniment=None, composition=None, placement_report=None) -> dict:
composition = composition or generator.vocabulary.current()
if part_type not in generator.parts.PART_TYPES:
raise ValueError(f'unknown arrangement part: {part_type}')
staff = generator.score.source_staff(document)
source = staff['measures']
sections = generator.arrange.form.full_arrangement_sections(source, part_type)
plan = plan or generator.arrange.form.FormPlan.read(document, part_type)
sections = plan.sections
output, tuplets, octave_shifts, voicing_origins = [], [], [], []
absolute = fractions.Fraction()
source_starts = []
@@ -61,10 +59,12 @@ def _arrange_document(document: dict, part_type: str, plans=None, *, owned=None,
section_measures = section_source(source, section, sections[index + 1] if index + 1 < len(sections) else None)
previous = generator.accompaniment.carried_chords(section_measures)
segment = []
stop = plan.stops[index]
next_section = sections[index + 1] if index + 1 < len(sections) else None
for si in range(section.source_measure_index, section.source_measure_index + section.measure_count):
m = section_measures[si]
if role == 'accompaniment' and accompaniment is not None:
result = accompaniment(m, previous[si], si)
result = accompaniment(m, previous[si], si, sources=section_measures, bounds=(section.source_measure_index, section.source_measure_index + section.measure_count), stop=stop)
result['id'] = f'measure_{len(output) + len(segment) + 1}'
result['section_label'] = section.label if not segment else ''
else:
@@ -97,24 +97,29 @@ def _arrange_document(document: dict, part_type: str, plans=None, *, owned=None,
octave_shifts.append({**shift, 'id': f'pickup_{section.section_index}_{shift["id"]}', 'start': generator.model.rational(offset + low), 'end': generator.model.rational(offset + high)})
output.extend(segment)
absolute += segment_length
if sections and sections[-1].section_index == FINAL_SECTION_INDEX:
generator.arrange.ending.append(source, output, part_type,
sounding=part_type != 'vocal' and (owned is None or 'accompaniment' in owned),
center=composition.role(part_type + '_accompaniment').get('center', 55), composition=composition, incoming=accompaniment.last_position if accompaniment is not None else None)
tuplets = generator.arrange.pickup.retain_links(output, tuplets)
result = generator.score.make_arranged_document(document, staff, staff_id='staff_arranged_' + part_type, staff_name=part_type.capitalize(), role='vocal' if part_type == 'vocal' else 'guitar', arrangement_part_type=part_type, measures=output, tuplets=tuplets, octave_shifts=octave_shifts)
result['metadata'].setdefault('tempo', 124)
if part_type == 'acoustic' and accompaniment is None and (owned is None or 'accompaniment' in owned):
generator.acoustic.prepare(result)
generator.acoustic_voicing.place(result)
if part_type == 'acoustic':
if accompaniment is None and (owned is None or 'accompaniment' in owned):
generator.acoustic.prepare(result)
generator.acoustic_voicing.place(result)
generator.acoustic.validate_comping(result)
generator.acoustic.combine(result)
elif part_type == 'electric' and (owned is None or 'melody' in owned):
generator.melody.harmonize(result)
generator.guitar.place_guitar(result)
report = generator.guitar.place_guitar(result, composition=composition)
if generator.accompaniment.connect_continuations(result):
generator.guitar.place_guitar(result)
report = generator.guitar.place_guitar(result, composition=composition)
if placement_report is not None:
placement_report.update(report)
# Source labels identify the head while arranging; published labels identify
# the complete performance, including its lead-in and repeated choruses.
for number, measure in enumerate(output, 1):
measure['number'] = str(number)
generator.fretboard.validate_document(result)
return result
def generate_performance_scores(source_dir: pathlib.Path, output_dir: pathlib.Path, *, composition_jobs=2, cache_dir=None, progress=False, timings=None) -> int:
return generator.production.generate_tree(source_dir, output_dir, jobs=composition_jobs, cache_dir=cache_dir, progress=progress, timings=timings)
+68
View File
@@ -0,0 +1,68 @@
"""Validate and copy supplied recordings without synthesis or transformation."""
from __future__ import annotations
import fractions
import hashlib
import json
import re
import shutil
import wave
import generator.model
import generator.performance
TEMPOS = tuple(range(60, 121, 10))
def describe_wav(path, root, *, song_id='', bpm=0):
if path.is_symlink() or not path.is_file() or not path.resolve().is_relative_to(root.resolve()):
raise ValueError(f'{path}: expected a contained regular WAV')
try:
with wave.open(str(path), 'rb') as audio:
channels, rate, frames = audio.getnchannels(), audio.getframerate(), audio.getnframes()
if audio.getcomptype() != 'NONE' or audio.getsampwidth() != 2 or channels not in (1, 2) or not 8000 <= rate <= 192000 or frames <= 0:
raise ValueError('expected nonempty mono/stereo PCM16 WAV')
remaining = frames
while remaining:
count = min(remaining, 65536)
if len(audio.readframes(count)) != count * channels * 2:
raise ValueError('truncated WAV data')
remaining -= count
except (wave.Error, EOFError) as error:
raise ValueError(f'{path}: invalid WAV: {error}') from error
with path.open('rb') as source:
digest = hashlib.file_digest(source, 'sha256').hexdigest()
return dict(path=path.relative_to(root).as_posix(), sha256=digest, channels=channels, sample_rate=rate, frames=frames, song_id=song_id, bpm=bpm)
def copy_audio(static, destination, song_ids):
entries = []
inputs = [(static / 'sounds' / name, '', 0) for name in ('beat1.wav', 'beat2.wav')]
for path in sorted((static / 'backing').glob('*.wav')):
match = re.fullmatch(r'([a-z0-9]+(?:_[a-z0-9]+)*)_(60|70|80|90|100|110|120)\.wav', path.name)
if not match:
raise ValueError(f'{path}: unsupported backing filename or tempo')
if match[1] not in song_ids:
continue
inputs.append((path, match[1], int(match[2])))
for source, song_id, bpm in inputs:
description = describe_wav(source, static, song_id=song_id, bpm=bpm)
target = destination / description['path']
target.parent.mkdir(parents=True, exist_ok=True)
shutil.copyfile(source, target)
entries.append(description)
return entries
def validate_recording_lengths(root, entries):
durations = {}
for path in sorted((root / 'songs').glob('*.json')):
document = json.loads(path.read_text())
performance = generator.performance.timing(document)
song_id = performance['song_id']
duration = generator.model.fraction(performance['duration']) + performance['count_in_beats']
if song_id in durations and durations[song_id] != duration:
raise ValueError(f'{song_id}: parts disagree about performance duration')
durations[song_id] = duration
for entry in entries:
if entry['song_id']:
seconds = fractions.Fraction(entry['frames'], entry['sample_rate'])
if seconds < durations[entry['song_id']] * 60 / entry['bpm']:
raise ValueError(f"{entry['path']}: backing recording is shorter than count-in and score")
+82
View File
@@ -0,0 +1,82 @@
"""Content identities and atomic storage shared by generator cache adapters."""
from __future__ import annotations
import ast
import contextlib
import functools
import hashlib
import json
import os
import pathlib
import shutil
import tempfile
ROOT = pathlib.Path(__file__).resolve().parent
@functools.lru_cache(maxsize=256)
def imports(content):
modules = set()
for node in ast.walk(ast.parse(content)):
if isinstance(node, ast.Import):
modules.update(alias.name for alias in node.names if alias.name.startswith('generator.'))
elif isinstance(node, ast.ImportFrom) and node.module and node.module.startswith('generator'):
modules.add(node.module)
modules.update(node.module + '.' + alias.name for alias in node.names)
return tuple(sorted(modules))
def source_identity(entrypoints):
"""Conservatively include the transitive imports of explicit stage roots.
Read bytes on every call, so edits in a long-lived build process invalidate
both code content and newly introduced dependencies. Only parsing is cached.
"""
pending, sources = list(entrypoints), {}
while pending:
module = pending.pop()
relative = module.split('.')[1:]
path = ROOT.joinpath(*relative).with_suffix('.py') if relative else ROOT / '__init__.py'
if not path.is_file():
path = ROOT.joinpath(*relative, '__init__.py')
if path in sources or not path.is_file():
continue
content = path.read_bytes()
sources[path] = hashlib.sha256(content).hexdigest()
pending.extend(imports(content))
pending.extend('.'.join(module.split('.')[:i]) for i in range(1, len(module.split('.'))))
return {path.relative_to(ROOT).as_posix(): sources[path] for path in sorted(sources)}
def fingerprint(value):
return hashlib.sha256(json.dumps(value, sort_keys=True, separators=(',', ':')).encode()).hexdigest()
def write_json(path, value):
path.parent.mkdir(parents=True, exist_ok=True)
temporary = None
try:
with tempfile.NamedTemporaryFile('w', dir=path.parent, delete=False) as output:
temporary = pathlib.Path(output.name)
json.dump(value, output, sort_keys=True)
os.replace(temporary, path)
finally:
if temporary is not None:
temporary.unlink(missing_ok=True)
def has_symlink(path):
return any(parent.is_symlink() for parent in (path, *path.parents))
@contextlib.contextmanager
def stage_entry(entry, prefix):
if has_symlink(entry.parent):
raise ValueError('cache directories must not be symlinks')
entry.parent.mkdir(parents=True, exist_ok=True)
if entry.is_symlink() or entry.is_file():
entry.unlink(missing_ok=True)
entry.mkdir(exist_ok=True)
with tempfile.TemporaryDirectory(prefix=prefix, dir=entry.parent) as temporary:
yield pathlib.Path(temporary)
def publish_files(entry, staged, names):
"""Publish complete files in order, with the artifact manifest last."""
for name in names:
target = entry / name
if target.is_dir() and not target.is_symlink():
shutil.rmtree(target)
(staged / name).replace(target)
+18 -5
View File
@@ -10,7 +10,7 @@ import sys
if __name__ == '__main__' and __package__ is None:
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
import generator.performance
import generator.audio_assets
APPLICATION_ID = 0x56414D50
SONG_COLUMNS = """
@@ -45,10 +45,21 @@ def metadata(path: pathlib.Path, root: pathlib.Path) -> dict:
raise ValueError('presentation requires a generated Pico title image; regenerate assets')
if not isinstance(staff['name'], str):
raise ValueError('staff name must be a string')
solos_enabled = meta.get('solos_enabled', True)
if type(solos_enabled) is not bool:
raise ValueError('solos_enabled must be a boolean')
relative = path.relative_to(root)
return dict(id=path.stem, title=meta['title'], composer=meta['composer'], key_signature=key,
source_path=relative.as_posix(), source_json=text,
measure_count=len(staff['measures']), total_pages=len(presentation['pages']), title_image=title_image, part=staff['name'])
measure_count=len(staff['measures']), total_pages=len(presentation['pages']), title_image=title_image, part=staff['name'], solos_enabled=int(solos_enabled))
VARIANT_ERRORS = """
SELECT json_extract(source_json, '$.music.metadata.song_id'), part FROM songs
WHERE json_extract(source_json, '$.music.staves[0].arranged') = 1
GROUP BY json_extract(source_json, '$.music.metadata.song_id'), part
HAVING (part IN ('Acoustic', 'Electric') AND (count(*) != 2 OR sum(solos_enabled) != 1))
OR (part = 'Vocal' AND (count(*) != 1 OR sum(solos_enabled) != 1))
"""
def populate(connection: sqlite3.Connection, root: pathlib.Path, audio_assets=None) -> None:
if not root.is_dir():
@@ -58,19 +69,19 @@ def populate(connection: sqlite3.Connection, root: pathlib.Path, audio_assets=No
for path in sorted(root.glob('sounds/*.wav')):
if path.name not in ('beat1.wav', 'beat2.wav'):
raise ValueError(f'{path}: unknown metronome sample')
audio_assets.append(generator.performance.describe_wav(path, root))
audio_assets.append(generator.audio_assets.describe_wav(path, root))
for path in sorted(root.glob('backing/*.wav')):
match = re.fullmatch(r'([a-z0-9]+(?:_[a-z0-9]+)*)_(60|70|80|90|100|110|120)\.wav', path.name)
if not match:
raise ValueError(f'{path}: invalid backing filename')
audio_assets.append(generator.performance.describe_wav(path, root, song_id=match[1], bpm=int(match[2])))
audio_assets.append(generator.audio_assets.describe_wav(path, root, song_id=match[1], bpm=int(match[2])))
folder = root / 'songs'
if (folder.exists() or folder.is_symlink()) and not folder.is_dir():
raise ValueError(f'{folder}: score asset directory not found')
with connection:
connection.execute('BEGIN')
connection.execute(f'PRAGMA application_id = {APPLICATION_ID}')
connection.execute(f'CREATE TABLE songs ({SONG_COLUMNS}, part TEXT NOT NULL) STRICT')
connection.execute(f'CREATE TABLE songs ({SONG_COLUMNS}, part TEXT NOT NULL, solos_enabled INTEGER NOT NULL CHECK(solos_enabled IN (0, 1))) STRICT')
connection.execute('CREATE INDEX songs_menu ON songs(title, composer, part, id)')
connection.execute('CREATE TABLE resources (id TEXT PRIMARY KEY, value TEXT NOT NULL CHECK(json_valid(value))) STRICT')
connection.execute('INSERT INTO resources VALUES (?, ?)', ('audio', json.dumps(audio_assets)))
@@ -82,6 +93,8 @@ def populate(connection: sqlite3.Connection, root: pathlib.Path, audio_assets=No
connection.execute(f'INSERT INTO songs ({", ".join(row)}) VALUES ({", ".join("?" for _ in row)})', tuple(row.values()))
except (ValueError, KeyError, TypeError, sqlite3.Error) as error:
raise ValueError(f'{path}: {error}') from error
if connection.execute(VARIANT_ERRORS).fetchall():
raise ValueError('missing or duplicate solo variants; regenerate score assets')
if connection.execute('PRAGMA integrity_check').fetchall() != [('ok',)]:
raise ValueError('catalog integrity check failed')
+56
View File
@@ -0,0 +1,56 @@
"""Transposable guitar families, derived from the written chord and legal grips."""
import generator.fretboard
import generator.harmony
import generator.model
import generator.vocabulary
def acoustic(chord, grip, *, composition=None):
composition = composition or generator.vocabulary.current()
degrees = generator.harmony.degrees(chord)
root = int(generator.model.NATURAL[chord['root']['letter']] + generator.model.alteration(chord['root']['alter']))
classes = {d: (root + generator.harmony.degree_semitones(d, a)) % 12 for d, a in degrees.items()}
guide = next((d for d in (3, 4, 2) if d in degrees), None)
terminal = next((d for d in (7, 6) if d in degrees), None)
color = max((d for d in degrees if d > 7), default=None)
kind = 'extended' if terminal and color else 'tetrad' if terminal else 'triad'
bass = next((d for d in (1, 5, 3) if classes.get(d) == grip[0].midi % 12), None)
slots = {'root': 1, 'fifth': 5, 'guide': guide, 'terminal': terminal, 'color': color}
policy = composition.accompaniment('acoustic')['voicing_families']
orders = policy[kind].get(f'{grip[0].string_number}/{bass}', ())
upper = tuple(p.midi % 12 for p in grip[1:])
preferred = any(all(slots[s] in classes for s in order) and tuple(classes[slots[s]] for s in order) == upper for order in orders)
# The physical/harmonic enumerator remains authoritative: an explicit bass
# or an unrepresented extension can use another valid compact voicing.
return {'id': f'{kind}/s{grip[0].string_number}/bass{bass or "written"}/' + '-'.join(str(next((d for d in sorted(classes) if pc == classes[d]), 'bass')) for pc in upper),
'preferred': preferred, 'bass_degree': bass, 'bass_string': grip[0].string_number,
'relative_frets': [p.fret - grip[0].fret for p in grip]}
def electric(grip):
"""Classify actual voicing geometry, without inventing chord permissions."""
pitches = sorted(p.midi for p in grip)
if len(grip) == 3:
return 'three-note-shell'
if len(set(p % 12 for p in pitches)) < len(pitches):
return 'compact-doubled'
if len(pitches) == 4:
lifted = sorted([pitches[0] + 12, *pitches[1:]])
if lifted[-1] - lifted[0] < 12 and lifted[2] == pitches[0] + 12:
return 'drop-two'
return 'close-position' if pitches and pitches[-1] - pitches[0] < 12 else 'compact-open'
def coverage(chord, options, part, *, composition=None):
composition = composition or generator.vocabulary.current()
if part == 'electric':
return {name: sum(electric(v) == name for v in options) for name in composition.accompaniment('electric')['voicing_families']['rank']}
families = [acoustic(chord, v, composition=composition) for v in options]
result = []
for string in (5, 6):
for degree in (1, 5):
found = [f for f in families if f['bass_degree'] == degree and f['bass_string'] == string]
result.append({'bass_string': string, 'bass_degree': degree, 'candidates': len(found), 'preferred': sum(f['preferred'] for f in found),
'reason': '' if found else 'no legal grip for this bass under written harmony and current fret/span limits'})
return result
def span_coverage(options):
return {'primary': sum(not generator.fretboard.span_penalty(v) for v in options),
'fallback': sum(generator.fretboard.span_penalty(v) for v in options)}
+386 -166
View File
@@ -2,22 +2,26 @@
from __future__ import annotations
import copy
import dataclasses
import fractions
import functools
import json
import fractions
import typing
import generator.accompaniment
import generator.comping_rhythm
import generator.acoustic
import generator.acoustic_voicing
import generator.arrange.form
import generator.chord_families
import generator.comping_rhythm
import generator.fretboard
import generator.guitar
import generator.harmony
import generator.hand_position
import generator.model
import generator.parts
import generator.score
import generator.vocabulary
import generator.solo.policy
import generator.vocabulary
def semantic_key(chord):
return json.dumps({k: chord[k] for k in ('root', 'kind', 'degrees', 'bass', 'inversion') if k in chord}, sort_keys=True)
@@ -34,12 +38,15 @@ def requirements(chord, part):
raise ValueError('acoustic accompaniment requires a written bass, root or fifth')
return dataclasses.replace(result, basses=basses)
def voicings(key, part, *, composition=None):
return _voicings(key, part, composition or generator.vocabulary.current())
@functools.lru_cache(maxsize=2048)
def voicings(key, part):
def _voicings(key, part, composition):
chord = json.loads(key)
required = requirements(chord, part)
if part == 'electric':
options = generator.guitar.chord_positions(required, prune=False, profile='electric')
options = generator.guitar.chord_positions(required, prune=False, profile='electric', composition=composition)
elif part == 'acoustic':
degrees = generator.harmony.degrees(chord)
plain = degrees in ({1: 0, 3: 0, 5: 0}, {1: 0, 3: -1, 5: 0})
@@ -52,54 +59,91 @@ def voicings(key, part):
options = tuple(v for v in options if generator.fretboard.playable_attack((p, fractions.Fraction(1)) for p in v))
if not options:
layout = 'bass on 5/6 plus upper strings 2/3/4' if part == 'acoustic' else 'melody chord families on strings 1–4'
raise ValueError(f'{generator.harmony.symbol(chord)}: no legal {part} voicing ({layout}); required degrees/bass, no open strings, fret anchor 1–12 and three consecutive frets remain binding')
raise ValueError(f'{generator.harmony.symbol(chord)}: no legal {part} voicing ({layout}); required degrees/bass, no open strings, fret anchor 1–12 and at most {generator.fretboard.MAX_FRET_SPAN} consecutive frets remain binding')
return tuple(sorted(options))
def movement(part, previous, current):
if not previous or not current:
return 0
if part == 'acoustic':
return generator.acoustic_voicing.movement(previous, current)
return generator.guitar.movement(previous, current)
def movement(part, previous, current, old_hand, hand):
return generator.hand_position.motion(previous, current, old_hand, hand, part == 'acoustic').shift
def local_cost(part, key, grip, center):
class VoicingCost(typing.NamedTuple):
extended_grips: int = 0
family: int = 0
travel: int = 0
peak_position: int = 0
effort: fractions.Fraction = fractions.Fraction()
missing_tones: int = 0
register: fractions.Fraction = fractions.Fraction()
def plus(self, other):
return VoicingCost(*(max(a, b) if field == 'peak_position' else a + b for field, a, b in zip(self._fields, self, other)))
def moved(self, distance, ergonomics=0):
return self._replace(travel=self.travel + distance, effort=self.effort + ergonomics)
def local_cost(part, key, grip, center, *, composition=None):
composition = composition or generator.vocabulary.current()
required = requirements(json.loads(key), part)
register = abs(fractions.Fraction(sum(p.midi for p in grip), len(grip)) - center)
register = generator.guitar.voicing_preferences(grip, generator.guitar.voicing_preference(part + '_accompaniment', center, composition=composition))
if part == 'electric':
value = generator.guitar.voicing_cost(grip, 'electric', required.allowed)
return (value.string_shortfall, value.effort, value.missing_tones, register)
# As in acoustic harmony-span placement: travel first, then completeness.
return (0, 0, len(set(required.allowed) - {p.midi % 12 for p in grip}), register)
value = generator.guitar.voicing_cost(grip, 'electric', required.allowed, composition=composition)
return VoicingCost(extended_grips=value.extended_grips, family=3 * value.string_shortfall + value.family_penalty, effort=value.effort, missing_tones=value.missing_tones, register=register)
# Keep the familiar families, then compare physical effort before position.
# Sounding register only breaks otherwise equal placement decisions.
family = generator.chord_families.acoustic(json.loads(key), grip, composition=composition)
return VoicingCost(extended_grips=generator.fretboard.span_penalty(grip), family=int(not family['preferred']), missing_tones=len(set(required.allowed) - {p.midi % 12 for p in grip}), register=register)
def select_grips(layers, costs, part, seed, *, left=(), right=(), close=False):
"""Exact small-state dynamic programming; never prune by hand center.
def select_grips(layers, costs, part, seed, *, left=(), right=(), left_hand=None, right_hand=None, close=False, fixed_hands=None):
"""Return complete grips, cost and hand windows, including repeat travel.
Electric effort includes its melody grip cost and hand-center travel.
Acoustic effort follows all four voices, including a bass-string change.
Fixing the first grip permits an exact repeat-join cost without a beam.
A concrete grip may occupy several windows. Preserve distinct earlier peaks
at a common grip/hand, and fix both starting values for a cyclic path.
"""
if not layers:
return (), (0, 0, 0, 0)
ranks = [{v: generator.solo.policy.stable_rank(seed, (i, v)) for v in layer} for i, layer in enumerate(layers)]
return (), VoicingCost(), ()
def hands(grip, fixed=None):
options = generator.hand_position.regions(grip)
if fixed is not None:
return tuple(h for h in options if h == fixed)
return options
retained = []
for i, layer in enumerate(layers):
tier = min(costs[i][v].extended_grips for v in layer)
fixed = fixed_hands[i] if fixed_hands is not None else None
options = tuple((v, h) for v in layer if costs[i][v].extended_grips == tier for h in hands(v, fixed))
if not options:
raise ValueError(f'accompaniment span {i}: no grip fits the committed hand position')
retained.append(options)
ranks = [{v: generator.solo.policy.stable_rank(seed, (i, v)) for v, _ in layer} for i, layer in enumerate(retained)]
winners = []
for first in layers[0] if close else [None]:
states = {left: ((0, 0, 0, 0), (), ())}
for i, layer in enumerate(layers):
for first in retained[0] if close else [None]:
states = {(left, h, h): (VoicingCost(peak_position=h), (), (), ()) for h in hands(left, left_hand)}
for i, layer in enumerate(retained):
following = {}
for grip in [first] if i == 0 and first is not None else layer:
local = costs[i][grip]
choices = []
for previous, (cost, ties, path) in states.items():
total = tuple(a + b for a, b in zip(cost, local))
total = (total[0], total[1] + movement(part, previous, grip), *total[2:])
choices.append((total, (*ties, ranks[i][grip]), (*path, grip)))
following[grip] = min(choices)
states = following
for grip, (cost, ties, path) in states.items():
travel = movement(part, grip, first if close else right)
winners.append(((cost[0], cost[1] + travel, *cost[2:]), ties, path))
cost, _, path = min(winners)
return path, cost
for grip, hand in [first] if i == 0 and first is not None else layer:
local = costs[i][grip]._replace(peak_position=hand)
for (previous, old_hand, _), (cost, ties, path, positions) in states.items():
motion = generator.hand_position.motion(previous, grip, old_hand, hand, part == 'acoustic')
total = cost.plus(local).moved(motion.shift, motion.ergonomics)
candidate = (total, (*ties, (ranks[i][grip], hand)), (*path, grip), (*positions, hand))
key = (grip, hand, total.peak_position)
if key not in following or candidate < following[key]:
following[key] = candidate
# Future travel is identical at a common concrete grip and hand.
best = {}
for (grip, hand, _), value in following.items():
primary = value[0][:3]
best[grip, hand] = min(best.get((grip, hand), primary), primary)
states = {key: value for key, value in following.items() if value[0][:3] == best[key[:2]]}
endpoints = [first] if close else [(right, h) for h in hands(right, right_hand)]
for (grip, hand, _), (cost, ties, path, positions) in states.items():
for endpoint, end_hand in endpoints:
motion = generator.hand_position.motion(grip, endpoint, hand, end_hand, part == 'acoustic')
total = cost.plus(VoicingCost(peak_position=end_hand)).moved(motion.shift, motion.ergonomics)
winners.append((total, ties, path, positions))
if not winners:
raise ValueError('accompaniment boundary grip does not fit the committed hand position')
cost, _, path, positions = min(winners)
return path, cost, positions
@dataclasses.dataclass(frozen=True)
class HarmonyChoice:
@@ -110,168 +154,344 @@ class HarmonyChoice:
events: tuple
figure: dict
options: tuple
hand: int | None = None
@property
def key(self):
return (self.index, self.start, self.end, semantic_key(self.chord), self.events)
def split_measures(flat, inputs, part):
"""Project a selected sounding figure into notation; barlines create ties only."""
output, fragments, original = [], {}, {}
cursor = fractions.Fraction()
for m, prior, index in inputs:
length = generator.model.fraction(m['duration'])
result = generator.parts.build_measure(m, f'comp_{part}_{index}', 'rest', part, prior)
voices = []
for voice in flat['voices']:
notes = []
for n in voice['notes']:
start = generator.model.fraction(n['onset'])
end = start + generator.model.fraction(n['duration'])
a, b = max(cursor, start), min(cursor + length, end)
if a >= b:
continue
for duration, written in generator.accompaniment.written_durations(b - a):
pitches = [{k: v for k, v in p.items() if k not in ('tie_from', 'tie_to')} for p in n['pitches']]
event = generator.model.make_event(f'comp_{part}_{index}_{voice["id"]}_{len(notes)}', a - cursor, duration, 'note' if pitches else 'rest', pitches, written)
event['voice'] = voice['id']
for old, new in zip(n['pitches'], event['pitches']):
fragments.setdefault(old['id'], []).append(new)
original[old['id']] = old
notes.append(event)
a += duration
voices.append({'id': voice['id'], 'notes': notes})
result['voices'] = voices
for chord in result['harmonies']:
chord.pop('chord_optional', None)
output.append(result)
cursor += length
for pieces in fragments.values():
for a, b in zip(pieces, pieces[1:]):
a['tie_to'], b['tie_from'] = b['id'], a['id']
for identifier, old in original.items():
if old.get('tie_to') in fragments:
a, b = fragments[identifier][-1], fragments[old['tie_to']][0]
a['tie_to'], b['tie_from'] = b['id'], a['id']
return tuple(output)
class Canonical:
def __init__(self, document, part, seed):
def __init__(self, document, part, seed, *, composition=None, plan=None):
self.composition = composition or generator.vocabulary.current()
self.part, self.seed = part, seed
self.policy = generator.vocabulary.role(part + '_accompaniment')
self.policy = self.composition.role(part + '_accompaniment')
self.cache, self._reports, self._rhythm_reports = {}, {}, {}
measures = generator.score.source_staff(document)['measures']
self.cache_positions = {}
self.last_position = ((), 0)
self.measures = generator.score.source_staff(document)['measures']
# A held accompaniment chord may continue into the bar containing the
# source melody pickup. Keep its voice identity through that splice.
self.voice_id = self.measures[0]['voices'][0]['id']
self.melody = generator.comping_rhythm.melody_contexts(document)
first_index = generator.score.body_start_measure_index(measures)
sections = generator.arrange.form.full_arrangement_sections(measures, part)
self.closed = any(a.role == b.role == 'accompaniment' and a.source_measure_index + a.measure_count == len(measures)
and b.source_measure_index == first_index for a, b in zip(sections, sections[1:]))
carried = generator.accompaniment.carried_chords(measures)
inputs = []
for index in range(first_index, len(measures)):
source = copy.deepcopy(measures[index])
for chord in source['harmonies']:
chord.pop('chord_optional', None)
inputs.append((source, carried[index], index))
layers = tuple(generator.comping_rhythm.candidates(m, prior, part, self.melody[i], seed + '/' + str(i)) for m, prior, i in inputs)
rhythms = generator.comping_rhythm.select(layers, seed)
self.rhythms = {i: r for (_, _, i), r in zip(inputs, rhythms)}
prepared = [(m, prior, i, self.prepare(m, prior, i, r)) for (m, prior, i), r in zip(inputs, rhythms)]
active = tuple(s for _, _, _, spans in prepared for s in spans if s.events)
path, self.path_cost = self.select(active, close=self.closed)
self.first = generator.score.body_start_measure_index(self.measures)
plan = plan or generator.arrange.form.FormPlan.read(document, part)
sections = plan.sections
self.closed = any(a.role == b.role == 'accompaniment' and a.source_measure_index + a.measure_count == len(self.measures)
and b.source_measure_index == self.first for a, b in zip(sections, sections[1:]))
carried = generator.accompaniment.carried_chords(self.measures)
self.groups = []
index = self.first
while index < len(self.measures):
size = 1
if index + 1 < len(self.measures):
lengths = [generator.model.fraction(m['duration']) for m in self.measures[index:index + 2]]
if self.measures[index]['time_signature'] == self.measures[index + 1]['time_signature'] and any(tuple(map(fractions.Fraction, p['lengths'])) == tuple(lengths) for p in self.composition.accompaniment(part)['patterns']):
size = 2
self.groups.append(tuple((self.measures[i], carried[i], i) for i in range(index, index + size)))
index += size
self.acoustic_cache = {}
self.pair_breaks = {self.first, len(self.measures)}
self.pair_stops = []
for section in sections:
if section.role == 'accompaniment':
self.pair_breaks.update((section.source_measure_index, section.source_measure_index + section.measure_count))
self.pair_stops = [stop for section, stop in zip(sections, plan.stops) if section.role == 'accompaniment' and stop is not None]
breaks = [(i, fractions.Fraction()) for i in self.pair_breaks] + self.pair_stops
choices, locations, self.groove_report = generator.comping_rhythm.choose_cycles(self.groups, part, self.melody, seed, breaks=breaks, composition=self.composition)
self.patterns = {g[0][2]: (p, a) for g, (p, a, _) in zip(self.groups, choices)}
self.locations = {g[0][2]: location for g, location in zip(self.groups, locations)}
selected = [r for _, _, r in choices]
self.block_rhythms = {group[0][2]: rhythm for group, rhythm in zip(self.groups, selected)}
prepared = [self.prepare(group, rhythm) for group, rhythm in zip(self.groups, selected)]
active = tuple(span for spans in prepared for span in spans if span.events)
self.canonical_spans = {group[0][2]: spans for group, spans in zip(self.groups, prepared)}
path, self.path_cost, self.hand_order = self.select(active, close=self.closed)
self.base = dict(zip((s.key for s in active), path))
self.hands = dict(zip((s.key for s in active), self.hand_order))
self.order = tuple((s.index, s.start, v) for s, v in zip(active, path))
previous = path[-1] if self.closed and path else ()
for source, prior, index, spans in prepared:
selected = tuple(self.base[s.key] for s in spans if s.events)
self.cache[self.key(source, prior, index)] = self.render(source, prior, index, spans, selected, previous, False)
if selected:
previous = selected[-1]
self.connect_holds(inputs)
self.rhythms = {}
previous = (path[-1], self.hand_order[-1]) if self.closed and path else ((), 0)
for group, rhythm, spans in zip(self.groups, selected, prepared):
grips = tuple((self.base[s.key], self.hands[s.key]) for s in spans if s.events)
key = (self.key(group), rhythm.signature) if part == 'acoustic' else self.key(group)
self.cache[key], self.cache_positions[key] = self.render(group, rhythm, spans, grips, previous, False)
cursor = fractions.Fraction()
for m, _, i in group:
length = generator.model.fraction(m['duration'])
self.rhythms[i] = dataclasses.replace(rhythm, events=tuple(dataclasses.replace(e, start=max(e.start, cursor) - cursor, end=min(e.end, cursor + length) - cursor, harmonic_time=e.harmonic_time - cursor if e.harmonic_time is not None else None) for e in rhythm.events if e.start < cursor + length and e.end > cursor))
cursor += length
if grips:
previous = grips[-1]
@property
def report(self):
return [row for key in sorted(self._reports, key=lambda k: (k[0], repr(k))) for row in self._reports[key]]
return [row for key in sorted(self._reports, key=repr) for row in self._reports[key]]
@property
def placement_report(self):
previous = self.hand_order[-1] if self.closed and self.hand_order else None
shifts = []
for hand in self.hand_order:
shifts.append(abs(hand - previous) if previous is not None else 0)
previous = hand
return {'version': generator.hand_position.VERSION, 'priority': 'hand travel, maximum hand position, ergonomics, coverage/register, stable tie',
**generator.hand_position.summary(shifts), 'peak_position': self.path_cost.peak_position,
'cost': {k: str(v) for k, v in self.path_cost._asdict().items()},
'positions': [{'source_index': i, 'onset': str(t), 'hand_position': h} for (i, t, _), h in zip(self.order, self.hand_order)]}
@property
def rhythm_report(self):
return [self._rhythm_reports[key] for key in sorted(self._rhythm_reports, key=lambda k: (k[0], repr(k)))]
return [row for key in sorted(self._rhythm_reports, key=repr) for row in self._rhythm_reports[key]]
@staticmethod
def key(source, prior, index):
return (index, tuple((a, b, semantic_key(c) if c else '') for a, b, c in generator.comping_rhythm.spans(source, prior)),
source['duration'].__repr__())
def prepare(self, source, prior, index, rhythm):
def key(inputs, limit=None):
return (tuple((i, str(generator.model.fraction(m['duration'])), tuple((str(a), str(b), semantic_key(c) if c else '') for a, b, c in generator.comping_rhythm.spans(m, p))) for m, p, i in inputs), str(limit))
def candidates(self, inputs, limit=None):
flat = generator.comping_rhythm.flatten(inputs)
melody, cursor, lengths = [], fractions.Fraction(), []
for m, _, i in inputs:
melody.extend((a + cursor, b + cursor) for a, b in self.melody[i])
lengths.append(generator.model.fraction(m['duration']))
cursor += lengths[-1]
return generator.comping_rhythm.candidates(flat, None, self.part, tuple(melody), self.seed + '/' + str(inputs[0][2]), lengths=tuple(lengths), limit=limit, composition=self.composition)
def acoustic_realizations(self, sources, bounds=None, stop=None):
"""Assign the canonical attack stream once, before splitting it into blocks.
A variant uses the same patterns with the source's actual harmony and
participation boundaries. No selected notes from another role enter here.
"""
carried = generator.accompaniment.carried_chords(sources)
full = tuple((m, carried[i], i) for i, m in enumerate(sources))
key = (self.key(full), bounds, stop)
if key in self.acoustic_cache:
return self.acoustic_cache[key]
starts = [fractions.Fraction()]
for m in sources:
starts.append(starts[-1] + generator.model.fraction(m['duration']))
breaks = [(i, fractions.Fraction()) for i in self.pair_breaks | set(bounds or ())] + self.pair_stops
if stop:
breaks.append(stop)
groups, raw = [], []
for original in self.groups:
group = tuple(full[i] for _, _, i in original)
index = group[0][2]
pattern, anticipate = self.patterns[index]
limit = starts[stop[0]] + stop[1] - starts[index] if stop and any(i == stop[0] for _, _, i in group) else None
rhythm = generator.comping_rhythm.realize(pattern, group, 'acoustic', self.melody, anticipate=anticipate, limit=limit, boundary=True, assign=False)
if rhythm is None:
raise ValueError(f'source measure {sources[index]["number"]}: selected acoustic rhythm cannot fit written harmony')
raw.append(rhythm)
groups.append(group)
context = generator.comping_rhythm.acoustic_context(groups, self.melody, breaks)
realized = generator.comping_rhythm.realize_acoustic_form(raw, context)
result = {g[0][2]: r for g, r in zip(groups, realized)}
self.acoustic_cache[key] = result
return result
def prepare(self, inputs, rhythm):
flat = generator.comping_rhythm.flatten(inputs)
spans = []
for start, end, chord in generator.comping_rhythm.spans(source, prior):
offsets, cursor = [], fractions.Fraction()
for m, _, i in inputs:
offsets.append((cursor, i))
cursor += generator.model.fraction(m['duration'])
for start, end, chord in generator.comping_rhythm.spans(flat, None):
if not chord:
continue
events = tuple(e for e in rhythm.events if start <= e.start < end)
offset, index = next((a, i) for a, i in reversed(offsets) if a <= start)
events = tuple(e for e in rhythm.events if start <= (e.harmonic_time if e.harmonic_time is not None else e.start) < end)
try:
options = voicings(semantic_key(chord), self.part)
options = voicings(semantic_key(chord), self.part, composition=self.composition)
except ValueError as error:
raise ValueError(f'source measure {source["number"]}, beat {start + 1}: {error}') from error
raise ValueError(f'source measure {inputs[index - inputs[0][2]][0]["number"]}, beat {start - offset + 1}: {error}') from error
spans.append(HarmonyChoice(index, start, end, chord, events, dict(rhythm.families), options))
self._rhythm_reports[self.key(source, prior, index)] = {
'source_index': index, 'families': dict(rhythm.families), 'source_melody': [(str(a), str(b)) for a, b in self.melody[index]],
'contributions': dict(rhythm.contributions), 'selection_cost': rhythm.cost, 'exceptions': rhythm.exceptions,
'layers': {lane: {'attacks': sum(e.lane == lane for e in rhythm.events),
'events': [{'onset': str(e.start), 'duration': str(e.end - e.start)} for e in rhythm.events if e.lane == lane], 'tied_continuations': 0} for lane, _ in rhythm.families},
'overlap_beats': str(sum((max(0, min(a.end, b.end) - max(a.start, b.start)) for a in rhythm.events for b in rhythm.events if a.lane == 'bass' and b.lane == 'upper'), fractions.Fraction()))}
return tuple(spans)
def select(self, spans, *, left=(), right=(), close=False, fixed=None):
layers = tuple((fixed[s.key],) if fixed and s.key in fixed else s.options for s in spans)
costs = tuple({v: local_cost(self.part, semantic_key(s.chord), v, self.policy.get('center', 55)) for v in layer}
for s, layer in zip(spans, layers))
return select_grips(layers, costs, self.part, self.seed, left=left, right=right, close=close)
def __call__(self, source, prior, index):
key = self.key(source, prior, index)
def select(self, spans, *, left=(), right=(), left_hand=None, right_hand=None, close=False):
layers = tuple(s.options for s in spans)
costs = tuple({v: local_cost(self.part, semantic_key(s.chord), v, self.policy.get('center', 55), composition=self.composition) for v in layer} for s, layer in zip(spans, layers))
return select_grips(layers, costs, self.part, self.seed, left=left, right=right, left_hand=left_hand, right_hand=right_hand, close=close, fixed_hands=tuple(s.hand for s in spans))
def __call__(self, source, prior, index, *, sources=None, bounds=None, stop=None):
group = next((g for g in self.groups if any(i == index for _, _, i in g)), ((source, prior, index),))
original_group = group
sources = sources or self.measures
if self.part == 'acoustic' and source != sources[index]:
sources = [source if i == index else m for i, m in enumerate(sources)]
carried = generator.accompaniment.carried_chords(sources)
low, high = bounds or (self.first, len(sources))
group = tuple((source if i == index else sources[i], prior if i == index else carried[i], i) for _, _, i in group if low <= i < high)
limit = None
if stop and any(i == stop[0] for _, _, i in group):
limit = sum((generator.model.fraction(m['duration']) for m, _, i in group if i < stop[0]), fractions.Fraction()) + stop[1]
key = self.key(group, limit)
complete = None
if self.part == 'acoustic' and original_group[0][2] in self.patterns:
complete = self.acoustic_realizations(sources, (low, high), stop)[original_group[0][2]]
key = (key, complete.signature)
if key not in self.cache:
# Effective pickup/turnaround harmony may differ from the main form.
# Solve that measure between fixed canonical neighbors. Request order
# and previously generated arrangement sections cannot change it.
choices = generator.comping_rhythm.candidates(source, prior, self.part, self.melody[index], self.seed + '/' + str(index))
rhythm = generator.comping_rhythm.select((choices,), self.seed, self.rhythms.get(index - 1), self.rhythms.get(index + 1))[0]
spans = self.prepare(source, prior, index, rhythm)
before = [v for i, _, v in self.order if i < index]
after = [v for i, _, v in self.order if i > index]
left = before[-1] if before else self.order[-1][2] if self.closed and self.order else ()
right = after[0] if after else self.order[0][2] if self.closed and self.order else ()
selected, _ = self.select(tuple(s for s in spans if s.events), left=left, right=right, fixed=self.base)
self.cache[key] = self.render(source, prior, index, spans, selected, left, True)
return copy.deepcopy(self.cache[key])
def render(self, source, prior, index, spans, selected, previous, variant):
length = generator.model.fraction(source['duration'])
attacks, rows = [], []
start, end = group[0][2], group[-1][2]
offset = sum((generator.model.fraction(m['duration']) for m, _, i in original_group if i < start), fractions.Fraction())
if original_group[0][2] in self.patterns:
pattern, anticipate = self.patterns[original_group[0][2]]
if self.part == 'acoustic':
end_time = offset + (limit if limit is not None else sum(generator.model.fraction(m['duration']) for m, _, _ in group))
rhythm = dataclasses.replace(complete, events=tuple(dataclasses.replace(e, start=max(e.start, offset) - offset, end=min(e.end, end_time) - offset, harmonic_time=e.harmonic_time - offset if e.harmonic_time is not None and e.harmonic_time >= offset else None)
for e in complete.events if e.start < end_time and e.end > offset))
elif offset:
# Fit the incoming context before slicing. A raw template sustain
# may already have ended at a chord change; projecting it first
# would resurrect that note as an unintended new downbeat attack.
context = tuple((source if i == index else sources[i], prior if i == index else carried[i], i)
for _, _, i in original_group if i <= end)
incoming = generator.comping_rhythm.realize(pattern, context, self.part, self.melody, anticipate=anticipate, limit=offset + limit if limit is not None else None, boundary=True)
if incoming is None:
raise ValueError(f'source measure {source["number"]}: selected groove cannot fit incoming harmony')
pattern = {**pattern, 'events': [{'onset': str(e.start), 'duration': str(e.end - e.start),
'layer': e.lane, 'anticipate': e.harmonic_time is not None and e.lane in ('upper', 'electric')} for e in incoming.events]}
if self.part != 'acoustic':
pattern = generator.comping_rhythm.project(pattern, offset, tuple(generator.model.fraction(m['duration']) for m, _, _ in group))
rhythm = generator.comping_rhythm.realize(pattern, group, self.part, self.melody, anticipate=anticipate, limit=limit, boundary=True)
if rhythm is None:
raise ValueError(f'source measure {source["number"]}: selected groove cannot fit protected boundary')
else:
# A source pickup outside the repeating body uses the existing partial
# vocabulary. It never selects or changes the body groove.
rhythm = min(self.candidates(group, limit), key=lambda r: (r.cost, generator.solo.policy.stable_rank(self.seed, r.signature)))
spans = self.prepare(group, rhythm)
# Keep every unchanged harmonic interval's canonical grip, even when a
# neighbor loses an optional turnaround or a section starts mid-pattern.
fixed = []
for span in spans:
original = next((s for s in self.canonical_spans.get(original_group[0][2], ()) if s.key in self.base
and s.start <= span.start + offset < s.end and semantic_key(s.chord) == semantic_key(span.chord)), None)
fixed.append(dataclasses.replace(span, options=(self.base[original.key],), hand=self.hands[original.key]) if original else span)
spans = tuple(fixed)
before = [(v, h) for (i, _, v), h in zip(self.order, self.hand_order) if i < start]
after = [(v, h) for (i, _, v), h in zip(self.order, self.hand_order) if i > end]
left = before[-1] if before else (self.order[-1][2], self.hand_order[-1]) if self.closed and self.order else ((), 0)
right = after[0] if after else (self.order[0][2], self.hand_order[0]) if self.closed and self.order else ((), 0)
selected, _, hands = self.select(tuple(s for s in spans if s.events), left=left[0], right=right[0], left_hand=left[1], right_hand=right[1])
self.cache[key], self.cache_positions[key] = self.render(group, rhythm, spans, tuple(zip(selected, hands)), left, True, limit)
placement = self.cache_positions[key][index - group[0][2]]
if placement is not None:
self.last_position = placement
return copy.deepcopy(self.cache[key][index - group[0][2]])
def render(self, inputs, rhythm, spans, selected, previous, variant, limit=None):
flat = generator.comping_rhythm.flatten(inputs)
length = generator.model.fraction(flat['duration'])
index = inputs[0][2]
attacks, rows, placed_events = [], [], []
choices = iter(selected)
for span in spans:
grip = next(choices) if span.events else ()
grip, hand = next(choices) if span.events else ((), 0)
motion = generator.hand_position.motion(previous[0], grip, previous[1], hand, self.part == 'acoustic')
bass = grip[0] if grip and self.part == 'acoustic' else None
degrees = generator.harmony.degrees(span.chord)
root = int(generator.model.NATURAL[span.chord['root']['letter']] + generator.model.alteration(span.chord['root']['alter']))
rows.append({'source_index': index, 'onset': str(span.start), 'chord': generator.harmony.symbol(span.chord),
'figure': span.figure, 'tones': len(grip), 'bass': bool(bass), 'variant': variant,
rows.append({'source_index': span.index, 'onset': str(span.start), 'chord': generator.harmony.symbol(span.chord),
'figure': span.figure, 'pattern_id': rhythm.pattern_id, 'tones': len(grip), 'bass': bool(bass), 'variant': variant,
'family': (generator.chord_families.acoustic(span.chord, grip, composition=self.composition) if self.part == 'acoustic' else generator.chord_families.electric(grip)) if grip else None,
'family_coverage': generator.chord_families.coverage(span.chord, span.options, self.part, composition=self.composition),
'fret_span': generator.fretboard.fret_span(grip),
'span_group': ('fallback' if generator.fretboard.span_penalty(grip) else 'primary') if grip else None,
'span_candidates': generator.chord_families.span_coverage(span.options),
'positions': [{'string': p.string_number, 'fret': p.fret, 'sounding_midi': p.midi} for p in grip],
'bass_degree': next((d for d, a in degrees.items() if bass and (root + generator.harmony.degree_semitones(d, a)) % 12 == bass.midi % 12), None),
'bass_string': bass.string_number if bass else None,
'movement': movement(self.part, previous, grip), 'voicing_candidates': len(span.options)})
for event in span.events:
positions = (grip[0],) if event.lane == 'bass' else grip[1:] if event.lane == 'upper' else grip
attacks.append((event.lane, event.start, event.end, positions, span.chord))
'movement': motion.shift, 'voicing_candidates': len(span.options)})
if grip:
previous = grip
self._reports[self.key(source, prior, index)] = rows
local = local_cost(self.part, semantic_key(span.chord), grip, self.policy.get('center', 55), composition=self.composition)
rows[-1]['hand_position'] = hand
rows[-1]['voicing_cost'] = {'movement': motion.shift, 'hand_shift': motion.shift, 'finger_adjustment': motion.fingers,
'string_changes': motion.strings, 'grip_effort': str(local.effort), 'register_tiebreak': str(local.register),
'secondary_effort': str(motion.ergonomics + local.effort)}
for event in span.events:
placed_events.append((event.start, event.end, (grip, hand)))
lanes = ['bass', 'upper'] if event.lane == 'combined' else [event.lane]
for lane in lanes:
positions = (grip[0],) if lane == 'bass' else grip[1:] if lane == 'upper' else grip
attacks.append((lane, event.start, event.end, positions, span.chord))
if grip:
previous = (grip, hand)
key = self.key(inputs, limit)
if self.part == 'acoustic':
key = (key, rhythm.signature)
measure_hands, cursor = [], fractions.Fraction()
for m, _, _ in inputs:
end = cursor + generator.model.fraction(m['duration'])
played = sorted((a, b, p) for a, b, p in placed_events if a < end and b > cursor)
measure_hands.append(played[-1][2] if played else None)
cursor = end
self._reports[key] = rows
voices = []
notes, cursor, lane = [], fractions.Fraction(), ''
def emit(a, b, positions=(), chord=None):
nonlocal cursor
previous = None
for duration, written in generator.accompaniment.written_durations(b - a):
pitches = generator.fretboard.chord_pitches(chord, positions) if positions else []
n = generator.model.make_event(f'comp_{self.part}_{index}_{lane}_{len(notes)}', a, duration, 'note' if pitches else 'rest', pitches, written)
n['voice'] = lane
if self.part == 'acoustic':
n['stem'] = 'down' if lane == 'bass' else 'up'
if previous and pitches:
for old, new in zip(previous['pitches'], n['pitches']):
old['tie_to'], new['tie_from'] = new['id'], old['id']
notes.append(n)
previous = n
a += duration
cursor = b
for lane in ['upper', 'bass'] if self.part == 'acoustic' else ['electric']:
voice_id = lane if self.part == 'acoustic' else self.voice_id
notes, cursor = [], fractions.Fraction()
def emit(a, b, positions=(), chord=None):
previous = None
for duration, written in generator.accompaniment.written_durations(b - a):
pitches = generator.fretboard.chord_pitches(chord, positions) if positions else []
n = generator.model.make_event(f'comp_{self.part}_{index}_{lane}_{len(notes)}', a, duration, 'note' if pitches else 'rest', pitches, written)
n['voice'] = voice_id
if previous and pitches:
for old, new in zip(previous['pitches'], n['pitches']):
old['tie_to'], new['tie_from'] = new['id'], old['id']
notes.append(n)
previous = n
a += duration
for _, start, end, positions, chord in sorted((e for e in attacks if e[0] == lane), key=lambda e: e[1]):
if cursor < start:
emit(cursor, start)
emit(start, end, positions, chord)
cursor = end
if cursor < length:
emit(cursor, length)
voices.append({'id': lane, 'notes': notes})
result = generator.parts.build_measure(source, 'canonical', 'rest', self.part, prior)
result['voices'] = voices
return result
def connect_holds(self, inputs):
"""Only explicit sustained neighbors can share an attack across a barline.
These are canonical internal joins, never links across role boundaries.
The direct reattack remains when a grip or required attack count differs.
"""
for left, right in zip(inputs, inputs[1:]):
before = self.cache[self.key(*left)]
after = self.cache[self.key(*right)]
previous_chord = generator.accompaniment.active_chord(left[0], generator.model.fraction(left[0]['duration']), left[1])
next_chord = generator.accompaniment.active_chord(right[0], fractions.Fraction(), right[1])
if not generator.accompaniment.same_chord(previous_chord, next_chord):
continue
for a, b in zip(before['voices'], after['voices']):
if a['id'] == 'bass':
continue
old, new = a['notes'][-1], b['notes'][0]
minimum = 1 if a['id'] == 'upper' else 0
attacks = sum(bool(n['pitches']) and not any('tie_from' in p for p in n['pitches']) for n in b['notes'])
if not old['pitches'] or not new['pitches'] or attacks <= minimum or min(generator.model.fraction(n['duration']) for n in (old, new)) < 1:
continue
if [p['tablature'] for p in old['pitches']] != [p['tablature'] for p in new['pitches']]:
continue
for p, q in zip(old['pitches'], new['pitches']):
p['tie_to'], q['tie_from'] = q['id'], p['id']
row = self._rhythm_reports[self.key(*right)]['layers'][a['id']]
row['attacks'] -= 1
row['tied_continuations'] += 1
voices.append({'id': voice_id, 'notes': notes})
result = split_measures({'voices': voices}, inputs, self.part)
if self.part == 'acoustic':
generator.acoustic.validate_assignment(result, rhythm.events)
reports, cursor = [], fractions.Fraction()
for m, _, i in inputs:
duration = generator.model.fraction(m['duration'])
reports.append({'source_index': i, 'pattern_id': rhythm.pattern_id, 'pattern_start': index,
**next((self.locations[g[0][2]] for g in self.groups if any(j == i for _, _, j in g)), {}),
'families': dict(rhythm.families), 'contributions': dict(rhythm.contributions), 'selection_cost': rhythm.cost,
'exceptions': rhythm.exceptions, 'source_melody': [(str(a), str(b)) for a, b in self.melody[i]],
'events': [{'layer': e.lane, 'onset': str(max(e.start, cursor) - cursor), 'duration': str(min(e.end, cursor + duration) - max(e.start, cursor)),
'continuation': e.start < cursor, 'harmonic_target': str(e.harmonic_time - cursor) if e.harmonic_time is not None else None} for e in rhythm.events if e.start < cursor + duration and e.end > cursor]})
cursor += duration
self._rhythm_reports[key] = reports
return result, tuple(measure_hands)
+486 -136
View File
@@ -1,19 +1,79 @@
"""Bounded, source-only measure rhythms; acoustic layers are selected jointly."""
"""Complete, source-only comping figures. Time is in rational quarter notes."""
import dataclasses
import fractions
import itertools
import generator.accompaniment
import generator.model
import generator.solo.analysis
import generator.solo.policy
import generator.source
import generator.vocabulary
def meter_context(measure):
"""Nominal meter and explicit additive grouping, independent of bar length.
In particular, a three-quarter-note pickup or a 6/8 bar is not 3/4.
"""
groups = measure['meter']['groups']
if not groups or any(g['unit'] != 4 for g in groups):
raise ValueError(f"source measure {measure['number']}: no comping vocabulary for {measure['time_signature']}")
beats = tuple(b for g in groups for b in g['beats'])
total = sum(beats)
if total not in (3, 4, 5) or (len(beats) > 1 and beats not in ((3, 2), (2, 3))):
raise ValueError(f"source measure {measure['number']}: unsupported comping grouping {measure['time_signature']}")
return f'{total}/4', beats if len(beats) > 1 else ()
def grouping_for(run, melody):
"""Choose one source-only quintuple feel, shared by independent roles.
Written grouping wins. Otherwise compare actual chord changes, entrances
after an eighth-note breath, then all melodic attacks at the group boundary.
Counts are evidence, not inferred accents or performance dynamics.
"""
meter, explicit = meter_context(run[0][0][0])
if meter != '5/4':
return (), {'reason': 'simple_meter'}
if explicit:
return explicit, {'reason': 'written'}
evidence = {}
for boundary in (3, 2):
changes, entrances, attacks = 0, 0, 0
for group in run:
for m, prior, i in group:
changes += sum(a == boundary and c is not None for a, _, c in spans(m, prior))
context = melody[i]
for a, _ in context:
if a != boundary:
continue
attacks += 1
previous = max((b for x, b in context if x < a), default=fractions.Fraction())
entrances += a - previous >= fractions.Fraction(1, 2)
evidence[boundary] = (changes, entrances, attacks)
boundary = 2 if evidence[2] > evidence[3] else 3
return (boundary, 5 - boundary), {'reason': 'source' if evidence[2] != evidence[3] else 'default_3+2',
'boundary_evidence': {str(k): dict(zip(('chord_changes', 'melody_entrances', 'melody_attacks'), v)) for k, v in evidence.items()}}
def patterns_for(policy, measure, lengths, grouping=()):
meter, explicit = meter_context(measure)
grouping = explicit or grouping or ((3, 2) if meter == '5/4' else ())
# Untagged in-memory figures are allowed for independently authored unit
# tests; the resource loader requires metadata for every production entry.
return [p for p in policy['patterns'] if tuple(map(fractions.Fraction, p['lengths'])) == tuple(lengths)
and (p.get('meter') == 'partial' or (p.get('meter', meter) == meter and tuple(p.get('grouping', grouping)) == grouping))]
def relevant_policy(policy, measures):
"""An unused meter's vocabulary must not influence this role's decisions."""
meters = {meter_context(m)[0] for m in measures}
lengths = {generator.model.fraction(m['duration']) for m in measures}
return {**policy, 'patterns': [p for p in policy['patterns'] if p.get('meter') in meters
or (p.get('meter') == 'partial' and fractions.Fraction(p['lengths'][0]) in lengths)]}
@dataclasses.dataclass(frozen=True, order=True)
class Attack:
lane: str
start: fractions.Fraction
end: fractions.Fraction
harmonic_time: fractions.Fraction | None = None
@dataclasses.dataclass(frozen=True)
class Rhythm:
@@ -21,15 +81,16 @@ class Rhythm:
families: tuple
contributions: tuple
exceptions: tuple = ()
pattern_id: str = ''
@property
def cost(self):
return sum(value for _, value in self.contributions)
@property
def signature(self):
return tuple((e.lane, str(e.start), str(e.end - e.start)) for e in self.events)
return tuple((e.lane, str(e.start), str(e.end - e.start), str(e.harmonic_time)) for e in self.events)
def melody_contexts(document):
melody = generator.solo.analysis.attacks(document)
melody = generator.source.attacks(document)
result, cursor = [], fractions.Fraction()
for m in document['staves'][0]['measures']:
length = generator.model.fraction(m['duration'])
@@ -49,149 +110,438 @@ def spans(measure, prior):
result.append((a, b, chord))
return tuple(result)
def lane_score(events, lane, melody, harmony, length):
"""Named source-context preferences, independent of the deterministic seed."""
attacks = [a for a, b in melody if a >= 0]
occupied = sum((max(0, min(length, b) - max(0, a)) for a, b in melody), fractions.Fraction())
space = max(0, length - occupied)
busy = len(attacks) >= length
if lane == 'bass':
target = min(2, sum(c is not None and b - a >= 1 for a, b, c in harmony))
elif lane == 'upper':
target = 2.5 if space >= length / 2 else 1.5 if busy else 2
else:
target = .5 if busy else 1.5 if space >= length / 2 else 1
# A half-attack tolerance makes neighboring densities genuine alternatives.
# The objective does not always fill up to a layer's permitted maximum.
activity = .35 * max(0, abs(len(events) - target) - .5)
support, articulation = 0., 0.
for e in events:
# Supporting an entrance is different from doubling every moving note.
entrance = any(a == e.start and (i == 0 and a >= 0 or i > 0 and a - melody[i - 1][1] >= fractions.Fraction(1, 2)) for i, (a, _) in enumerate(melody))
moving = any(a <= e.start < b and b - a <= 1 for a, b in melody)
gap = not any(a <= e.start < b for a, b in melody)
if lane != 'bass':
support += -.2 if entrance else .25 if moving and e.start in attacks else -.15 if gap else 0
articulation += .12 if busy and e.end - e.start > 1 else .08 if not busy and e.end - e.start < 1 else 0
elif e.start and e.start.denominator != 1:
support += .15
divisor = max(1, len(events))
return (('activity', activity), ('melody_support', support / divisor), ('duration_contrast', articulation / divisor))
def flatten(inputs):
"""Harmony/timing adapter only; never concatenate separately chosen rhythms."""
first = inputs[0][0]
result = {**first, 'harmonies': []}
cursor = fractions.Fraction()
for m, prior, _ in inputs:
chord = generator.accompaniment.active_chord(m, fractions.Fraction(), prior)
initial = chord or {'kind': 'none'}
result['harmonies'].append({**initial, 'onset': generator.model.rational(cursor)})
result['harmonies'].extend({**h, 'onset': generator.model.rational(cursor + generator.model.fraction(h['onset']))} for h in m['harmonies'] if generator.model.fraction(h['onset']))
cursor += generator.model.fraction(m['duration'])
result['duration'] = generator.model.rational(cursor)
return result
def representatives(candidates, limit, seed):
"""Keep counts, placements and duration families before the final cutoff."""
unique = {}
for candidate in candidates:
key = candidate.signature
rank = (candidate.cost, generator.solo.policy.stable_rank(seed, key))
if key not in unique or rank < unique[key][0]:
unique[key] = rank, candidate
ordered = [v for _, v in sorted(unique.values(), key=lambda item: item[0])]
groups = {}
shapes = set()
for c in ordered:
counts = tuple((lane, sum(e.lane == lane for e in c.events)) for lane, _ in c.families)
shape = (counts, c.families, any(e.start.denominator != 1 for e in c.events))
# Round-robin attack counts first. Otherwise many cosmetic variants of
# the cheapest density can exclude every one- or three-attack idea.
if shape not in shapes:
groups.setdefault(counts, []).append(c)
shapes.add(shape)
result = []
while groups and len(result) < limit:
for key in list(groups):
result.append(groups[key].pop(0))
if not groups[key]:
del groups[key]
if len(result) == limit:
break
def validate_events(events, part, lengths=None):
ordered = sorted(events, key=lambda e: e.start)
for e in ordered:
duration = e.end - e.start
if duration <= 0:
raise ValueError('comping event must have positive sounding duration')
if part == 'acoustic':
if e.lane not in ('bass', 'upper', 'combined') or (duration < 1 and duration != fractions.Fraction(1, 2)):
raise ValueError('acoustic attacks require quarter/eighth notes or authored sustains')
elif e.lane != 'electric':
raise ValueError('electric comping requires chord events')
for i, a in enumerate(ordered):
for b in ordered[i + 1:]:
if a.end > b.start:
raise ValueError('comping sound must release before the next attack')
def assign_acoustic(events, harmony, breaks=()):
"""Assign attacks, not notation fragments, across a complete source span.
Pair left to right within an effective harmony. An anticipated attack is
already playing its target harmony. Form/participation boundaries break
pairs; ordinary barlines and computational blocks do not.
"""
ordered = sorted(events, key=lambda e: e.start)
if len({e.start for e in ordered}) != len(ordered):
raise ValueError('acoustic rhythm must have one event per attack position')
def region(event):
time = event.harmonic_time if event.harmonic_time is not None else event.start
return next(i for i, (a, b, _) in enumerate(harmony) if a <= time < b)
lanes, i = ['combined'] * len(ordered), 0
while i + 1 < len(ordered):
a, b = ordered[i:i + 2]
if b.start - a.start == fractions.Fraction(1, 2) and region(a) == region(b) and not any(a.start < t <= b.start for t in breaks):
lanes[i:i + 2] = ['bass', 'upper']
i += 2
else:
i += 1
result = [dataclasses.replace(e, lane=lane) for e, lane in zip(ordered, lanes)]
# One rhythm-guitar stream: every new attack releases the previous sound,
# including a change of lane. A combined attack has one shared release.
for i, a in enumerate(result):
following = result[i + 1].start if i + 1 < len(result) else a.end
result[i] = dataclasses.replace(a, end=min(a.end, following))
# Shortening must not strand an anticipation before its promised arrival.
# Rebind that event to the current chord, then reconsider its pair once.
expired = {e.start for e in result if e.harmonic_time is not None and e.end <= e.harmonic_time}
if expired:
rebound = []
for e in ordered:
if e.start in expired:
boundary = next(b for a, b, _ in harmony if a <= e.start < b)
e = dataclasses.replace(e, harmonic_time=None, end=min(e.end, boundary))
rebound.append(e)
return assign_acoustic(rebound, harmony, breaks)
validate_events(result, 'acoustic')
return tuple(result)
def lane_candidates(measure, prior, lane, melody, policy, seed):
def fit(pattern, measure, prior, part, *, anticipate=False, limit=None, assign=True):
"""Bind a complete figure to written harmony, with bounded early arrivals."""
length = generator.model.fraction(measure['duration'])
limit = length if limit is None else min(length, limit)
harmony = spans(measure, prior)
active = [(a, b, c) for a, b, c in harmony if c]
if not active:
return Rhythm((), ((lane, 'space'),), (('activity', 0.),)),
low, high = policy['layers'][lane]['attacks']
# Genuinely different harmony gets a gesture, not its own density budget.
required = [(a, b) for a, b, c in active if b - a >= (2 if lane == 'bass' else 1)]
if lane == 'bass' and active[0][0] == 0 and not any(a == 0 for a, _ in required):
required.insert(0, active[0][:2])
if lane == 'electric' and len(active) == 1 and generator.accompaniment.same_chord(active[0][2], prior):
required = []
# With very fast harmonic rhythm, establish the edges and longest spans.
# Short intervening chords may be silent; no incompatible sustain is kept.
if len(required) > high + 1:
edges = [required[0], required[-1]]
required = sorted(edges + sorted(required[1:-1], key=lambda ab: (-(ab[1] - ab[0]), ab[0]))[:high - 1])
extra = int(len(required) > high)
grid = fractions.Fraction(policy['grid'])
positions = {i * grid for i in range(int(length / grid) + 1) if i * grid < length}
positions.update(a for a, _, _ in active)
positions = sorted(t for t in positions if any(a <= t < b for a, b, _ in active))
events, exceptions, available = [], [], []
for row in pattern['events']:
start = fractions.Fraction(row['onset'])
end = min(start + fractions.Fraction(row['duration']), limit)
if start >= limit:
continue
active = next(((a, b, c) for a, b, c in harmony if a <= start < b), None)
if active is None or active[2] is None:
exceptions.append(('space', 'no written harmony at ' + str(start)))
continue
available.append((dict(row), start, end, active))
lengths = tuple(map(fractions.Fraction, pattern.get('lengths', (length,))))
for row, start, end, active in available:
_, boundary, chord = active
target = None
if anticipate and row.get('anticipate'):
future = next(((a, b, c) for a, b, c in harmony if a == start + fractions.Fraction(1, 2) and c), None)
if future and future[0] < end and not generator.accompaniment.same_chord(chord, future[2]):
target, boundary = future[0], future[1]
end = min(end, boundary)
events.append(Attack('acoustic' if part == 'acoustic' else row['layer'], start, end, target))
try:
if part == 'acoustic' and assign:
events = assign_acoustic(events, harmony)
exceptions.append(('layer_assignment', 'combined attacks; same-harmony eighth pairs use bass then upper'))
elif part == 'acoustic' and any(e.end <= e.start or (e.end - e.start < 1 and e.end - e.start != fractions.Fraction(1, 2)) for e in events):
raise ValueError('acoustic articulation cannot fit this boundary')
if part != 'acoustic' or assign:
validate_events(events, part, lengths)
except ValueError:
return None
return tuple(events), tuple(exceptions)
def evaluate(events, part, melody, harmony, lengths):
activity, support, coverage, articulation = 0., 0., 0., 0.
cursor = fractions.Fraction()
for length in lengths:
local = [e for e in events if cursor <= e.start < cursor + length]
attacks = [a for a, b in melody if cursor <= a < cursor + length]
busy = len(attacks) >= length
sounding = any(e.start < cursor + length and e.end > cursor for e in events)
target = (1 if busy else 1.5) if part == 'electric' else (2 if busy else 2.5)
# Sustained occupancy and planned space are not missing attacks.
activity += .22 * max(0, abs(len({e.start for e in local}) - target) - .75) if not (sounding and not local) else 0
# A bass paired with the upper chord is one rhythmic attack, regardless
# of whether unequal releases require two internal lane events.
attacks_by_time = {e.start: max((v for v in local if v.start == e.start), key=lambda v: v.end) for e in local}
for e in attacks_by_time.values():
gap = not any(a <= e.start < b for a, b in melody)
entrance = any(a == e.start and (i == 0 or a - melody[i - 1][1] >= fractions.Fraction(1, 2)) for i, (a, _) in enumerate(melody))
support += -.2 if entrance else -.12 if gap else .18 if busy and e.start in attacks else 0
articulation += .08 if busy and e.end - e.start > 2 else 0
cursor += length
for a, b, chord in harmony:
if chord and b - a >= 1 and not any(e.start < b and e.end > a for e in events):
coverage += .18 # A preference, never a chord-attack quota.
divisor = max(1, len(lengths))
return tuple((k, v / divisor) for k, v in (('activity', activity), ('melody_support', support), ('harmonic_support', coverage), ('articulation', articulation)))
def candidates(measure, prior, part, melody, seed, *, lengths=None, limit=None, grouping=(), composition=None):
composition = composition or generator.vocabulary.current()
lengths = lengths or (generator.model.fraction(measure['duration']),)
policy = composition.accompaniment(part)
result = []
for count in range(low, high + extra + 1):
for onsets in itertools.combinations(positions, count):
if lane == 'bass' and active[0][0] == 0 and (not onsets or onsets[0] != 0):
for pattern in patterns_for(policy, measure, lengths, grouping):
for anticipate in (False, True):
fitted = fit(pattern, measure, prior, part, anticipate=anticipate, limit=limit)
if fitted is None:
continue
if any(not any(a <= t < b for t in onsets) for a, b in required):
events, exceptions = fitted
if anticipate and not any(e.harmonic_time is not None for e in events):
continue
if any(b - a < 1 for a, b in zip(onsets, onsets[1:])):
continue
for family in policy['layers'][lane]['families']:
durations = policy['families'][family]
events = []
for i, a in enumerate(onsets):
end = next(b for start, b, c in active if start <= a < b)
following = onsets[i + 1] if i + 1 < len(onsets) else length
duration = fractions.Fraction(durations[i % len(durations)])
events.append(Attack(lane, a, min(a + duration, following, end)))
exceptions = ((lane, 'extra attack for harmonic changes'),) if count > high else ()
contributions = (*lane_score(events, lane, melody, harmony, length), ('extra_attacks', .5 * bool(exceptions)))
result.append(Rhythm(tuple(events), ((lane, family if count else 'space'),), contributions, exceptions))
contributions = evaluate(events, part, melody, spans(measure, prior), lengths)
result.append(Rhythm(events, (('pattern', pattern['family']),), contributions, exceptions, pattern['id'] + ('.anticipated' if anticipate else '')))
if not result:
# A short partial bar can have fewer gestures, not invented subdivisions.
if length < 1:
a, b, _ = active[0]
return Rhythm((Attack(lane, a, b),), ((lane, 'partial'),), (('activity', 0.),)),
raise ValueError(f'measure {measure["number"]}: no {lane} rhythm within the bounded attack/spacing policy')
return representatives(result, policy['lane_candidates'], seed + '/' + lane)
raise ValueError(f'measure {measure["number"]}: no {part} pattern for lengths {lengths} and written harmonic/release constraints')
return representatives(result, policy['pattern_candidates'], seed)
def crowding(events):
times = sorted({e.start for e in events})
cost = .22 * sum(y - x < 1 for x, y in zip(times, times[1:]))
# Three successive half-beat changes are a busy figure even though each
# layer is sparse. Coincident attacks count as one hand action.
return cost + .5 * sum(z - x <= 1 for x, y, z in zip(times, times[1:], times[2:]))
def representatives(candidates, limit, seed):
unique = {}
for c in candidates:
rank = (c.cost, generator.solo.policy.stable_rank(seed, (c.pattern_id, c.signature)))
if c.signature not in unique or rank < unique[c.signature][0]:
unique[c.signature] = rank, c
ordered = [c for _, c in sorted(unique.values(), key=lambda item: item[0])]
retained, families = [], set()
for c in ordered:
if c.families not in families:
retained.append(c)
families.add(c.families)
retained.extend(c for c in ordered if c not in retained)
return tuple(retained[:limit])
def candidates(measure, prior, part, melody, seed):
policy = generator.vocabulary.data('accompaniment')
if part == 'electric':
return lane_candidates(measure, prior, 'electric', melody, policy, seed)
bass = lane_candidates(measure, prior, 'bass', melody, policy, seed)
upper = lane_candidates(measure, prior, 'upper', melody, policy, seed)
def project(pattern, offset, lengths):
"""Take a form-position slice, rather than restarting a pattern at an entry."""
end = offset + sum(lengths)
rows = []
for row in pattern['events']:
a = fractions.Fraction(row['onset'])
b = a + fractions.Fraction(row['duration'])
if a < end and b > offset:
rows.append({**row, 'onset': str(max(a, offset) - offset), 'duration': str(min(b, end) - max(a, offset))})
return {**pattern, 'lengths': list(map(str, lengths)), 'events': rows}
def realize(pattern, inputs, part, melody, *, anticipate=False, limit=None, boundary=False, assign=True):
flat = flatten(inputs)
lengths = tuple(generator.model.fraction(m['duration']) for m, _, _ in inputs)
fitted = fit(pattern, flat, None, part, anticipate=anticipate, limit=limit, assign=assign)
if fitted is None and boundary:
# Keep the selected onset/layers at a protected handoff, using the longest
# permitted short articulation that fits rather than another groove.
clipped = project(pattern, fractions.Fraction(), (min(sum(lengths), limit) if limit is not None else sum(lengths),))
rows = []
for row in clipped['events']:
a, duration = fractions.Fraction(row['onset']), fractions.Fraction(row['duration'])
_, b, _ = next(s for s in spans(flat, None) if s[0] <= a < s[1])
duration = min(duration, b - a)
if part == 'acoustic' and duration <= 1:
duration = next((d for d in (fractions.Fraction(1), fractions.Fraction(1, 2)) if d <= duration), fractions.Fraction())
if duration:
rows.append({**row, 'duration': str(duration)})
fitted = fit({**pattern, 'events': rows}, flat, None, part, anticipate=False, limit=limit, assign=assign)
if fitted is not None:
fitted = fitted[0], (*fitted[1], ('release', 'shortened articulation at source-defined boundary'))
if fitted is None:
return None
events, exceptions = fitted
context, cursor = [], fractions.Fraction()
for m, _, i in inputs:
context.extend((a + cursor, b + cursor) for a, b in melody[i])
cursor += generator.model.fraction(m['duration'])
return Rhythm(events, (('pattern', pattern['family']),), evaluate(events, part, context, spans(flat, None), lengths), exceptions,
pattern['id'] + ('.anticipated' if any(e.harmonic_time is not None for e in events) else ''))
def identity(pattern):
"""Layer swaps and anticipation permissions alone are not different rhythms."""
return tuple((fractions.Fraction(r['onset']), fractions.Fraction(r['duration'])) for r in pattern['events'])
def acoustic_context(groups, melody, breaks=()):
"""Immutable source timing for assigning and evaluating a complete stream.
Breaks are (source measure index, offset) pairs. Ordinary storage boundaries
are absent: adjacent figures must see each other's attacks before scoring.
"""
blocks, starts, cursor = [], {}, fractions.Fraction()
for group in groups:
start, context, lengths = cursor, [], []
for m, _, i in group:
starts[i] = cursor
context.extend((a + cursor - start, b + cursor - start) for a, b in melody[i])
lengths.append(generator.model.fraction(m['duration']))
cursor += lengths[-1]
starts[i + 1] = cursor
blocks.append((start, cursor, tuple(context), spans(flatten(group), None), tuple(lengths)))
full = tuple(row for group in groups for row in group)
return {'blocks': tuple(blocks), 'harmony': spans(flatten(full), None),
'breaks': tuple(sorted(starts[i] + t for i, t in breaks if i in starts))}
def realize_acoustic_form(rhythms, context):
"""The shared release/lane contract for selection, fills and final output.
Inputs retain authored releases. Re-evaluate those releases whenever an
edited neighboring figure changes the next attack; never restore duration
from previously shortened notation.
"""
if len(rhythms) != len(context['blocks']):
raise ValueError('acoustic realization requires one rhythm per source block')
events = []
for rhythm, (start, _, _, _, _) in zip(rhythms, context['blocks']):
events.extend(dataclasses.replace(e, start=e.start + start, end=e.end + start, harmonic_time=e.harmonic_time + start if e.harmonic_time is not None else None) for e in rhythm.events)
assigned = assign_acoustic(events, context['harmony'], context['breaks'])
result = []
for a, b in itertools.product(bass, upper):
costs = tuple((lane + '_' + k, v) for lane, c in (('bass', a), ('upper', b)) for k, v in c.contributions)
result.append(Rhythm(tuple(sorted((*a.events, *b.events))), (*a.families, *b.families), (*costs, ('combined_crowding', crowding((*a.events, *b.events)))), (*a.exceptions, *b.exceptions)))
return representatives(result, policy['measure_candidates'], seed)
for rhythm, (start, end, melody, harmony, lengths) in zip(rhythms, context['blocks']):
local = tuple(dataclasses.replace(e, start=e.start - start, end=e.end - start, harmonic_time=e.harmonic_time - start if e.harmonic_time is not None else None)
for e in assigned if start <= e.start < end)
exceptions = tuple(e for e in rhythm.exceptions if e[0] != 'layer_assignment')
result.append(dataclasses.replace(rhythm, events=local, contributions=evaluate(local, 'acoustic', melody, harmony, lengths),
pattern_id=rhythm.pattern_id.removesuffix('.anticipated') + ('.anticipated' if any(e.harmonic_time is not None for e in local) else ''),
exceptions=(*exceptions, ('layer_assignment', 'combined attacks or bass/upper eighth pairs; release at every next attack'))))
return tuple(result)
def transition(previous, current):
if previous is None:
return 0.
# Recurrence is allowed; penalize repeating an entire bar more than sharing
# a duration family. This stays separate from the source-context objective.
same_counts = all(sum(e.lane == lane for e in previous.events) == sum(e.lane == lane for e in current.events) for lane, _ in current.families)
return .45 * (previous.signature == current.signature) + .12 * (previous.families == current.families) + .08 * same_counts
def form_cost(rhythms, groups):
return sum(r.cost * len(g) for r, g in zip(rhythms, groups))
def select(layers, seed, left=None, right=None):
"""One state per concrete bar rhythm; compare complete equal-span paths."""
states = [(0., (), (), left)]
for i, layer in enumerate(layers):
following = []
for c in layer:
options = [(cost + c.cost + transition(previous, c), (*ties, generator.solo.policy.stable_rank(seed, (i, c.signature))), (*path, c), c) for cost, ties, path, previous in states]
following.append(min(options, key=lambda item: item[:2]))
states = following
return min(states, key=lambda item: (item[0] + (transition(item[3], right) if right else 0), item[1]))[2]
def choose_cycles(groups, part, melody, seed, *, breaks=(), composition=None):
"""Select a small recurring vocabulary against every occurrence in the form.
No local shortlist precedes whole-form evaluation. A pattern/mode is retained
as one decision even where a chord boundary changes its legal release.
"""
composition = composition or generator.vocabulary.current()
policy = composition.accompaniment(part)
settings = policy['groove']
selected, locations, reports = [], [], []
runs = []
for group in groups:
m = group[0][0]
key = (meter_context(m), generator.model.fraction(m['duration']))
if not runs or runs[-1][0] != key:
runs.append((key, []))
runs[-1][1].append(group)
for ((meter, _), length), run in runs:
grouping, grouping_evidence = grouping_for(run, melody)
patterns = patterns_for(policy, run[0][0][0], (length, length), grouping)
if not patterns:
patterns = patterns_for(policy, run[0][0][0], (length,), grouping)
requested = settings['cycle_patterns']
identities = {p['id']: identity(p) for p in patterns}
available = len(set(identities.values()))
cache, estimates = {}, {}
context = acoustic_context(run, melody, breaks) if part == 'acoustic' else None
for i, group in enumerate(run):
lengths = tuple(generator.model.fraction(m['duration']) for m, _, _ in group)
local_context = acoustic_context((group,), melody, breaks) if context else None
for p in patterns:
for anticipate in (False, True):
value = realize(project(p, fractions.Fraction(), lengths), group, part, melody, anticipate=anticipate, assign=part != 'acoustic')
cache[i, p['id'], anticipate] = value
try:
estimates[i, p['id'], anticipate] = realize_acoustic_form((value,), local_context)[0] if context and value is not None else value
except ValueError:
estimates[i, p['id'], anticipate] = None
winner, examined = None, 0
for width in range(min(requested, len(run), available), 0, -1):
layers = []
for slot in range(width):
unique = {}
for p in patterns:
for anticipate in (False, True):
values = [estimates[i, p['id'], anticipate] for i in range(slot, len(run), width)]
if any(v is None for v in values):
continue
cost = sum(v.cost * len(run[i]) for i, v in zip(range(slot, len(run), width), values))
rank = (cost, generator.solo.policy.stable_rank(seed, (meter, slot, p['id'], anticipate)))
option = (rank, p, anticipate)
key = identities[p['id']]
if key not in unique or rank < unique[key][0]:
unique[key] = option
ordered = sorted(unique.values(), key=lambda o: o[0])
diverse, families = [], set()
for option in ordered:
if option[1]['family'] not in families:
diverse.append(option)
families.add(option[1]['family'])
diverse.extend(o for o in ordered if o not in diverse)
layers.append(diverse[:settings['slot_candidates']])
for cycle in itertools.product(*layers):
if len({identities[o[1]['id']] for o in cycle}) != width:
continue
examined += 1
cost = sum(o[0][0] for o in cycle)
if context:
values = [cache[i, cycle[i % width][1]['id'], cycle[i % width][2]] for i in range(len(run))]
try:
cost = form_cost(realize_acoustic_form(values, context), run)
except ValueError:
continue
rank = (cost, tuple(o[0][1] for o in cycle))
if winner is None or rank < winner[0]:
winner = rank, cycle
if winner is not None:
break
if winner is None:
raise ValueError(f'source measure {run[0][0][0]["number"]}: no legal recurring {part} groove for {meter}; check harmonic releases and pattern vocabulary')
cycle = winner[1]
report = {'source_start': run[0][0][2], 'source_end': run[-1][-1][2], 'meter': meter,
'grouping': list(grouping), 'grouping_evidence': grouping_evidence, 'eligible_patterns': len(patterns),
'requested_patterns': requested, 'cycle_patterns': len(cycle), 'patterns': [o[1]['id'] for o in cycle],
'anticipation': [o[2] for o in cycle], 'cost': winner[0][0], 'complete_cycles_compared': examined,
'retrieval_cost': sum(o[0][0] for o in cycle),
'reduction': 'available distinct, legal patterns or source length' if len(cycle) < requested else None}
reports.append(report)
for i, group in enumerate(run):
_, p, anticipate = cycle[i % len(cycle)]
selected.append((p, anticipate, cache[i, p['id'], anticipate]))
locations.append({'cycle_start': run[0][0][2], 'cycle_slot': i % len(cycle), 'base_pattern': p['id'], 'fill': None})
context = acoustic_context(groups, melody, breaks) if part == 'acoustic' else None
add_fills(groups, selected, locations, part, melody, seed, context=context, composition=composition)
if context:
realized = realize_acoustic_form([r for _, _, r in selected], context)
selected = [(p, a, r) for (p, a, _), r in zip(selected, realized)]
for report in reports:
report['final_cost'] = sum(r.cost * len(g) for g, r in zip(groups, realized) if report['source_start'] <= g[0][2] <= report['source_end'])
report['attack_assignment'] = 'sequential_combined_except_eighth_pairs'
return selected, locations, reports
def add_fills(groups, selected, locations, part, melody, seed, *, context=None, composition=None):
"""Fixed source-position answers; no iteration seed or generated lead input."""
composition = composition or generator.vocabulary.current()
policy = composition.accompaniment(part)
spacing = policy['groove']['fill_spacing_measures']
if not groups:
return
body_start, body_end = groups[0][0][2], groups[-1][-1][2] + 1
body_length = body_end - body_start
options = []
if body_length < spacing:
return
original = realize_acoustic_form([r for _, _, r in selected], context) if context else tuple(r for _, _, r in selected)
def proposal(i, candidate, baseline):
if not context:
return candidate.cost < baseline[i].cost - 1e-9, baseline[i].cost - candidate.cost
raw = [r for _, _, r in selected]
raw[i] = candidate
try:
revised = realize_acoustic_form(raw, context)
except ValueError:
return False, 0
middle = generator.model.fraction(groups[i][0][0]['duration'])
# A second-bar fill must not alter the preceding/following block's lane
# assignment or release, nor any part of its own first bar.
if any(a.events != b.events for j, (a, b) in enumerate(zip(baseline, revised)) if j != i):
return False, 0
if tuple(e for e in baseline[i].events if e.start < middle) != tuple(e for e in revised[i].events if e.start < middle):
return False, 0
gain = form_cost(baseline, groups) - form_cost(revised, groups)
return gain > 1e-9, gain
for i, (group, (base, anticipate, _)) in enumerate(zip(groups, selected)):
current = original[i]
if len(group) != 2:
continue
last, _, index = group[-1]
length = generator.model.fraction(last['duration'])
reason = 'form_end' if i == len(groups) - 1 else 'section_end' if groups[i + 1][0][0].get('section_label') else None
if reason is None and max((min(b, length) for a, b in melody[index]), default=fractions.Fraction()) <= length - 1:
reason = 'melody_breath'
if reason is None:
continue
middle = generator.model.fraction(group[0][0]['duration'])
if any(e.start < middle < e.end for e in current.events):
continue
for variation in policy['patterns']:
if variation['family'] != base['family'] or tuple(variation['lengths']) != tuple(base['lengths']) or variation.get('meter') != base.get('meter') or tuple(variation.get('grouping', ())) != tuple(base.get('grouping', ())):
continue
hybrid = {**base, 'id': base['id'] + '.fill.' + variation['id'], 'events':
[r for r in base['events'] if fractions.Fraction(r['onset']) < middle] +
[r for r in variation['events'] if fractions.Fraction(r['onset']) >= middle]}
candidate = realize(hybrid, group, part, melody, anticipate=anticipate, assign=part != 'acoustic')
if candidate is None:
continue
if not context and tuple(e for e in candidate.events if e.start < middle) != tuple(e for e in current.events if e.start < middle):
continue
valid, gain = proposal(i, candidate, original)
if not valid:
continue
options.append((-gain, generator.solo.policy.stable_rank(seed, (index, hybrid['id'])), i, index, hybrid, anticipate, candidate, reason))
chosen = []
for _, _, i, index, pattern, anticipate, candidate, reason in sorted(options):
if any(min(abs(index - other), body_length - abs(index - other)) < spacing for other in chosen):
continue
if context and not proposal(i, candidate, realize_acoustic_form([r for _, _, r in selected], context))[0]:
continue
selected[i] = pattern, anticipate, candidate
locations[i]['fill'] = {'pattern': pattern['id'], 'source_index': index, 'reason': reason}
chosen.append(index)
+8 -12
View File
@@ -1,33 +1,29 @@
"""Explicit single-role build. Does not publish or consume an existing ensemble."""
import argparse
import json
import time
import pathlib
import time
import generator.composition
import generator.composition_types
import generator.musicxml
import generator.parts
import generator.production
import generator.solo.export
import generator.source
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--song', type=pathlib.Path, required=True)
parser.add_argument('--role', choices=generator.production.ROLES, required=True)
parser.add_argument('--role', choices=generator.composition_types.ROLES, required=True)
parser.add_argument('--data-dir', type=pathlib.Path, default=pathlib.Path('data'))
parser.add_argument('--output', type=pathlib.Path, required=True)
parser.add_argument('--cache-dir', type=pathlib.Path)
parser.add_argument('--solo-xml', type=pathlib.Path, help='Also export a completed solo role as MusicXML.')
parser.add_argument('--settings', type=pathlib.Path)
args = parser.parse_args()
if args.solo_xml and not args.role.endswith('_solo'):
parser.error('--solo-xml requires a solo role')
source = generator.production.SourceAnalysis.read(generator.parts.prepare_document(generator.musicxml.load_musicxml(args.song)))
source = generator.source.SourceAnalysis.read(generator.parts.prepare_document(generator.musicxml.load_musicxml(args.song)))
start = time.monotonic()
result = generator.production.generate_role(source, args.role, args.data_dir, json.loads(args.settings.read_text()) if args.settings else {}, args.cache_dir)
result = generator.composition.generate_role(source, args.role, args.data_dir, json.loads(args.settings.read_text()) if args.settings else {}, args.cache_dir)
args.output.parent.mkdir(parents=True, exist_ok=True)
args.output.write_text(json.dumps(result, indent=2))
if args.solo_xml:
manifest = generator.solo.export.write_role(result, args.solo_xml)
args.solo_xml.with_suffix('.manifest.solo').write_text(json.dumps(manifest, indent=2) + '\n')
print(f'{args.role}: {time.monotonic() - start:.2f}s wall; cached={result["cache_hit"]}; role generation/cache lookup {result["seconds"]:.2f}s')
if __name__ == '__main__':
+161
View File
@@ -0,0 +1,161 @@
"""Independent, reproducible role generation from source and policy inputs.
Only source documents and production resources enter generate_role. Completed
roles and published assets are downstream values, never composition inputs.
"""
from __future__ import annotations
import copy
import dataclasses
import functools
import hashlib
import json
import pathlib
import time
import generator.accompaniment
import generator.acoustic
import generator.arrange.assembly
import generator.arrange.form
import generator.arrange.generate
import generator.comping
import generator.comping_rhythm
import generator.composition_types
import generator.fretboard
import generator.input_audit
import generator.role_cache
import generator.score
import generator.solo.arrangement
import generator.solo.authored
import generator.solo.composer
import generator.solo.learned
import generator.solo.notation
import generator.solo.report
import generator.source
import generator.validation
import generator.vocabulary
VERSION = 'independent-roles-1'
def dependencies(role, resources, measures=None):
names = ['harmony', 'lead_ins'] if role.endswith('_solo') else []
accompaniment = {}
if role.endswith('_accompaniment'):
policy = generator.vocabulary.accompaniment(role.split('_')[0], resources)
accompaniment = {'accompaniment': generator.comping_rhythm.relevant_policy(policy, measures) if measures is not None else policy}
return {'roles': {'role': resources['roles']['roles'][role], 'difficulty': resources['roles']['difficulty']},
**({'voicing_families': generator.vocabulary.accompaniment('electric', resources)['voicing_families']} if role == 'electric_melody' else {}),
**accompaniment,
**{name: resources[name] for name in names}}
def _resource_key(directory, role):
return {'model': hashlib.sha256((directory / 'models' / 'solo.json').read_bytes()).hexdigest()} if role.endswith('_solo') else {}
@functools.lru_cache(maxsize=4)
def _solo_model(directory, fingerprint):
return generator.solo.learned.Model.load(pathlib.Path(directory) / 'models' / 'solo.json')
def generate_role(source, role, data_dir, settings=None, cache_dir=None) -> generator.composition_types.RoleResult:
started = time.monotonic()
with generator.input_audit.composition(data_dir, role, cache_dir) as reads:
result = _generate_role(source, role, data_dir, settings, cache_dir)
# Observed reads are diagnostics, never cache identity or musical seeds.
result['trace'] = {**result['trace'], 'input_boundary': 'production data (including explicit authored repertoire), generator code, Python runtime, own role cache'}
result['observed_reads'] = sorted(reads)
result['seconds'] = time.monotonic() - started
return result
def _generate_role(source, role, data_dir, settings=None, cache_dir=None):
if role not in generator.composition_types.ROLES:
raise ValueError('Unknown generation role: ' + role)
data_dir = pathlib.Path(data_dir)
resources = generator.vocabulary.load(data_dir / 'composition')
settings = settings or {}
registered = generator.solo.authored.lookup(source, role.removesuffix('_solo'), data_dir) if role.endswith('_solo') and not settings.get('predict', False) else None
algorithm = VERSION + '/' + generator.solo.learned.VERSION if role.endswith('_solo') else VERSION
inputs = {'version': algorithm, 'source': source.musical_key, 'role': role, 'settings': settings,
'vocabulary': dependencies(role, resources, generator.score.source_staff(source.document())['measures']), 'catalogs': ({'authored': registered['sha256'], 'id': registered['id'], 'pitch_convention': registered['pitch_convention']} if registered else _resource_key(data_dir, role)), 'code': generator.role_cache.code_key()}
# Source notation/lyrics also invalidate cached score representation, never the musical seed.
key = generator.vocabulary.fingerprint({'inputs': inputs, 'notation': source.document_json})
path = pathlib.Path(cache_dir) / role / (key + '.json') if cache_dir else None
cached = generator.role_cache.restore(path, key)
if cached is not None:
return cached
started = time.monotonic()
document = source.document()
part = role.split('_')[0]
plan = generator.arrange.form.FormPlan.read(document, part)
trace = {'source': source.musical_key, 'role': role, 'production_resources': inputs['catalogs'],
'vocabulary': generator.vocabulary.fingerprint(inputs['vocabulary']), 'settings': settings, 'algorithm': algorithm, 'code': inputs['code'], 'cache_key': key}
choice_source = source.accompaniment_key() if role.endswith('_accompaniment') else source.musical_key
choice_data, choice_settings = inputs['vocabulary'], settings
if role.endswith('_accompaniment'):
# Voicing weights invalidate the concrete cache, but must not reshuffle
# rhythm patterns. Removing this new field preserves the pre-policy seed.
choice_data = copy.deepcopy(choice_data)
choice_data['roles']['role'].pop('voicing', None)
for field in ('provenance', 'license', 'research'):
choice_data['accompaniment'].pop(field, None)
choice_settings = {k: v for k, v in settings.items() if k != 'voicing'}
seed = generator.vocabulary.fingerprint({'source': choice_source, 'role': role, 'settings': choice_settings, 'data': choice_data, 'version': algorithm})
details = {}
solo_report = ''
composition_timings = {}
composition = generator.vocabulary.CompositionContext.create(resources, role, settings | {'choice_seed': seed})
if role.endswith('_solo'):
result = generator.arrange.generate._arrange_document(document, part, plan, owned={'slash'}, composition=composition)
si = 3 if part == 'acoustic' else 4
first, count, offset, length = generator.solo.arrangement.regions(document)[si]
# The template/harmony comes directly from source form, not another generated part.
authored = generator.score.source_staff(document)['measures']
section = plan.sections[si]
effective = generator.arrange.generate.section_source(authored, section, plan.sections[si + 1])
template = copy.deepcopy(effective[section.source_measure_index:section.source_measure_index + count])
initial = generator.accompaniment.carried_chords(effective)[section.source_measure_index]
start, end = next((a - offset, b - offset) for a, b, r in plan.windows if r == role)
notation_first = first
if start < 0:
# The preceding arrangement harmony comes from the source form. Do
# not invent harmony from a comparison score's unlabelled lead-in.
template.insert(0, copy.deepcopy(result['staves'][0]['measures'][first - 1]))
notation_first -= 1
initial = generator.accompaniment.carried_chords(result['staves'][0]['measures'])[first - 1]
if registered:
solo = generator.solo.authored.realize(registered, generator.source.analyze(document), template, part, start, end, initial, composition=composition)
else:
solo_model = _solo_model(str(data_dir), inputs['catalogs']['model'])
solo = generator.solo.composer.compose(generator.source.analyze(document), template, part, end, initial=initial, learned_model=solo_model, expressions_enabled=composition.role().get('expressions', True), start=start, composition=composition)
composition_timings = {k: v for k, v in solo.diagnostics.items() if k.endswith('_seconds')}
relative = tuple(dataclasses.replace(n, start=n.start - start, end=n.end - start) for n in solo.notes())
output = generator.solo.notation.measures(result['staves'][0]['measures'][notation_first:first + count], relative, 'solo_' + part)
generator.solo.notation.replace_region(result, notation_first, output)
details = generator.solo.report.structure(solo, composition=composition)
details['allocation'] = {'start': str(start), 'end': str(end), 'lead_in_measures': first - notation_first}
solo_report = generator.solo.report.describe(solo, first, offset, detail=details, composition=composition)
elif role.endswith('_accompaniment'):
canonical = generator.comping.Canonical(document, part, seed, composition=composition, plan=plan)
result = generator.arrange.generate._arrange_document(document, part, plan, owned={'accompaniment'}, accompaniment=canonical, composition=composition)
details = {'canonical_comping': canonical.report, 'guitar_placement': canonical.placement_report, 'accompaniment_rhythm': canonical.rhythm_report, 'groove_cycles': canonical.groove_report, 'rhythm_source': choice_source}
else:
placement_report = {}
result = generator.arrange.generate._arrange_document(document, part, plan, owned={'vocal' if part == 'vocal' else 'melody'}, composition=composition, placement_report=placement_report)
if placement_report:
details['guitar_placement'] = placement_report
allowed = tuple((a, b) for a, b, r in plan.windows if r == role)
generator.arrange.assembly.mask(result, allowed)
if role == "acoustic_accompaniment":
generator.acoustic.validate_comping(result)
staff = result['staves'][0]
for measure in staff['measures']:
measure['id'] = role + '_' + measure['id']
staff['tuplets'] = generator.score.reidentify(staff['measures'], staff.get('tuplets', []))
if part != 'vocal':
result['staves'][0]['tablature'] = True
generator.validation.validate_document(result)
generator.fretboard.validate_document(result)
value = {'role': role, 'document': result, 'trace': trace, 'details': details, 'report': solo_report, 'seconds': time.monotonic() - started, 'composition_timings': composition_timings, 'cache_hit': False}
# Sidecar diagnostics use the same rational-safe representation as reports.
# Identical insertion order after cold generation and cache loading also
# keeps serialized scores and the catalog byte-for-byte reproducible.
value = json.loads(json.dumps(value, default=str, sort_keys=True))
generator.role_cache.store(path, key, value)
return value
+28
View File
@@ -0,0 +1,28 @@
"""Worker requests and role results; score serialization stays unchanged."""
from __future__ import annotations
import dataclasses
import pathlib
import typing
import generator.source
ROLES = ('acoustic_accompaniment', 'electric_accompaniment', 'electric_melody', 'vocal_melody', 'acoustic_solo', 'electric_solo')
@dataclasses.dataclass(frozen=True)
class RoleRequest:
source: generator.source.SourceAnalysis
role: str
directory: pathlib.Path
settings_json: str = '{}'
cache: pathlib.Path | None = None
class RoleResult(typing.TypedDict):
role: str
document: dict
trace: dict
details: dict
report: str
seconds: float
composition_timings: dict
cache_hit: bool
observed_reads: typing.NotRequired[list[str]]
+34 -4
View File
@@ -19,16 +19,17 @@ def audit_primitives(primitives, width, height, fonts):
if any(abs(a - b) > 0.001 for a, b in zip((actual.left, actual.top, actual.right, actual.bottom), (item.box.left, item.box.top, item.box.right, item.box.bottom))):
raise generator.engraving.types.EngravingError(f'{item.sources}: glyph bounds disagree with its actual outline')
def audit_layout(document: dict, layout: generator.engraving.types.LayoutDocument, fonts: generator.engraving.fonts.Fonts) -> None:
def audit_layout(document: dict, layout: generator.engraving.types.LayoutDocument, fonts: generator.engraving.fonts.Fonts, *, systems_per_page: int | None = 2) -> None:
index = generator.engraving.notation.ScoreIndex(document)
fragments, primitives = {}, {}
previous_end = fractions.Fraction()
scale = layout.pages[0].systems[0].scale
for page in layout.pages:
if len(page.systems) != 2 and (page is not layout.pages[-1] or len(page.systems) != 1):
if not page.systems or (systems_per_page is not None and len(page.systems) != systems_per_page and (page is not layout.pages[-1] or not 1 <= len(page.systems) < systems_per_page)):
raise generator.engraving.types.EngravingError('pages must contain two music systems, except an odd final system')
if len(page.systems) == 2 and page.systems[0].box.bottom + layout.style.system_gap > page.systems[1].box.top + 0.01:
raise generator.engraving.types.EngravingError('music systems overlap their page rows')
for first, second in zip(page.systems, page.systems[1:]):
if first.box.bottom + layout.style.system_gap > second.box.top + 0.01:
raise generator.engraving.types.EngravingError('music systems overlap their page rows')
audit_primitives(page.primitives, page.width, page.height, fonts)
header = generator.engraving.types.bounds([p for p in page.primitives if p.role in ('title', 'subtitle')])
footer = generator.engraving.types.bounds([p for p in page.primitives if p.role == 'page_number'])
@@ -79,6 +80,9 @@ def audit_layout(document: dict, layout: generator.engraving.types.LayoutDocumen
# Staff, ledger, stem, beam and tie contacts are intentional. Distinct
# noteheads, accidentals and text in the same lane must remain separate.
checked = [p for p in system.primitives if p.role in ('head', 'tab', 'accidental', 'harmony', 'lyric', 'scale', 'section')]
for label in (p for p in system.primitives if p.role == 'measure_number'):
if any(label.box.overlaps(p.box, 3 * system.scale) for p in system.primitives if p is not label):
raise generator.engraving.types.EngravingError(f'{label.sources}: measure number overlaps notation')
for i, item in enumerate(checked):
for other in checked[i + 1:]:
if set(item.sources) & set(other.sources) and (item.role != 'tab' or other.role != 'tab'):
@@ -141,3 +145,29 @@ def audit_layout(document: dict, layout: generator.engraving.types.LayoutDocumen
for span in index.staff.get('octave_shifts', []):
if not any(p.role == 'octave-shift' for p in primitives.get(span['id'], [])):
raise generator.engraving.types.EngravingError(f'{span["id"]}: octave shift was omitted')
def audit_playback(pages, playback, style, fonts):
canonical = [system for page in pages for system in page.systems]
if len(playback) != len(canonical):
raise generator.engraving.types.EngravingError('playback must have one view per system')
for i, page in enumerate(playback):
audit_primitives(page.primitives, page.width, page.height, fonts)
expected = canonical[i:i + 2]
if len(page.systems) != len(expected):
raise generator.engraving.types.EngravingError('invalid playback system pairing')
header = generator.engraving.types.bounds([p for p in page.primitives if p.role in ('title', 'subtitle')])
footer = generator.engraving.types.bounds([p for p in page.primitives if p.role == 'page_number'])
if page.systems[0].box.top < header.bottom + style.page_clearance - 0.01 or page.systems[-1].box.bottom > footer.top - style.page_clearance + 0.01:
raise generator.engraving.types.EngravingError('playback overlaps header or footer')
for a, b in zip(page.systems, page.systems[1:]):
if a.box.bottom + style.system_gap > b.box.top + 0.01:
raise generator.engraving.types.EngravingError('playback systems overlap')
for source, actual in zip(expected, page.systems):
if (source.start, source.end, source.scale, source.fragments) != (actual.start, actual.end, actual.scale, actual.fragments):
raise generator.engraving.types.EngravingError('playback changes system content')
dy = actual.box.top - source.box.top
if len(source.primitives) != len(actual.primitives):
raise generator.engraving.types.EngravingError('playback changes primitives')
for a, b in zip(source.primitives, actual.primitives):
if (a.kind, a.role, a.sources, a.value, a.size) != (b.kind, b.role, b.sources, b.value, b.size) or len(a.points) != len(b.points) or any(abs(x - u) > .001 or abs(y + dy - v) > .001 for (x, y), (u, v) in zip(a.points, b.points)):
raise generator.engraving.types.EngravingError('playback changes notation geometry')
+11 -35
View File
@@ -9,12 +9,12 @@ import pathlib
import platform
import re
import shutil
import tempfile
import PIL.Image
import PIL.ImageChops
import PIL.features
import generator.cache
import generator.engraving.validation
import generator.theme
@@ -22,9 +22,10 @@ def renderer_identity(fonts, style) -> dict:
root = pathlib.Path(__file__).resolve().parents[1]
versions = {name: importlib.metadata.version(name) for name in ('Pillow', 'fonttools', 'aggdraw')}
versions.update({name: PIL.features.version(name) for name in PIL.features.get_supported()})
sources = [*root.joinpath('engraving').glob('*.py'), root / 'model.py', root / 'performance.py', root / 'harmony.py', root / 'theme.py', root / 'palette.json']
sources = generator.cache.source_identity(('generator.engraving.pipeline', 'generator.printing'))
sources['palette.json'] = hashlib.sha256((root / 'palette.json').read_bytes()).hexdigest()
return {'fonts_style': fonts.fingerprint(style), 'python': {'implementation': platform.python_implementation(), 'version': platform.python_version()}, 'dependencies': versions,
'sources': {path.relative_to(root).as_posix(): hashlib.sha256(path.read_bytes()).hexdigest() for path in sorted(sources)}}
'sources': sources}
def renderer_fingerprint(fonts, style) -> str:
return hashlib.sha256(json.dumps(renderer_identity(fonts, style), sort_keys=True).encode()).hexdigest()
@@ -46,12 +47,9 @@ def band_fingerprint(notation: str, page, band) -> str:
context = [notation, page.width, page.height, page.supersampling, dataclasses.asdict(band)]
return hashlib.sha256(json.dumps(context, sort_keys=True, ensure_ascii=False).encode()).hexdigest()
def has_symlink(path: pathlib.Path) -> bool:
return any(parent.is_symlink() for parent in (path, *path.parents))
def restore_pages(entry: pathlib.Path, destination: pathlib.Path, validated_pages: set[str] | None = None) -> list[dict] | None:
try:
if has_symlink(entry) or has_symlink(destination):
if generator.cache.has_symlink(entry) or generator.cache.has_symlink(destination):
return None
manifest = entry / 'pages.json'
if manifest.is_symlink():
@@ -61,7 +59,7 @@ def restore_pages(entry: pathlib.Path, destination: pathlib.Path, validated_page
return None
destination.mkdir(parents=True, exist_ok=True)
for index, page in enumerate(pages, 1):
if not isinstance(page, dict) or set(page) != {'path', 'sha256', 'first_measure', 'measure_count', 'start_beat', 'end_beat'} or page['path'] != f'{index:04}.png' or not isinstance(page['sha256'], str) or not re.fullmatch('[0-9a-f]{64}', page['sha256']):
if not isinstance(page, dict) or set(page) != {'path', 'sha256', 'first_measure', 'measure_count', 'start_beat', 'end_beat', 'systems', 'playback'} or type(page['playback']) is not bool or not isinstance(page['path'], str) or not re.fullmatch(r'(?:playback-)?[0-9]{4,5}\.png', page['path']) or not isinstance(page['sha256'], str) or not re.fullmatch('[0-9a-f]{64}', page['sha256']):
return None
path = entry / page['path']
if path.is_symlink() or not path.is_file():
@@ -76,28 +74,17 @@ def restore_pages(entry: pathlib.Path, destination: pathlib.Path, validated_page
return None
def store_pages(entry: pathlib.Path, destination: pathlib.Path, pages: list[dict]) -> None:
if has_symlink(entry.parent):
raise ValueError('engraving cache directories must not be symlinks')
entry.parent.mkdir(parents=True, exist_ok=True)
if entry.is_symlink() or entry.is_file():
entry.unlink(missing_ok=True)
entry.mkdir(exist_ok=True)
with tempfile.TemporaryDirectory(prefix='.engraving_', dir=entry.parent) as temporary:
staged = pathlib.Path(temporary)
with generator.cache.stage_entry(entry, '.engraving_') as staged:
for page in pages:
shutil.copyfile(destination / page['path'], staged / page['path'])
(staged / 'pages.json').write_text(json.dumps(pages), encoding='utf-8')
# Identical keys have identical pages; publish complete files, then the manifest.
for name in [page['path'] for page in pages] + ['pages.json']:
target = entry / name
if target.is_dir() and not target.is_symlink():
shutil.rmtree(target, ignore_errors=True)
(staged / name).replace(target)
generator.cache.publish_files(entry, staged, list(dict.fromkeys(page['path'] for page in pages)) + ['pages.json'])
def restore_band(entry: pathlib.Path, key: str, width: int, height: int) -> PIL.Image.Image | None:
try:
manifest, asset = entry / 'band.json', entry / 'band.png'
if has_symlink(entry) or manifest.is_symlink() or asset.is_symlink():
if generator.cache.has_symlink(entry) or manifest.is_symlink() or asset.is_symlink():
return None
metadata = json.loads(manifest.read_text(encoding='utf-8'))
if not isinstance(metadata, dict) or set(metadata) != {'context', 'width', 'height', 'sha256'}:
@@ -122,19 +109,8 @@ def restore_band(entry: pathlib.Path, key: str, width: int, height: int) -> PIL.
return None
def store_band(entry: pathlib.Path, key: str, image: PIL.Image.Image) -> None:
if has_symlink(entry.parent):
raise ValueError('engraving cache directories must not be symlinks')
entry.parent.mkdir(parents=True, exist_ok=True)
if entry.is_symlink() or entry.is_file():
entry.unlink()
entry.mkdir(exist_ok=True)
with tempfile.TemporaryDirectory(prefix='.engraving_', dir=entry.parent) as temporary:
staged = pathlib.Path(temporary)
with generator.cache.stage_entry(entry, '.engraving_') as staged:
image.save(staged / 'band.png', format='PNG')
metadata = {'context': key, 'width': image.width, 'height': image.height, 'sha256': hashlib.sha256((staged / 'band.png').read_bytes()).hexdigest()}
(staged / 'band.json').write_text(json.dumps(metadata), encoding='utf-8')
for name in ('band.png', 'band.json'):
target = entry / name
if target.is_dir() and not target.is_symlink():
shutil.rmtree(target)
(staged / name).replace(target)
generator.cache.publish_files(entry, staged, ('band.png', 'band.json'))
+33 -22
View File
@@ -16,7 +16,7 @@ import generator.engraving.spans
import generator.engraving.tablature
import generator.engraving.types
import generator.harmony
import generator.model
import generator.validation
def lyric_text(verse: dict) -> str:
return ''.join(s['text'] for s in verse['syllables'] if s['kind'] in ('text', 'elision'))
@@ -57,7 +57,6 @@ def column(index: generator.engraving.notation.ScoreIndex, time: fractions.Fract
items.append(fonts.text(generator.harmony.symbol(item), 0, 0, 18 if index.staff.get('tablature') else 21, 'harmony', (item['id'],)))
items.extend(generator.engraving.scales.column(index, time, start, fonts))
if time == measure_start:
items.append(fonts.text(str(measure['number']), 0, -style.space * (index.state(time)['staff_details']['lines'] + 0.5), 12, 'measure_number', (measure['id'],)))
if label := measure.get('section_label'):
items.append(fonts.text(label, 0, 0, 16 if index.staff.get('tablature') else 19, 'section', (measure['id'] + ':section',)))
return items, anchors, fragments
@@ -103,6 +102,10 @@ def make_system(index: generator.engraving.notation.ScoreIndex, start: fractions
for owner, ci, change in index.attributes_by_onset.get(time, []):
extra = generator.engraving.attributes.staff_attributes(index, index.state(time), time, fonts, style.space, owner['id'] + f':attributes:{ci}', tuple(change))
leading.extend(p.moved(max((p.box.right for p in leading), default=0) + 10, 0) for p in extra)
if time == measure_start:
# Anchor labels to the barline, not to the first note's time column.
bar_x = cursor - generator.engraving.types.bounds(leading).left if leading else 0
items.append(fonts.text(str(m['number']), bar_x, 0, 12, 'measure_number', (m['id'],), True))
if leading:
width = generator.engraving.types.bounds(leading).right - generator.engraving.types.bounds(leading).left + 14
items.extend(p.moved(cursor - generator.engraving.types.bounds(leading).left, 0) for p in leading)
@@ -162,7 +165,7 @@ def fit_part_systems(systems, index, available_height, fonts, style):
def fitting_scale(items):
scale = 1
for first in range(0, len(items), 2):
for first in range(len(items)):
pair = items[first:first + 2]
height = sum(s.box.bottom - s.box.top for s in pair)
scale = min(scale, (available_height - style.system_gap * (len(pair) - 1)) / height)
@@ -191,6 +194,8 @@ def part_header(document, fonts, style):
raise generator.engraving.types.EngravingError('score title cannot fit the page without clipping')
result = [item]
subtitle = ' - '.join(str(value) for value in (document['metadata'].get('composer'), document['staves'][0].get('name')) if value)
if document['metadata'].get('solos_enabled') is False:
subtitle += ' - Improvisation'
if not subtitle:
return result
credit = fonts.text(subtitle, 0, style.margin_y + size, 12, 'subtitle', ())
@@ -214,34 +219,40 @@ def part_header(document, fonts, style):
result.append(fonts.text(line, style.margin_x, baseline, 12, 'subtitle', ()))
return result
def paginate(systems: list[generator.engraving.types.System], document: dict, fonts: generator.engraving.fonts.Fonts, style: generator.engraving.types.Style, *, index=None) -> tuple[generator.engraving.types.Page, ...]:
pages = []
def page_views(systems: list[generator.engraving.types.System], document: dict, fonts: generator.engraving.fonts.Fonts, style: generator.engraving.types.Style, *, index=None) -> tuple[tuple[generator.engraving.types.Page, ...], tuple[generator.engraving.types.Page, ...]]:
index = index or generator.engraving.notation.ScoreIndex(document)
header = part_header(document, fonts, style)
top = generator.engraving.types.bounds(header).bottom + style.page_clearance
footers = [fonts.text(str(number), style.width / 2, style.height - style.margin_y, 12, 'page_number', (), True) for number in range(1, (len(systems) + 1) // 2 + 1)]
footers = [fonts.text(str(number), style.width / 2, style.height - style.margin_y, 12, 'page_number', (), True) for number in range(1, len(systems) + 1)]
bottom = min(p.box.top for p in footers) - style.page_clearance
if bottom - top <= style.system_gap:
raise generator.engraving.types.EngravingError('page header leaves no room for two music systems')
fitted = fit_part_systems(systems, index, bottom - top, fonts, style)
for first in range(0, len(systems), 2):
number = len(pages) + 1
pair = fitted[first:first + 2]
slack = max(0, bottom - top - sum(s.box.bottom - s.box.top for s in pair) - style.system_gap * (len(pair) - 1))
spacing = slack / 3 if len(pair) == 2 else 0
cursor = top + spacing
placed = []
for system in pair:
dx, dy = style.margin_x + 1, cursor - system.box.top
placed.append(dataclasses.replace(system, primitives=tuple(p.moved(dx, dy) for p in system.primitives), anchors=tuple(a.moved(dx, dy) for a in system.anchors), box=system.box.moved(dx, dy)))
cursor = placed[-1].box.bottom + style.system_gap + spacing
footer = footers[first // 2]
pages.append(generator.engraving.types.Page(number, style.width, style.height, style.supersampling, tuple(placed), tuple(header + [p for s in placed for p in s.primitives] + [footer])))
return tuple(pages)
def place(stride):
pages = []
for first in range(0, len(fitted), stride):
number = len(pages) + 1
pair = fitted[first:first + 2]
slack = max(0, bottom - top - sum(s.box.bottom - s.box.top for s in pair) - style.system_gap * (len(pair) - 1))
spacing = slack / 3 if len(pair) == 2 else 0
cursor = top + spacing
placed = []
for system in pair:
dx, dy = style.margin_x + 1, cursor - system.box.top
placed.append(dataclasses.replace(system, primitives=tuple(p.moved(dx, dy) for p in system.primitives), anchors=tuple(a.moved(dx, dy) for a in system.anchors), box=system.box.moved(dx, dy)))
cursor = placed[-1].box.bottom + style.system_gap + spacing
pages.append(generator.engraving.types.Page(number, style.width, style.height, style.supersampling, tuple(placed), tuple(header + [p for s in placed for p in s.primitives] + [footers[number - 1]])))
return tuple(pages)
return place(2), place(1)
def paginate(systems, document, fonts, style, *, index=None):
return page_views(systems, document, fonts, style, index=index)[0]
def layout_systems(document: dict, style: generator.engraving.types.Style, fonts: generator.engraving.fonts.Fonts, *, index=None) -> tuple[generator.engraving.types.System, ...]:
if index is None:
generator.model.validate_document(document)
generator.validation.validate_document(document)
index = generator.engraving.notation.ScoreIndex(document)
if not index.measures:
raise generator.engraving.types.EngravingError('score has no measures')
@@ -267,7 +278,7 @@ def layout_systems(document: dict, style: generator.engraving.types.Style, fonts
return tuple(systems)
def layout_score(document: dict, style: generator.engraving.types.Style, fonts: generator.engraving.fonts.Fonts) -> generator.engraving.types.LayoutDocument:
generator.model.validate_document(document)
generator.validation.validate_document(document)
style = generator.engraving.types.score_style(document, style)
index = generator.engraving.notation.ScoreIndex(document)
systems = layout_systems(document, style, fonts, index=index)
+9 -174
View File
@@ -1,182 +1,17 @@
from __future__ import annotations
import collections
import concurrent.futures
import dataclasses
import hashlib
import json
import multiprocessing
import pathlib
import shutil
import tempfile
import time
import PIL.Image
import generator.engraving.audit
import generator.engraving.cache
import generator.engraving.fonts
import generator.engraving.layout
import generator.engraving.notation
import generator.engraving.raster
import generator.engraving.types
import generator.engraving.validation
import generator.model
import generator.performance
@dataclasses.dataclass
class GroupResult:
scores: list = dataclasses.field(default_factory=list)
fullscore: int = 0
bodyhits: int = 0
bodies: int = 0
renderedpages: int = 0
rejected: int = 0
timings: dict = dataclasses.field(default_factory=lambda: dict.fromkeys(('layout', 'pagination', 'raster', 'cache'), 0.0))
class BodyBands:
def __init__(self, root, persistent, result, limit=16 * 1024 * 1024):
self.root, self.persistent, self.result, self.limit = root, persistent, result, limit
self.images = collections.OrderedDict()
self.size = 0
self.known = {}
self.root.mkdir(parents=True, exist_ok=True)
def get(self, notation, page, band, fonts):
key = generator.engraving.cache.band_fingerprint(notation, page, band)
if key in self.images:
self.images.move_to_end(key)
self.result.bodyhits += 1
return self.images[key]
started = time.monotonic()
entry = self.root / (key + '.rgb')
image = None
if key in self.known:
if entry.is_symlink() or entry.stat().st_size != page.width * (band.bottom - band.top) * 3:
raise generator.engraving.types.EngravingError('temporary notation band was corrupted')
data = entry.read_bytes()
if hashlib.sha256(data).hexdigest() != self.known[key]:
raise generator.engraving.types.EngravingError('temporary notation band was corrupted')
image = PIL.Image.frombytes('RGB', (page.width, band.bottom - band.top), data)
elif self.persistent:
cached = self.persistent / 'notation' / key
image = generator.engraving.cache.restore_band(cached, key, page.width, band.bottom - band.top)
self.result.rejected += int(image is None and (cached.exists() or cached.is_symlink()))
self.result.timings['cache'] += time.monotonic() - started
if image is None:
started = time.monotonic()
image = generator.engraving.raster.rasterize_band(page, band.primitives, band.top, band.bottom, fonts)
self.result.timings['raster'] += time.monotonic() - started
self.result.bodies += 1
if self.persistent:
started = time.monotonic()
generator.engraving.cache.store_band(self.persistent / 'notation' / key, key, image)
self.result.timings['cache'] += time.monotonic() - started
else:
self.result.bodyhits += 1
if key not in self.known:
started = time.monotonic()
# Spill finalized pixels, so eviction never repeats rasterization or PNG decoding.
data = image.tobytes()
entry.write_bytes(data)
self.result.timings['cache'] += time.monotonic() - started
self.known[key] = hashlib.sha256(data).hexdigest()
size = image.width * image.height * 3
while self.images and self.size + size > self.limit:
_, old = self.images.popitem(last=False)
self.size -= old.width * old.height * 3
old.close()
self.images[key] = image
self.size += size
return image
def close(self):
for image in self.images.values():
image.close()
self.images.clear()
self.size = 0
def clear_pages(destination):
if destination.is_symlink() or destination.is_file():
destination.unlink()
elif destination.exists():
shutil.rmtree(destination)
def write_bundle(path, document, pages, fingerprint):
entries = [{**page, 'path': path.with_suffix('.pages').name + '/' + page['path']} for page in pages]
music = document
bundle = {'music': music, 'presentation': {'engine': generator.engraving.validation.ENGINE_NAME, 'style_sha256': fingerprint,
'width': generator.engraving.validation.PAGE_WIDTH, 'height': generator.engraving.validation.PAGE_HEIGHT, 'pages': entries}}
generator.performance.validate_pages(document, pages)
bundle['performance'] = generator.performance.timing(document)
path.write_text(json.dumps(bundle, indent=2, ensure_ascii=False) + '\n', encoding='utf-8')
def engrave_group(notation, paths, root, font_path, cache_dir, fingerprint, progress=False):
family = generator.engraving.fonts.Fonts(font_path)
style = generator.engraving.types.Style()
systems = None
index = None
scores = {}
audited = set()
result = GroupResult()
with tempfile.TemporaryDirectory(prefix='vamp_notation_') as temporary:
bodies = BodyBands(pathlib.Path(temporary), cache_dir, result)
try:
for path, score_key in paths:
try:
document = json.loads(path.read_text(encoding='utf-8'))
style = generator.engraving.types.score_style(document, generator.engraving.types.Style())
destination = path.with_suffix('.pages')
clear_pages(destination)
destination.mkdir()
if score_key in scores:
source, pages = scores[score_key]
for page in pages:
shutil.copyfile(source / page['path'], destination / page['path'])
result.fullscore += 1
else:
if systems is None:
started = time.monotonic()
generator.model.validate_document(document)
index = generator.engraving.notation.ScoreIndex(document)
systems = generator.engraving.layout.layout_systems(document, style, family, index=index)
result.timings['layout'] += time.monotonic() - started
started = time.monotonic()
pages_layout = generator.engraving.layout.paginate(systems, document, family, style, index=index)
placement = tuple((page.width, page.height, tuple((system.start, system.end, system.box) for system in page.systems)) for page in pages_layout)
if placement not in audited:
layout = generator.engraving.types.LayoutDocument(pages_layout, style, fingerprint)
generator.engraving.audit.audit_layout(document, layout, family)
audited.add(placement)
else:
for page in pages_layout:
decoration = tuple(p for p in page.primitives if p.role in ('title', 'subtitle', 'page_number'))
generator.engraving.audit.audit_primitives(decoration, page.width, page.height, family)
result.timings['pagination'] += time.monotonic() - started
pages = []
for page in pages_layout:
bands = generator.engraving.raster.page_bands(page)
if bands is None:
started = time.monotonic()
image = generator.engraving.raster.rasterize_page(page, family)
else:
body = bodies.get(notation, page, bands[1], family)
started = time.monotonic()
image = generator.engraving.raster.compose_page(page, family, bands, body)
target = destination / f'{page.number:04}.png'
with image:
image.save(target, format='PNG')
result.timings['raster'] += time.monotonic() - started
result.renderedpages += 1
pages.append({'path': target.name, 'sha256': hashlib.sha256(target.read_bytes()).hexdigest(), **generator.performance.page_timing(document, page)})
scores[score_key] = (destination, pages)
write_bundle(path, document, pages, fingerprint)
result.scores.append((path, score_key, pages))
if progress and len(result.scores) % 50 == 0:
print(f'Engraving body {notation[:12]}: {len(result.scores)}/{len(paths)} scores, fullscore {result.fullscore}, bodyhits {result.bodyhits}, bodies {result.bodies}, renderedpages {result.renderedpages}', flush=True)
except ValueError as error:
raise generator.engraving.types.EngravingError(f'{path.relative_to(root)}: {error}') from error
finally:
bodies.close()
return result
import generator.engraving.worker
import generator.validation
def engrave_tree(root: pathlib.Path, fonts: pathlib.Path, *, cache_dir: pathlib.Path | None = None, jobs: int = 1, progress: bool = False) -> set[str]:
if type(jobs) is not int or not 1 <= jobs <= 16:
@@ -198,22 +33,22 @@ def engrave_tree(root: pathlib.Path, fonts: pathlib.Path, *, cache_dir: pathlib.
print(f'Engraving cache enabled: {cache_dir} ({state}; renderer {renderer})', flush=True)
elif progress:
print('Engraving cache disabled', flush=True)
totals = GroupResult()
totals = generator.engraving.worker.GroupResult()
missing, rejected, completed = 0, 0, 0
groups = {}
for path in paths:
try:
document = json.loads(path.read_text(encoding='utf-8'))
generator.model.validate_document(document)
generator.validation.validate_document(document)
score_key = generator.engraving.cache.score_fingerprint(document, renderer)
destination = path.with_suffix('.pages')
clear_pages(destination)
generator.engraving.worker.clear_pages(destination)
entry = cache_dir / 'fullscore' / score_key if cache_dir else None
present = entry is not None and (entry.exists() or entry.is_symlink())
pages = generator.engraving.cache.restore_pages(entry, destination, validated_pages) if entry else None
if pages is not None:
try:
generator.performance.validate_pages(document, pages)
generator.engraving.worker.validate_cached_views(document, pages)
except (ValueError, TypeError, KeyError):
pages = None
if pages is None:
@@ -222,7 +57,7 @@ def engrave_tree(root: pathlib.Path, fonts: pathlib.Path, *, cache_dir: pathlib.
notation = generator.engraving.cache.notation_fingerprint(document, renderer)
groups.setdefault(notation, []).append((path, score_key))
else:
write_bundle(path, document, pages, fingerprint)
generator.engraving.worker.write_bundle(path, document, pages, fingerprint)
totals.fullscore += 1
completed += 1
except ValueError as error:
@@ -259,10 +94,10 @@ def engrave_tree(root: pathlib.Path, fonts: pathlib.Path, *, cache_dir: pathlib.
jobs = min(jobs, len(groups))
if jobs <= 1:
for notation, group in groups.items():
finish(engrave_group(notation, group, root, fonts, cache_dir, fingerprint, progress))
finish(generator.engraving.worker.engrave_group(notation, group, root, fonts, cache_dir, fingerprint, progress))
else:
with concurrent.futures.ProcessPoolExecutor(max_workers=jobs, mp_context=multiprocessing.get_context('spawn')) as pool:
futures = [pool.submit(engrave_group, notation, group, root, fonts, cache_dir, fingerprint, progress) for notation, group in groups.items()]
futures = [pool.submit(generator.engraving.worker.engrave_group, notation, group, root, fonts, cache_dir, fingerprint, progress) for notation, group in groups.items()]
for future in concurrent.futures.as_completed(futures):
finish(future.result())
if progress:
+13 -9
View File
@@ -30,12 +30,14 @@ class OutlinePen(fontTools.pens.basePen.BasePen):
def _endPath(self):
pass
def rasterize_page(page: generator.engraving.types.Page, fonts: generator.engraving.fonts.Fonts) -> PIL.Image.Image:
return rasterize_band(page, page.primitives, 0, page.height, fonts)
def rasterize_page(page: generator.engraving.types.Page, fonts: generator.engraving.fonts.Fonts, *, ink=None, background=None, output_scale=1) -> PIL.Image.Image:
return rasterize_band(page, page.primitives, 0, page.height, fonts, ink=ink, background=background, output_scale=output_scale)
def rasterize_band(page: generator.engraving.types.Page, primitives: tuple[generator.engraving.types.Primitive, ...], top: int, bottom: int, fonts: generator.engraving.fonts.Fonts) -> PIL.Image.Image:
scale = page.supersampling
image = PIL.Image.new('RGB', (page.width * scale, (bottom - top) * scale), generator.theme.rgb('background'))
def rasterize_band(page: generator.engraving.types.Page, primitives: tuple[generator.engraving.types.Primitive, ...], top: int, bottom: int, fonts: generator.engraving.fonts.Fonts, *, ink=None, background=None, output_scale=1) -> PIL.Image.Image:
ink = generator.theme.rgb('ink') if ink is None else ink
background = generator.theme.rgb('background') if background is None else background
scale = page.supersampling * output_scale
image = PIL.Image.new('RGB', (round(page.width * scale), round((bottom - top) * scale)), background)
context = aggdraw.Draw(image)
for item in primitives:
points = [(x * scale, y * scale - top * scale) for x, y in item.points]
@@ -56,16 +58,18 @@ def rasterize_band(page: generator.engraving.types.Page, primitives: tuple[gener
if item.kind == 'polygon':
path.close()
if item.kind in ('glyph', 'polygon'):
context.path(path, None, aggdraw.Brush(generator.theme.rgb('ink')))
context.path(path, None, aggdraw.Brush(ink))
else:
context.path(path, aggdraw.Pen(generator.theme.rgb('ink'), item.thickness * scale))
context.path(path, aggdraw.Pen(ink, item.thickness * scale))
context.flush()
drawing = PIL.ImageDraw.Draw(image)
for item in primitives:
if item.kind == 'text':
x, y = item.points[0]
drawing.text((x * scale, y * scale - top * scale), item.value, font=fonts.text_font(item.size * scale), anchor='ls', fill=generator.theme.rgb('ink'))
return image.resize((page.width, bottom - top), PIL.Image.Resampling.LANCZOS)
drawing.text((x * scale, y * scale - top * scale), item.value, font=fonts.text_font(item.size * scale), anchor='ls', fill=ink)
result = image.resize((round(page.width * output_scale), round((bottom - top) * output_scale)), PIL.Image.Resampling.LANCZOS)
image.close()
return result
@dataclasses.dataclass(frozen=True)
class Band:
+3 -3
View File
@@ -123,7 +123,7 @@ def draw_spans(index: generator.engraving.notation.ScoreIndex, anchors: list[gen
y = anchor.y - anchor.direction * 8
if anchor.x - 2 > left:
result.append(generator.engraving.types.curve('tie', (identifier,), ((left, y), (left + 5, y - anchor.direction * 9), (anchor.x - 7, y - anchor.direction * 9), (anchor.x - 2, y)), 1.6))
top = min(-style.space * 5, min((p.box.top for p in items if p.role not in ('harmony', 'lyric', 'section', 'scale', 'tempo')), default=0))
top = min(-style.space * 5, min((p.box.top for p in items if p.role not in ('harmony', 'lyric', 'section', 'scale', 'tempo', 'measure_number')), default=0))
tuplet_lanes = []
for span in index.staff.get('tuplets', []):
a, b = index.by_id[span['start']], index.by_id[span['end']]
@@ -203,11 +203,11 @@ def draw_spans(index: generator.engraving.notation.ScoreIndex, anchors: list[gen
return items + result
def place_text_lanes(items: list[generator.engraving.types.Primitive], fonts: generator.engraving.fonts.Fonts, style: generator.engraving.types.Style) -> list[generator.engraving.types.Primitive]:
music = [p for p in items if p.role not in ('harmony', 'lyric', 'section', 'scale')]
music = [p for p in items if p.role not in ('harmony', 'lyric', 'section', 'scale', 'measure_number')]
box = generator.engraving.types.bounds(music)
result = list(music)
top = box.top - 12
for role in ('harmony', 'scale', 'section'):
for role in ('measure_number', 'harmony', 'scale', 'section'):
lane = [p for p in items if p.role == role]
if lane:
extent = generator.engraving.types.bounds(lane)
+190
View File
@@ -0,0 +1,190 @@
from __future__ import annotations
import collections
import dataclasses
import hashlib
import json
import pathlib
import shutil
import tempfile
import time
import PIL.Image
import generator.engraving.audit
import generator.engraving.cache
import generator.engraving.fonts
import generator.engraving.layout
import generator.engraving.notation
import generator.engraving.raster
import generator.engraving.types
import generator.engraving.validation
import generator.performance
import generator.validation
@dataclasses.dataclass
class GroupResult:
scores: list = dataclasses.field(default_factory=list)
fullscore: int = 0
bodyhits: int = 0
bodies: int = 0
renderedpages: int = 0
rejected: int = 0
timings: dict = dataclasses.field(default_factory=lambda: dict.fromkeys(('layout', 'pagination', 'raster', 'cache'), 0.0))
class BodyBands:
def __init__(self, root, persistent, result, limit=16 * 1024 * 1024):
self.root, self.persistent, self.result, self.limit = root, persistent, result, limit
self.images = collections.OrderedDict()
self.size = 0
self.known = {}
self.root.mkdir(parents=True, exist_ok=True)
def get(self, notation, page, band, fonts):
key = generator.engraving.cache.band_fingerprint(notation, page, band)
if key in self.images:
self.images.move_to_end(key)
self.result.bodyhits += 1
return self.images[key]
started = time.monotonic()
entry = self.root / (key + '.rgb')
image = None
if key in self.known:
if entry.is_symlink() or entry.stat().st_size != page.width * (band.bottom - band.top) * 3:
raise generator.engraving.types.EngravingError('temporary notation band was corrupted')
data = entry.read_bytes()
if hashlib.sha256(data).hexdigest() != self.known[key]:
raise generator.engraving.types.EngravingError('temporary notation band was corrupted')
image = PIL.Image.frombytes('RGB', (page.width, band.bottom - band.top), data)
elif self.persistent:
cached = self.persistent / 'notation' / key
image = generator.engraving.cache.restore_band(cached, key, page.width, band.bottom - band.top)
self.result.rejected += int(image is None and (cached.exists() or cached.is_symlink()))
self.result.timings['cache'] += time.monotonic() - started
if image is None:
started = time.monotonic()
image = generator.engraving.raster.rasterize_band(page, band.primitives, band.top, band.bottom, fonts)
self.result.timings['raster'] += time.monotonic() - started
self.result.bodies += 1
if self.persistent:
started = time.monotonic()
generator.engraving.cache.store_band(self.persistent / 'notation' / key, key, image)
self.result.timings['cache'] += time.monotonic() - started
else:
self.result.bodyhits += 1
if key not in self.known:
started = time.monotonic()
# Spill finalized pixels, so eviction never repeats rasterization or PNG decoding.
data = image.tobytes()
entry.write_bytes(data)
self.result.timings['cache'] += time.monotonic() - started
self.known[key] = hashlib.sha256(data).hexdigest()
size = image.width * image.height * 3
while self.images and self.size + size > self.limit:
_, old = self.images.popitem(last=False)
self.size -= old.width * old.height * 3
old.close()
self.images[key] = image
self.size += size
return image
def close(self):
for image in self.images.values():
image.close()
self.images.clear()
self.size = 0
def clear_pages(destination):
if destination.is_symlink() or destination.is_file():
destination.unlink()
elif destination.exists():
shutil.rmtree(destination)
def write_bundle(path, document, pages, fingerprint):
entries = [{k: v for k, v in {**page, 'path': path.with_suffix('.pages').name + '/' + page['path']}.items() if k != 'playback'} for page in pages]
normal = [entry for entry, page in zip(entries, pages) if not page['playback']]
playback = [entry for entry, page in zip(entries, pages) if page['playback']]
music = document
bundle = {'music': music, 'presentation': {'engine': generator.engraving.validation.ENGINE_NAME, 'style_sha256': fingerprint,
'width': generator.engraving.validation.PAGE_WIDTH, 'height': generator.engraving.validation.PAGE_HEIGHT, 'pages': normal, 'playback_pages': playback}}
validate_cached_views(document, pages)
bundle['performance'] = generator.performance.timing(document)
path.write_text(json.dumps(bundle, indent=2, ensure_ascii=False) + '\n', encoding='utf-8')
def validate_cached_views(document, pages):
generator.performance.validate_views(document, [p for p in pages if not p['playback']], [p for p in pages if p['playback']])
def engrave_group(notation, paths, root, font_path, cache_dir, fingerprint, progress=False):
family = generator.engraving.fonts.Fonts(font_path)
style = generator.engraving.types.Style()
systems = None
index = None
scores = {}
audited = set()
result = GroupResult()
with tempfile.TemporaryDirectory(prefix='vamp_notation_') as temporary:
bodies = BodyBands(pathlib.Path(temporary), cache_dir, result)
try:
for path, score_key in paths:
try:
document = json.loads(path.read_text(encoding='utf-8'))
style = generator.engraving.types.score_style(document, generator.engraving.types.Style())
destination = path.with_suffix('.pages')
clear_pages(destination)
destination.mkdir()
if score_key in scores:
source, pages = scores[score_key]
for page in pages:
shutil.copyfile(source / page['path'], destination / page['path'])
result.fullscore += 1
else:
if systems is None:
started = time.monotonic()
generator.validation.validate_document(document)
index = generator.engraving.notation.ScoreIndex(document)
systems = generator.engraving.layout.layout_systems(document, style, family, index=index)
result.timings['layout'] += time.monotonic() - started
started = time.monotonic()
pages_layout, playback_layout = generator.engraving.layout.page_views(systems, document, family, style, index=index)
placement = tuple((page.width, page.height, tuple((system.start, system.end, system.box) for system in page.systems)) for page in pages_layout)
if placement not in audited:
layout = generator.engraving.types.LayoutDocument(pages_layout, style, fingerprint)
generator.engraving.audit.audit_layout(document, layout, family)
generator.engraving.audit.audit_playback(pages_layout, playback_layout, style, family)
audited.add(placement)
else:
for page in pages_layout + playback_layout:
decoration = tuple(p for p in page.primitives if p.role in ('title', 'subtitle', 'page_number'))
generator.engraving.audit.audit_primitives(decoration, page.width, page.height, family)
result.timings['pagination'] += time.monotonic() - started
pages = []
rendered = {}
for is_playback, page in [(False, p) for p in pages_layout] + [(True, p) for p in playback_layout]:
if page.primitives in rendered:
name, digest = rendered[page.primitives]
pages.append(dict(path=name, sha256=digest, playback=is_playback, **generator.performance.page_timing(document, page)))
continue
bands = generator.engraving.raster.page_bands(page)
if bands is None:
started = time.monotonic()
image = generator.engraving.raster.rasterize_page(page, family)
else:
body = bodies.get(notation, page, bands[1], family)
started = time.monotonic()
image = generator.engraving.raster.compose_page(page, family, bands, body)
target = destination / (('playback-' if is_playback else '') + f'{page.number:04}.png')
with image:
image.save(target, format='PNG')
result.timings['raster'] += time.monotonic() - started
result.renderedpages += 1
digest = hashlib.sha256(target.read_bytes()).hexdigest()
rendered[page.primitives] = target.name, digest
pages.append(dict(path=target.name, sha256=digest, playback=is_playback, **generator.performance.page_timing(document, page)))
scores[score_key] = (destination, pages)
write_bundle(path, document, pages, fingerprint)
result.scores.append((path, score_key, pages))
if progress and len(result.scores) % 50 == 0:
print(f'Engraving body {notation[:12]}: {len(result.scores)}/{len(paths)} scores, fullscore {result.fullscore}, bodyhits {result.bodyhits}, bodies {result.bodies}, renderedpages {result.renderedpages}', flush=True)
except ValueError as error:
raise generator.engraving.types.EngravingError(f'{path.relative_to(root)}: {error}') from error
finally:
bodies.close()
return result
+12 -4
View File
@@ -12,7 +12,8 @@ STANDARD_TUNING = ((6, 40), (5, 45), (4, 50), (3, 55), (2, 59), (1, 64))
MIN_FRET = 1
MAX_FRET = 20
MAX_SINGLE_FRET = 12
MAX_FRET_SPAN = 3
PREFERRED_FRET_SPAN = 3
MAX_FRET_SPAN = 4
MAX_ANCHOR_FRET = 12
WRITTEN_GUITAR_OCTAVE_OFFSET = 12
@@ -21,10 +22,17 @@ class TabPosition(typing.NamedTuple):
fret: int
midi: int
def within_fret_span(positions) -> bool:
"""Count occupied fret positions inclusively: frets 1-3 fit, 1-4 do not."""
def fret_span(positions) -> int:
"""Inclusive occupied positions: frets 7-9 span three, 7-10 span four."""
frets = [position.fret for position in positions]
return not frets or max(frets) - min(frets) + 1 <= MAX_FRET_SPAN
return max(frets) - min(frets) + 1 if frets else 0
def span_penalty(positions) -> int:
"""Two tiers for legal grips; all one-to-three-fret shapes share tier zero."""
return int(fret_span(positions) > PREFERRED_FRET_SPAN)
def within_fret_span(positions) -> bool:
return fret_span(positions) <= MAX_FRET_SPAN
def has_fret_anchor(positions) -> bool:
return any(MIN_FRET <= position.fret <= MAX_ANCHOR_FRET for position in positions)
+111 -89
View File
@@ -7,27 +7,62 @@ import itertools
import logging
import typing
import generator.chord_families
import generator.fretboard
import generator.model
import generator.hand_position
import generator.pitch
import generator.vocabulary
PREFERRED_MAX_FRET = 12
ELECTRIC_STRINGS = ((3, 2, 1), (4, 3, 2, 1))
class VoicingCost(typing.NamedTuple):
string_shortfall: int = 0
extended_grips: int = 0
melody_string: int = 0
covered_melody: int = 0
covering_tones: int = 0
effort: int = 0
string_shortfall: int = 0
family_penalty: int = 0
travel: int = 0
peak_position: int = 0
effort: fractions.Fraction = fractions.Fraction()
missing_tones: int = 0
register: fractions.Fraction = fractions.Fraction()
def plus(self, other: VoicingCost) -> VoicingCost:
return VoicingCost(*(a + b for a, b in zip(self, other)))
return VoicingCost(*(max(a, b) if field == "peak_position" else a + b for field, a, b in zip(self._fields, self, other)))
@functools.lru_cache(maxsize=16384)
def moved(self, distance: int) -> VoicingCost:
return self._replace(effort=self.effort + distance)
def moved(self, distance: int, ergonomics: int = 0) -> VoicingCost:
return self._replace(travel=self.travel + distance, effort=self.effort + ergonomics)
def voicing_preference(role, center=None, *, composition=None):
"""Immutable role settings for both selection and scored-retrieval caches."""
composition = composition or generator.vocabulary.current()
settings = composition.role(role)
policy = settings.get('voicing', {})
center = settings.get('center', 53 if role.startswith('acoustic') else 60) if center is None else center
if set(policy) - {'register_weight'}:
raise ValueError('unknown voicing preference; hand position is ranked across the passage')
result = tuple(fractions.Fraction(str(v)) for v in (center, policy.get('register_weight', 1)))
if result[1] < 0:
raise ValueError('voicing preference requires a nonnegative register tie weight')
return result
@functools.lru_cache(maxsize=8192)
def voicing_cost(positions: tuple[generator.fretboard.TabPosition, ...], profile: str = '', allowed: tuple[int, ...] = (), melody: tuple[int, ...] = ()) -> VoicingCost:
def voicing_preferences(positions, preference):
if not positions or not preference:
return fractions.Fraction()
center, register_weight = preference
register = abs(fractions.Fraction(sum(p.midi for p in positions), len(positions)) - center)
return register_weight * register
def voicing_cost(positions: tuple[generator.fretboard.TabPosition, ...], profile: str = '', allowed: tuple[int, ...] = (), melody: tuple[int, ...] = (), *, composition=None) -> VoicingCost:
composition = composition or generator.vocabulary.current()
families = tuple(composition.accompaniment('electric')['voicing_families']['rank'].items()) if profile == 'electric' else ()
preference = voicing_preference('electric_melody', composition=composition) if profile == 'electric' and melody else ()
return _voicing_cost(positions, profile, allowed, melody, families, preference)
@functools.lru_cache(maxsize=8192)
def _voicing_cost(positions, profile, allowed, melody, families, preference):
frets = {p.fret for p in positions}
classes = {p.midi % 12 for p in positions}
above = sum(p.midi > max(melody) for p in positions) if melody else 0
@@ -35,11 +70,19 @@ def voicing_cost(positions: tuple[generator.fretboard.TabPosition, ...], profile
if profile == 'electric':
effort = 2 * max(0, len(frets) - 1) + 3 * span
else:
effort = 2 * max(0, max(frets, default=0) - PREFERRED_MAX_FRET) + span
return VoicingCost(max(0, 4 - len(positions)) if profile == 'electric' else 0, int(bool(above)), above, effort, len(set(allowed) - classes))
effort = span
family_penalty = dict(families).get(generator.chord_families.electric(positions), 0) if positions and families else 0
melody_string = min((p.string_number - 1 for p in positions if melody and p.midi == max(melody)), default=0)
return VoicingCost(extended_grips=generator.fretboard.span_penalty(positions), melody_string=melody_string, string_shortfall=max(0, 4 - len(positions)) if profile == 'electric' else 0, covered_melody=int(bool(above)), covering_tones=above, family_penalty=family_penalty, effort=effort, missing_tones=len(set(allowed) - classes), register=voicing_preferences(positions, preference))
def chord_positions(requirements: generator.fretboard.ChordRequirements, prune: bool = True, profile: str = '', melody: tuple[int, ...] = (), *, composition=None) -> tuple[tuple[generator.fretboard.TabPosition, ...], ...]:
composition = composition or generator.vocabulary.current()
families = tuple(composition.accompaniment('electric')['voicing_families']['rank'].items()) if profile == 'electric' else ()
preference = voicing_preference('electric_melody', composition=composition) if profile == 'electric' and melody else ()
return _chord_positions(requirements, prune, profile, melody, families, preference)
@functools.lru_cache(maxsize=256)
def chord_positions(requirements: generator.fretboard.ChordRequirements, prune: bool = True, profile: str = '', melody: tuple[int, ...] = ()) -> tuple[tuple[generator.fretboard.TabPosition, ...], ...]:
def _chord_positions(requirements, prune, profile, melody, families, preference):
result = []
options = [tuple(generator.fretboard.TabPosition(string, fret, open_midi + fret) for fret in range(generator.fretboard.MIN_FRET, generator.fretboard.MAX_FRET + 1) if (open_midi + fret) % 12 in requirements.allowed or open_midi + fret in melody) for string, open_midi in generator.fretboard.STANDARD_TUNING]
@@ -57,6 +100,7 @@ def chord_positions(requirements: generator.fretboard.ChordRequirements, prune:
if profile:
by_string = {string: options[i] for i, (string, _) in enumerate(generator.fretboard.STANDARD_TUNING)}
# Every electric chord includes string 1, even with a lower melody inside.
for strings in ELECTRIC_STRINGS:
for selected in itertools.product(*(by_string[s] for s in strings)):
if not generator.fretboard.within_fret_span(selected) or not generator.fretboard.has_fret_anchor(selected) or not requirements.covers({p.midi % 12 for p in selected}) or not set(melody) <= {p.midi for p in selected}:
@@ -66,29 +110,13 @@ def chord_positions(requirements: generator.fretboard.ChordRequirements, prune:
result.append(selected)
else:
visit(0, (), set())
if not prune:
return tuple(sorted(result))
# Independent attacks with equal centers have identical movement costs.
# Held strings require the full candidate set instead of this reduction.
best = {}
for positions in result:
center = position_center(positions)
rank = (voicing_cost(positions, profile, requirements.allowed, melody), positions)
if center not in best or rank < best[center][0]:
best[center] = (rank, positions)
return tuple(sorted(item[1] for item in best.values()))
# Equal centers no longer imply equal future movement. Keep concrete grips;
# only identical positions can be merged before contextual placement.
return tuple(sorted(set(result)))
@functools.lru_cache(maxsize=16384)
def movement(previous: tuple[generator.fretboard.TabPosition, ...], current: tuple[generator.fretboard.TabPosition, ...]) -> int:
if not previous or not current:
return 0
return sum(abs(a - b) for a, b in zip(position_center(previous), position_center(current)))
@functools.lru_cache(maxsize=4096)
def position_center(positions: tuple[generator.fretboard.TabPosition, ...]) -> tuple[int, int]:
frets = [p.fret for p in positions] or [0]
strings = [p.string_number for p in positions]
return min(frets) + max(frets), min(strings) + max(strings) - 2
def movement(previous, current, old_hand, hand) -> int:
return generator.hand_position.motion(previous, current, old_hand, hand).shift
def compactness(positions) -> int:
frets = [p.fret for p in positions]
@@ -110,38 +138,7 @@ class Placement:
active: tuple
previous: Placement | None
choices: tuple
def nearest_positions(states: dict) -> list[list[tuple | None]]:
"""Exact Manhattan distance transform on the small fret/string position grid."""
initial = min(((p.cost, i, p) for i, p in enumerate(states.values()) if not p.active), key=lambda item: item[:2], default=None)
grid = [[initial for _ in range(11)] for _ in range(2 * generator.fretboard.MAX_FRET + 1)]
for index, previous in enumerate(states.values()):
if not previous.active:
continue
x, y = position_center(tuple(p for _, p in previous.active))
candidate = (previous.cost, index, previous)
if grid[x][y] is None or candidate[:2] < grid[x][y][:2]:
grid[x][y] = candidate
def relax(x, y, a, b):
source = grid[a][b]
if source is not None:
cost, index, previous = source
candidate = (cost.moved(1), index, previous)
if grid[x][y] is None or candidate[:2] < grid[x][y][:2]:
grid[x][y] = candidate
for y in range(11):
for x in range(1, len(grid)):
relax(x, y, x - 1, y)
for x in range(len(grid) - 2, -1, -1):
relax(x, y, x + 1, y)
for x in range(len(grid)):
for y in range(1, 11):
relax(x, y, x, y - 1)
for y in range(9, -1, -1):
relax(x, y, x, y + 1)
return grid
hand: int = 0
@dataclasses.dataclass(frozen=True)
class GuitarTone:
@@ -173,7 +170,8 @@ def continued_sources(notes):
def has_attack(notes: list[dict]) -> bool:
return any('_harmony' in n and '_continue_from' not in n or any('tie_from' not in p for p in n['pitches']) for n in notes)
def attack_candidates(notes: list[dict], tones: dict[str, GuitarTone], active: dict, held: dict, preserve_strings: bool, fallback: bool = False):
def attack_candidates(notes: list[dict], tones: dict[str, GuitarTone], active: dict, held: dict, preserve_strings: bool, fallback: bool = False, *, composition=None):
composition = composition or generator.vocabulary.current()
pending = []
chords = [n for n in notes if '_harmony' in n]
chord = chords[0] if chords else None
@@ -191,7 +189,7 @@ def attack_candidates(notes: list[dict], tones: dict[str, GuitarTone], active: d
requirements = generator.fretboard.chord_requirements(chord['_harmony'], respect_bass=profile != 'electric') if chord else generator.fretboard.ChordRequirements()
melody = tuple(sorted({p.midi for _, options in pending for p in options})) if profile == 'electric' else ()
fresh = has_attack(notes)
candidates = chord_positions(requirements, prune=not (preserve_strings or held or pending or profile), profile=profile, melody=melody) if chord else [()]
candidates = chord_positions(requirements, prune=not (preserve_strings or held or pending or profile), profile=profile, melody=melody, composition=composition) if chord else [()]
for exact in extend_positions(held, sorted(pending, key=lambda p: len(p[1]))):
exact_positions = dict(exact)
for positions in candidates:
@@ -215,7 +213,7 @@ def attack_candidates(notes: list[dict], tones: dict[str, GuitarTone], active: d
choices.append(EventPlacement(note, tuple((p, exact_positions[p['id']]) for p in note['pitches']), added))
if not compatible or not playable_choices(choices):
continue
cost = voicing_cost(positions, profile, requirements.allowed, melody) if fresh else VoicingCost()
cost = voicing_cost(positions, profile, requirements.allowed, melody, composition=composition) if fresh else VoicingCost()
yield AttackCandidate(tuple(sorted(assignment.items())), tuple(choices), positions, cost)
else:
shape = tuple(p for _, p in exact) + positions
@@ -225,7 +223,7 @@ def attack_candidates(notes: list[dict], tones: dict[str, GuitarTone], active: d
choices = tuple(EventPlacement(n, tuple((p, exact_positions[p['id']]) for p in n['pitches']), positions if n is chord else ()) for n in notes)
if not playable_choices(choices):
continue
cost = voicing_cost(shape, profile, requirements.allowed, melody) if fresh else VoicingCost()
cost = voicing_cost(shape, profile, requirements.allowed, melody, composition=composition) if fresh else VoicingCost()
yield AttackCandidate(assignment, choices, shape, cost)
def guitar_events(document: dict) -> tuple[list, dict[str, GuitarTone]]:
@@ -276,55 +274,78 @@ def guitar_events(document: dict) -> tuple[list, dict[str, GuitarTone]]:
def retain_tone(tone: GuitarTone, onset: fractions.Fraction) -> bool:
return tone.end > onset or tone.end == onset and bool(tone.pitch.get('tie_to'))
def keep_position(result, candidate, previous, fresh=True):
old_shape = tuple(p for _, p in previous.active)
hands = [previous.hand]
if fresh:
hands = generator.hand_position.regions(candidate.shape)
for hand in hands:
if candidate.shape and not all(hand <= p.fret <= hand + 3 for p in candidate.shape):
continue
motion = generator.hand_position.motion(old_shape, candidate.shape, previous.hand, hand) if fresh else generator.hand_position.Motion()
local = candidate.cost._replace(peak_position=hand)
cost = previous.cost.plus(local).moved(motion.shift, motion.ergonomics)
key = (candidate.active, hand, cost.peak_position)
value = Placement(cost, candidate.active, previous, candidate.choices, hand)
if key not in result or cost < result[key].cost:
result[key] = value
def reduce_positions(result):
# Future effort depends on the concrete held strings and hand, not on the
# earlier route. A strictly worse primary cost is dominated even if lower.
best = {}
for (active, hand, _), state in result.items():
key = (active, hand)
best[key] = min(best.get(key, state.cost[:7]), state.cost[:7])
return {key: state for key, state in result.items() if state.cost[:7] == best[key[:2]]}
def advance_attacks(candidates, states: dict) -> dict:
nearest = nearest_positions(states)
result = {}
for candidate in candidates:
x, y = position_center(candidate.shape)
cost, _, previous = nearest[x][y]
cost = cost.plus(candidate.cost)
if candidate.active not in result or cost < result[candidate.active].cost:
result[candidate.active] = Placement(cost, candidate.active, previous, candidate.choices)
return result
for previous in states.values():
keep_position(result, candidate, previous)
return reduce_positions(result)
def advance_positions(notes: list[dict], onset: fractions.Fraction, tones: dict[str, GuitarTone], states: dict, preserve_strings: bool, fallback: bool = False) -> dict:
def advance_positions(notes: list[dict], onset: fractions.Fraction, tones: dict[str, GuitarTone], states: dict, preserve_strings: bool, fallback: bool = False, *, composition=None) -> dict:
composition = composition or generator.vocabulary.current()
continued = continued_sources(notes)
fresh = has_attack(notes)
held_ids = {i for previous in states.values() for i, _ in previous.active if retain_tone(tones[i], onset)}
result = {}
def keep(candidate, previous, cost):
cost = cost.plus(candidate.cost)
if candidate.active not in result or cost < result[candidate.active].cost:
result[candidate.active] = Placement(cost, candidate.active, previous, candidate.choices)
if not held_ids and not continued:
result = advance_attacks(attack_candidates(notes, tones, {}, {}, preserve_strings, fallback), states)
result = advance_attacks(attack_candidates(notes, tones, {}, {}, preserve_strings, fallback, composition=composition), states)
else:
for previous in states.values():
active = dict(previous.active)
held = {i: p for i, p in previous.active if i not in continued and i in held_ids}
for candidate in attack_candidates(notes, tones, active, held, preserve_strings, fallback):
distance = movement(tuple(p for _, p in previous.active), candidate.shape) if fresh else 0
keep(candidate, previous, previous.cost.moved(distance))
for candidate in attack_candidates(notes, tones, active, held, preserve_strings, fallback, composition=composition):
keep_position(result, candidate, previous, fresh)
if not result:
if not fallback and any(n.get('_harmonize') for n in notes):
return advance_positions(notes, onset, tones, states, preserve_strings, True)
return advance_positions(notes, onset, tones, states, preserve_strings, True, composition=composition)
raise ValueError(f'event {notes[0]["id"]}, onset {onset}: no guitar placement; single notes need frets {generator.fretboard.MIN_FRET}-{generator.fretboard.MAX_SINGLE_FRET}; chords need frets {generator.fretboard.MIN_FRET}-{generator.fretboard.MAX_FRET}, an anchor <= {generator.fretboard.MAX_ANCHOR_FRET}, and at most {generator.fretboard.MAX_FRET_SPAN} consecutive fret positions; held/tied strings must remain fixed')
return result
return reduce_positions(result)
def place_guitar(document: dict) -> None:
def place_guitar(document: dict, *, composition=None) -> dict:
"""Choose electric voicings or exact/held melody placements."""
composition = composition or generator.vocabulary.current()
events, tones = guitar_events(document)
states = {(): Placement(VoicingCost(), (), None, ())}
groups = [(key[0], [item[3] for item in values]) for key, values in itertools.groupby(events, key=lambda e: e[:3])]
for index, (onset, notes) in enumerate(groups):
next_onset = groups[index + 1][0] if index + 1 < len(groups) else None
preserve_strings = next_onset is not None and any('_harmony' in n and onset + generator.model.fraction(n['duration']) > next_onset for n in notes)
states = advance_positions(notes, onset, tones, states, preserve_strings)
states = advance_positions(notes, onset, tones, states, preserve_strings, composition=composition)
selected = min(states.values(), key=lambda s: (s.cost, s.active))
trace = []
final_cost = selected.cost
skipped = []
while selected.previous is not None:
fresh = has_attack([c.note for c in selected.choices])
motion = generator.hand_position.motion(tuple(p for _, p in selected.previous.active), tuple(p for _, p in selected.active), selected.previous.hand, selected.hand) if fresh else generator.hand_position.Motion()
trace.append({'hand_position': selected.hand, 'events': [c.note['id'] for c in selected.choices],
'hand_shift': motion.shift, 'finger_adjustment': motion.fingers, 'string_changes': motion.strings,
'effort': str(selected.cost.effort - selected.previous.cost.effort)})
for choice in selected.choices:
note = choice.note
for tone, position in choice.exact:
@@ -344,3 +365,4 @@ def place_guitar(document: dict) -> None:
logging.getLogger(__name__).warning('%s: %s melody harmonizations kept as single notes; first event %s', document['metadata']['title'], len(skipped), skipped[-1])
document['staves'][0]['tablature'] = True
generator.fretboard.validate_document(document)
return {'version': generator.hand_position.VERSION, **generator.hand_position.summary(r['hand_shift'] for r in trace), 'peak_position': final_cost.peak_position, 'cost': {k: str(v) for k, v in final_cost._asdict().items()}, 'positions': list(reversed(trace))}
+52
View File
@@ -0,0 +1,52 @@
"""Four-fret hand windows shared by chord and single-note placement.
This describes playable regions, not an anatomical fingering solver. Chord
and single tones may occupy any frets within the window. Only shifting the
window is movement. Actual sounded-note limits remain in fretboard.py.
"""
import functools
import typing
import generator.fretboard
VERSION = 'hand-window-2'
class Motion(typing.NamedTuple):
shift: int = 0
fingers: int = 0
strings: int = 0
@property
def ergonomics(self):
return self.fingers + self.strings
def base(shape):
return min((p.fret for p in shape), default=0)
@functools.lru_cache(maxsize=4096)
def regions(shape):
if not shape:
return tuple([0])
return tuple(range(max(1, max(p.fret for p in shape) - 3), min(base(shape), generator.fretboard.MAX_ANCHOR_FRET) + 1))
@functools.lru_cache(maxsize=32768)
def motion(previous, current, old_hand, hand, acoustic=False):
if not previous or not current:
return Motion()
if len(previous) == len(current) == 1:
pairs = ((previous[0], current[0]),)
unmatched = 0
else:
def voices(shape):
return {('bass' if acoustic and p.string_number in (5, 6) else p.string_number): p for p in shape}
a, b = voices(previous), voices(current)
pairs = tuple((a[s], b[s]) for s in a.keys() & b.keys())
unmatched = len(a.keys() ^ b.keys())
return Motion(abs(hand - old_hand),
unmatched + sum(abs((a.fret - old_hand) - (b.fret - hand)) for a, b in pairs),
sum(abs(a.string_number - b.string_number) for a, b in pairs))
def summary(shifts):
shifts = tuple(shifts)
return {'total_travel': sum(shifts), 'shift_count': sum(s > 0 for s in shifts), 'largest_shift': max(shifts, default=0)}
-156
View File
@@ -3,8 +3,6 @@ from __future__ import annotations
import copy
import fractions
import typing
import generator.fretboard
import generator.pitch
MAX_INTEGER = (1 << 63) - 1
NOTE_TYPES = ('maxima', 'long', 'breve', 'whole', 'half', 'quarter', 'eighth', '16th', '32nd', '64th', '128th', '256th', '512th', '1024th')
@@ -140,157 +138,3 @@ def make_event(identifier: str, onset: fractions.Fraction, duration: fractions.F
if 'alter' in event['pitches'][-1]:
event['pitches'][-1]['alter'] = rational(alteration(p['alter']))
return event
def validate_document(document: dict) -> None:
if not isinstance(document, dict) or not isinstance(document.get('metadata'), dict):
raise ValueError('score requires a metadata object')
if any(not isinstance(document['metadata'].get(name), str) for name in ('title', 'composer', 'key_signature', 'time_signature')):
raise ValueError('score metadata requires title, composer, key_signature and time_signature strings')
staves = document.get('staves', [])
if not isinstance(staves, list) or len(staves) != 1 or not isinstance(staves[0], dict):
raise ValueError('exactly one staff is currently supported')
if not isinstance(staves[0].get('measures'), list) or not staves[0]['measures']:
raise ValueError('score requires measures')
instruments = staves[0].get('instruments', [])
instrument_ids = {i['id'] for i in instruments}
if len(instruments) != len(instrument_ids) or any(not isinstance(i, str) or not i for i in instrument_ids):
raise ValueError('score instruments require unique nonempty IDs')
ids: set[str] = set()
events: dict[str, dict] = {}
tones: dict[str, tuple[dict, fractions.Fraction, fractions.Fraction, str]] = {}
ownership: dict[str, str] = {}
absolute = fractions.Fraction()
for measure in staves[0]['measures']:
if {'repeats', 'endings', 'initial_attributes'} & measure.keys():
raise ValueError('repeat notation is unsupported; regenerate scores from music written out in reading order')
length = fraction(measure['duration'])
if length <= 0:
raise ValueError('measure duration must be positive')
voices = measure.get('voices', [])
if not voices or len({v['id'] for v in voices}) != len(voices) or any(not v['id'] for v in voices):
raise ValueError('measure requires uniquely identified voice lanes')
previous_ends = {v['id']: fractions.Fraction() for v in voices}
for voice, note in ((v, n) for v in voices for n in v['notes']):
if any({'sound_ties', 'printed_ties'} & pitch.keys() for pitch in note['pitches']):
raise ValueError('pass-specific tie metadata is unsupported; regenerate scores')
if not note['id'] or note['id'] in ids:
raise ValueError(f'duplicate event ID: {note["id"]}')
ids.add(note['id'])
events[note['id']] = note
ownership[note['id']] = voice['id']
if note.get('voice', voice['id']) != voice['id']:
raise ValueError('event voice ownership disagrees with its lane')
onset, duration = fraction(note['onset']), fraction(note['duration'])
if onset < 0 or duration < 0 or onset + duration > length:
raise ValueError(f'event outside measure: {note["id"]}')
if note['kind'] not in ('note', 'rest', 'spacer'):
raise ValueError('invalid event kind')
if not note.get('grace'):
if duration == 0 or onset < previous_ends[voice['id']]:
raise ValueError('overlapping events in one rhythmic voice')
previous_ends[voice['id']] = onset + duration
elif duration != 0:
raise ValueError('grace notes must not advance metric time')
expected = metric_length(note['written'])
if not note.get('grace') and not note.get('measure_rest') and duration != expected:
raise ValueError('metric and written event durations disagree')
if note['kind'] != 'note' and note.get('pitches'):
raise ValueError('rests and spacers cannot contain pitches')
if note['kind'] == 'note' and not note.get('pitches') and note.get('notehead') != 'slash':
raise ValueError('pitched event requires at least one pitch')
for p in note.get('pitches', []):
if p.get('instrument') and p['instrument'] not in instrument_ids:
raise ValueError('note refers to an unknown score instrument')
if 'unpitched' in p:
position = p['unpitched']
if position['letter'] not in LETTERS or type(position['octave']) is not int:
raise ValueError('invalid unpitched display position')
else:
pitch_number(p)
if staves[0].get('tablature'):
tab = p.get('tablature', {})
string, fret = tab.get('string'), tab.get('fret')
if type(string) is not int or type(fret) is not int or string not in dict(generator.fretboard.STANDARD_TUNING) or not generator.fretboard.MIN_FRET <= fret <= generator.fretboard.MAX_FRET:
raise ValueError(f'{p["id"]}: invalid generated tablature position')
state = dict(measure)
for change in measure.get('attributes', []):
if fraction(change['onset']) <= onset:
state.update(change)
if dict(generator.fretboard.STANDARD_TUNING)[string] + fret != generator.pitch.sounding_pitch(p, state):
raise ValueError(f'{p["id"]}: tablature disagrees with sounding pitch')
pd = fraction(p['duration'])
if pd < 0 or (pd == 0 and not note.get('grace')) or pd > duration or not p['id'] or p['id'] in tones:
raise ValueError('invalid chord-tone duration or duplicate ID')
if not note.get('grace') and pd != metric_length(p['written']):
raise ValueError('metric and written chord-tone durations disagree')
tones[p['id']] = (p, absolute + onset, pd, voice['id'])
for harmony in measure.get('harmonies', []):
if not 0 <= fraction(harmony['onset']) < length:
raise ValueError('harmony outside measure')
for change in measure.get('attributes', []):
if not 0 <= fraction(change['onset']) < length:
raise ValueError('attribute change outside measure')
for state in [measure, *measure.get('attributes', [])]:
if 'meter' in state:
validate_meter(state['meter'])
if 'key' in state:
if len(state['key']['alterations']) != 7:
raise ValueError('key alterations must contain seven exact alterations')
for value in state['key']['alterations']:
alteration(value)
if 'clef' in state and (state['clef']['sign'] not in ('G', 'F', 'C', 'percussion', 'none') or not 1 <= state['clef']['line'] <= 6 or not -3 <= state['clef']['octave_change'] <= 3):
raise ValueError('invalid clef')
absolute += length
for identifier, (p, start, duration, voice) in tones.items():
if target := p.get('tie_to'):
if target not in tones:
raise ValueError(f'dangling tie: {identifier} -> {target}')
other, next_start, _, next_voice = tones[target]
same_pitch = all(p.get(k) == other.get(k) for k in ('unpitched', 'instrument')) if 'unpitched' in p else all(p.get(k) == other.get(k) for k in ('letter', 'alter', 'octave'))
if other.get('tie_from') != identifier or not same_pitch or next_voice != voice or next_start != start + duration:
raise ValueError(f'invalid tie: {identifier} -> {target}')
if staves[0].get('tablature') and p['tablature'] != other['tablature']:
raise ValueError(f'{identifier}: tied guitar tones must retain their string and fret')
if source := p.get('tie_from'):
if source not in tones or tones[source][0].get('tie_to') != identifier:
raise ValueError(f'dangling incoming tie: {identifier}')
span_ids = set()
event_order = {identifier: index for index, identifier in enumerate(events)}
for span in staves[0].get('tuplets', []):
if not span['id'] or span['id'] in span_ids or span['start'] not in ids or span['end'] not in ids or not 0 < span['note_count'] <= 1000000 or not 0 < span['space_count'] <= 1000000 or not 0 <= span['depth'] <= 16:
raise ValueError('invalid tuplet span')
members = [n['id'] for n in events.values() if span['id'] in n.get('tuplet_ids', [])]
if not members or members[0] != span['start'] or members[-1] != span['end'] or event_order[span['start']] > event_order[span['end']]:
raise ValueError('tuplet endpoints disagree with member events')
if len({ownership[n] for n in members}) != 1 or span.get('voice', ownership[members[0]]) != ownership[members[0]]:
raise ValueError('tuplet crosses independent voice lanes')
if span.get('bracket', 'auto') not in ('yes', 'no', 'auto') or span.get('show_number', 'actual') not in ('none', 'actual', 'both'):
raise ValueError('invalid tuplet appearance')
span_ids.add(span['id'])
for note in events.values():
for verse in note.get('lyrics', []):
start = tones[note['pitches'][0]['id']][1] if note['pitches'] else fractions.Fraction()
if 'extend_to' in verse and not start < fraction(verse['extend_to']) <= absolute:
raise ValueError('lyric extension endpoint is outside the score')
if any(t not in span_ids for t in note.get('tuplet_ids', [])):
raise ValueError('event refers to an unknown tuplet')
if tremolo := note.get('tremolo'):
if tremolo['type'] not in ('single', 'start', 'stop') or type(tremolo['marks']) is not int or not 0 <= tremolo['marks'] <= 8:
raise ValueError('invalid measured tremolo')
if tremolo['type'] in ('start', 'stop'):
other = events.get(tremolo.get('partner'))
expected_type = 'stop' if tremolo['type'] == 'start' else 'start'
if not other or other.get('tremolo', {}).get('partner') != note['id'] or other['tremolo']['type'] != expected_type or other['tremolo']['marks'] != tremolo['marks']:
raise ValueError('invalid paired tremolo')
for span in staves[0].get('octave_shifts', []):
if not 0 <= fraction(span['start']) < fraction(span['end']) <= absolute or not -3 <= span['octaves'] <= 3:
raise ValueError('invalid octave-shift span')
previous_end = fractions.Fraction()
for span in staves[0].get('scale_spans', []):
start, end = fraction(span['start']), fraction(span['end'])
if not previous_end <= start < end <= absolute or not isinstance(span.get('label'), str) or not span['label'].strip() or type(span.get('matched')) is not bool:
raise ValueError('invalid solo scale span')
if not isinstance(span.get('id'), str) or not span['id'] or span['id'] in ids:
raise ValueError('solo scale spans require unique IDs')
ids.add(span['id'])
previous_end = end
+2 -1
View File
@@ -8,6 +8,7 @@ import defusedxml.ElementTree
import generator.harmony
import generator.model
import generator.validation
class MusicXMLError(ValueError):
pass
@@ -621,7 +622,7 @@ class Importer:
metadata.update({'key_signature': measures[0]['key_signature'], 'time_signature': measures[0]['time_signature'], 'key': copy.deepcopy(measures[0]['key'])})
result = {'metadata': metadata, 'staves': [{'id': 'staff_source', 'name': definitions[0].findtext('part-name', 'Source'), 'role': 'vocal', 'clef': copy.deepcopy(measures[0]['clef']), 'tuplets': self.tuplets, 'octave_shifts': self.octaves, 'measures': measures}]}
result['staves'][0]['instruments'] = instruments
generator.model.validate_document(result)
generator.validation.validate_document(result)
return result
def load_musicxml(path: pathlib.Path) -> dict:
+2 -1
View File
@@ -7,6 +7,7 @@ import xml.etree.ElementTree
import generator.harmony
import generator.model
import generator.validation
def element(parent, tag, content=None, **attributes):
node = xml.etree.ElementTree.SubElement(parent, tag, {k.replace('_', '-'): str(v) for k, v in attributes.items() if v is not None})
@@ -209,7 +210,7 @@ def write_barline(bar, measure, location):
element(node, 'bar-style', measure.get('barlines', {}).get(location, 'regular'))
def musicxml_tree(document: dict, *, tablature=False) -> xml.etree.ElementTree.ElementTree:
generator.model.validate_document(document)
generator.validation.validate_document(document)
root = xml.etree.ElementTree.Element('score-partwise', {'version': '4.0'})
metadata, staff = document['metadata'], document['staves'][0]
element(element(root, 'work'), 'work-title', metadata['title'])
-1
View File
@@ -3,7 +3,6 @@ from __future__ import annotations
import fractions
import pathlib
import generator.accompaniment
import generator.fretboard
import generator.model
import generator.pitch
+67 -64
View File
@@ -1,13 +1,8 @@
"""Page timing and supplied recordings. No note synthesis or audio transformation."""
"""Pure page coverage and performance timing."""
from __future__ import annotations
import fractions
import hashlib
import json
import pathlib
import re
import shutil
import wave
import math
import generator.model
@@ -23,7 +18,63 @@ def page_timing(document, page):
times = boundaries(document)
start, end = page.systems[0].start, page.systems[-1].end
first, last = times.index(start), times.index(end)
return dict(first_measure=first + 1, measure_count=last - first, start_beat=generator.model.rational(start), end_beat=generator.model.rational(end))
measures = document['staves'][0]['measures']
systems = []
for system in page.systems:
a, b = times.index(system.start), times.index(system.end)
labels = {p.sources[0]: p for p in system.primitives if p.role == 'measure_number'}
boxes = []
for i in range(a, b):
box = labels[measures[i]['id']].box
boxes.append(dict(measure=i + 1, bounds=[box.left, box.top, box.right, box.bottom]))
systems.append(dict(first_measure=a + 1, measure_count=b - a, start_beat=generator.model.rational(system.start), end_beat=generator.model.rational(system.end), labels=boxes))
return dict(first_measure=first + 1, measure_count=last - first, start_beat=generator.model.rational(start), end_beat=generator.model.rational(end), systems=systems)
def validate_views(document, pages, playback_pages):
validate_pages(document, pages)
times = boundaries(document)
canonical = []
def system_range(system):
a, count = system['first_measure'], system['measure_count']
if type(a) is not int or type(count) is not int or a < 1 or count < 1 or a + count > len(times):
raise ValueError('invalid system measure coverage')
if generator.model.fraction(system['start_beat']) != times[a - 1] or generator.model.fraction(system['end_beat']) != times[a + count - 1]:
raise ValueError('invalid system timing')
if [label['measure'] for label in system['labels']] != list(range(a, a + count)):
raise ValueError('invalid measure label coverage')
for label in system['labels']:
box = label['bounds']
if not isinstance(box, list) or len(box) != 4 or any(type(v) not in (int, float) or not math.isfinite(v) for v in box) or not (4 <= box[0] < box[2] <= 972 and 4 <= box[1] < box[3] <= 480):
raise ValueError('invalid measure label bounds')
return a, count
for page in pages:
systems = page.get('systems', [])
if len(systems) != 2 and (page is not pages[-1] or len(systems) != 1):
raise ValueError('invalid page systems')
cursor = page['first_measure']
for system in systems:
a, count = system_range(system)
if a != cursor:
raise ValueError('system gap or overlap')
cursor += count
canonical.append(system)
if cursor != page['first_measure'] + page['measure_count']:
raise ValueError('systems disagree with page coverage')
if not isinstance(playback_pages, list) or len(playback_pages) != len(canonical):
raise ValueError('missing playback pages; regenerate score assets')
for i, page in enumerate(playback_pages):
expected = canonical[i:i + 2]
systems = page.get('systems', [])
if len(systems) != len(expected):
raise ValueError('invalid playback systems')
for actual, source in zip(systems, expected):
system_range(actual)
if any(actual[k] != source[k] for k in ('first_measure', 'measure_count', 'start_beat', 'end_beat')):
raise ValueError('playback changes system boundaries')
if any(page[k] != expected[0][k] for k in ('first_measure', 'start_beat')) or page['end_beat'] != expected[-1]['end_beat'] or page['measure_count'] != sum(s['measure_count'] for s in expected):
raise ValueError('invalid playback page timing')
def validate_pages(document, pages):
times = boundaries(document)
@@ -43,9 +94,15 @@ def validate_pages(document, pages):
def timing(document):
times = boundaries(document)
measures = document['staves'][0]['measures']
# Metronome accents follow each actual measure, including meter changes.
ending = [i for i, m in enumerate(measures) if m.get('ending_sustain')]
if ending and ending != list(range(ending[0], len(measures))):
raise ValueError('held ending must be a contiguous terminal section')
sustain_start = times[ending[0]] if ending else times[-1]
# The written held ending participates in page time, not metronome time.
clicks = []
for start, measure in zip(times, measures):
if start >= sustain_start:
break
duration = generator.model.fraction(measure['duration'])
beat = fractions.Fraction()
while beat < duration:
@@ -53,58 +110,4 @@ def timing(document):
beat += 1
return dict(song_id=document['metadata'].get('song_id', ''),
duration=generator.model.rational(times[-1]),
count_in_beats=4, clicks=clicks)
def describe_wav(path, root, *, song_id='', bpm=0):
if path.is_symlink() or not path.is_file() or not path.resolve().is_relative_to(root.resolve()):
raise ValueError(f'{path}: expected a contained regular WAV')
try:
with wave.open(str(path), 'rb') as audio:
channels, rate, frames = audio.getnchannels(), audio.getframerate(), audio.getnframes()
if audio.getcomptype() != 'NONE' or audio.getsampwidth() != 2 or channels not in (1, 2) or not 8000 <= rate <= 192000 or frames <= 0:
raise ValueError('expected nonempty mono/stereo PCM16 WAV')
remaining = frames
while remaining:
count = min(remaining, 65536)
if len(audio.readframes(count)) != count * channels * 2:
raise ValueError('truncated WAV data')
remaining -= count
except (wave.Error, EOFError) as error:
raise ValueError(f'{path}: invalid WAV: {error}') from error
with path.open('rb') as source:
digest = hashlib.file_digest(source, 'sha256').hexdigest()
return dict(path=path.relative_to(root).as_posix(), sha256=digest, channels=channels, sample_rate=rate, frames=frames, song_id=song_id, bpm=bpm)
def copy_audio(static, destination, song_ids):
entries = []
inputs = [(static / 'sounds' / name, '', 0) for name in ('beat1.wav', 'beat2.wav')]
for path in sorted((static / 'backing').glob('*.wav')):
match = re.fullmatch(r'([a-z0-9]+(?:_[a-z0-9]+)*)_(60|70|80|90|100|110|120)\.wav', path.name)
if not match:
raise ValueError(f'{path}: unsupported backing filename or tempo')
if match[1] not in song_ids:
continue
inputs.append((path, match[1], int(match[2])))
for source, song_id, bpm in inputs:
description = describe_wav(source, static, song_id=song_id, bpm=bpm)
target = destination / description['path']
target.parent.mkdir(parents=True, exist_ok=True)
shutil.copyfile(source, target)
entries.append(description)
return entries
def validate_recording_lengths(root, entries):
durations = {}
for path in sorted((root / 'songs').glob('*.json')):
document = json.loads(path.read_text())
performance = timing(document)
song_id = performance['song_id']
duration = generator.model.fraction(performance['duration']) + performance['count_in_beats']
if song_id in durations and durations[song_id] != duration:
raise ValueError(f'{song_id}: parts disagree about performance duration')
durations[song_id] = duration
for entry in entries:
if entry['song_id']:
seconds = fractions.Fraction(entry['frames'], entry['sample_rate'])
if seconds < durations[entry['song_id']] * 60 / entry['bpm']:
raise ValueError(f"{entry['path']}: backing recording is shorter than count-in and score")
sustain_start=generator.model.rational(sustain_start), count_in_beats=4, clicks=clicks)
+1 -1
View File
@@ -20,7 +20,7 @@ TITLE_HEADER = struct.pack('<4sHH', b'VPTI', TITLE_WIDTH, TITLE_HEIGHT)
TITLE_BYTES = len(TITLE_HEADER) + TITLE_WIDTH * TITLE_HEIGHT // 2
MAX_TITLES = 8192
LABELS = ('VAMP', 'CONNECTING', 'OFFLINE', 'BUSY', 'READY', 'LOADING', 'WIFI', 'ERROR', 'PAGE', 'Acoustic', 'Electric', 'Vocal', 'UNAVAILABLE',
'Main Menu', 'Performance', 'Settings', 'Backing', 'Metronome', 'Tempo', 'Back', 'On', 'Off', 'BPM', 'Manual', 'Preparing', 'Count-in', 'Playing', 'Sustain', 'Hold to exit')
'Main Menu', 'Performance', 'Settings', 'Backing', 'Metronome', 'Solos', 'Tempo', 'Back', 'On', 'Off', 'BPM', 'Manual', 'Preparing', 'Count-in', 'Playing', 'Sustain', 'Hold to exit')
SPRITES = LABELS + tuple('0123456789/')
DIGIT_WIDTH = 22
DEFAULT_FONT_ROOT = pathlib.Path(__file__).resolve().parents[1] / 'package/assets/fonts/petaluma'
+180
View File
@@ -0,0 +1,180 @@
"""Build-only Letter PDFs from the complete arranged parts, never screen PNGs."""
from __future__ import annotations
import dataclasses
import hashlib
import json
import math
import pathlib
import shutil
import time
import PIL.PdfParser
import generator.engraving.audit
import generator.engraving.cache
import generator.engraving.fonts
import generator.engraving.layout
import generator.engraving.notation
import generator.engraving.raster
import generator.engraving.types
import generator.validation
# Two layout units per PDF point: guitar staff spacing is five points.
# Raster resolution is independent of layout and the device's display theme.
STYLE = generator.engraving.types.Style(width=1224, height=1584, margin_x=72, margin_y=72, page_clearance=28, system_gap=32, supersampling=1)
DPI = 300
PIXELS = (2550, 3300)
MEDIA_BOX = [0, 0, 612, 792]
VERSION = 'letter-parts-v1'
def layout_part(document, fonts):
generator.validation.validate_document(document)
style = dataclasses.replace(generator.engraving.types.score_style(document, STYLE), system_gap=STYLE.system_gap)
# Measure numbers are centered over barlines and can extend left of the
# staff. Reserve their actual overhang inside the half-inch paper margin.
overhang = max(-fonts.text(str(m['number']), 0, 0, 12, 'measure_number', (), True).box.left for m in document['staves'][0]['measures'])
style = dataclasses.replace(style, margin_x=style.margin_x + math.ceil(max(0, overhang)) + 4)
index = generator.engraving.notation.ScoreIndex(document)
systems = generator.engraving.layout.layout_systems(document, style, fonts, index=index)
# The shared header wraps long credits; print it at twice its display size.
header_style = dataclasses.replace(style, width=style.width // 2, margin_x=style.margin_x / 2, margin_y=style.margin_y / 2)
header = tuple(p.scaled(2) for p in generator.engraving.layout.part_header(document, fonts, header_style))
top = generator.engraving.types.bounds(header).bottom + style.page_clearance
# Reserve the measured outline for every possible page number, just as
# screen pagination does. A nominal font size is not its actual ascent.
footers = tuple(fonts.text(str(number), style.width / 2, style.height - style.margin_y - 8, 20, 'page_number', (), True)
for number in range(1, len(systems) + 1))
bottom = min(p.box.top for p in footers) - style.page_clearance
pages, placed, cursor = [], [], top
def finish():
number = len(pages) + 1
pages.append(generator.engraving.types.Page(number, style.width, style.height, style.supersampling, tuple(placed),
(*header, *(p for system in placed for p in system.primitives), footers[number - 1])))
for system in systems:
system = generator.engraving.layout.make_system(index, system.start, system.end, fonts, style, justify=system.end < index.end, staff_width=style.width - 2 * style.margin_x - 2)
height = system.box.bottom - system.box.top
if height > bottom - top:
raise generator.engraving.types.EngravingError(f'at musical offset {system.start}: system cannot fit a Letter page at readable size')
if placed and cursor + height > bottom:
finish()
placed, cursor = [], top
dx, dy = style.margin_x + 1, cursor - system.box.top
placed.append(dataclasses.replace(system, primitives=tuple(p.moved(dx, dy) for p in system.primitives),
anchors=tuple(a.moved(dx, dy) for a in system.anchors), box=system.box.moved(dx, dy)))
cursor += height + style.system_gap
finish()
result = generator.engraving.types.LayoutDocument(tuple(pages), style, fonts.fingerprint(style))
generator.engraving.audit.audit_layout(document, result, fonts, systems_per_page=None)
if any(p.box.left < STYLE.margin_x or p.box.right > style.width - STYLE.margin_x or
p.box.top < STYLE.margin_y or p.box.bottom > style.height - STYLE.margin_y for page in pages for p in page.primitives):
raise generator.engraving.types.EngravingError('print notation exceeds the half-inch printer margins')
return result
def rasterize(page, fonts):
return generator.engraving.raster.rasterize_page(page, fonts, ink=(0, 0, 0), background=(255, 255, 255), output_scale=DPI / 144)
def validate_pdf(path, expected_pages=None):
"""Check the narrow PDF format written by the pinned Pillow asset dependency.
This adapter deliberately uses Pillow's parser, not a new general PDF stack.
Tests also decode the embedded page images to check print color/resolution.
"""
try:
if path.is_symlink() or not path.is_file():
raise ValueError('expected a regular print PDF')
pdf = PIL.PdfParser.PdfParser(filename=str(path))
try:
count = len(pdf.pages)
if not 0 < count <= 10000 or (expected_pages is not None and count != expected_pages):
raise ValueError('invalid print PDF page count')
for reference in pdf.pages:
page = pdf.read_indirect(reference)
if page[b'MediaBox'] != MEDIA_BOX:
raise ValueError('print PDF must use portrait US Letter')
image = pdf.read_indirect(page[b'Resources'][b'XObject'][b'image'])
if (image.dictionary[b'Width'], image.dictionary[b'Height']) != PIXELS or image.dictionary[b'ColorSpace'] != b'DeviceGray':
raise ValueError('print PDF must contain 300 DPI grayscale pages')
return count
finally:
pdf.close()
except (OSError, KeyError, TypeError, IndexError, PIL.PdfParser.PdfFormatError) as error:
raise ValueError(f'{path.name}: invalid print PDF: {error}') from error
def write_pdf(path, document, fonts):
layout = layout_part(document, fonts)
# Append one page at a time so a long arrangement never keeps a chorus of
# full-resolution raster images in memory. The enclosing build is staged.
for page in layout.pages:
with rasterize(page, fonts) as rgb, rgb.convert('L') as image:
if image.size != PIXELS or image.getextrema()[0] == 255:
raise ValueError('print renderer produced an empty or incorrectly sized page')
image.save(path, format='PDF', append=page.number > 1, resolution=DPI, quality=95,
title=document['metadata']['title'] + ' - ' + document['staves'][0].get('name', 'Part'),
creator='Product Vamp', creationDate=None, modDate=None)
validate_pdf(path, len(layout.pages))
return len(layout.pages)
def renderer_key(fonts):
identity = generator.engraving.cache.renderer_identity(fonts, STYLE)
identity.update(print_version=VERSION, print_code=hashlib.sha256(pathlib.Path(__file__).read_bytes()).hexdigest(), dpi=DPI, ink='black', background='white', quality=95)
return hashlib.sha256(json.dumps(identity, sort_keys=True).encode()).hexdigest()
def restore(entry, key, target):
try:
if generator.cache.has_symlink(entry):
return None
pdf, manifest = entry / 'part.pdf', entry / 'print.json'
if pdf.is_symlink() or manifest.is_symlink():
return None
info = json.loads(manifest.read_text())
if info['key'] != key or info['sha256'] != hashlib.sha256(pdf.read_bytes()).hexdigest():
return None
pages = validate_pdf(pdf, info['pages'])
shutil.copyfile(pdf, target)
return pages
except (OSError, ValueError, KeyError, TypeError):
return None
def store(entry, key, target, pages):
with generator.cache.stage_entry(entry, '.print_') as staged:
shutil.copyfile(target, staged / 'part.pdf')
(staged / 'print.json').write_text(json.dumps({'key': key, 'sha256': hashlib.sha256(target.read_bytes()).hexdigest(), 'pages': pages}))
generator.cache.publish_files(entry, staged, ('part.pdf', 'print.json'))
def generate_tree(root, font_path, *, cache_dir=None, progress=False):
"""Called inside the normal build's atomic staging directory."""
if cache_dir and (cache_dir.resolve().is_relative_to(root.resolve()) or root.resolve().is_relative_to(cache_dir.resolve())):
raise ValueError('print cache and generated assets must not overlap')
destination = root / 'print'
destination.mkdir(exist_ok=True)
paths = sorted((root / 'songs').glob('*.json'))
fonts = generator.engraving.fonts.Fonts(font_path)
renderer = renderer_key(fonts)
expected, pages_total, reused = set(), 0, 0
started = time.monotonic()
for path in paths:
bundle = json.loads(path.read_text())
document = bundle.get('music', bundle)
target = destination / path.with_suffix('.pdf').name
expected.add(target)
key = generator.engraving.cache.score_fingerprint(document, renderer)
entry = cache_dir / 'print' / renderer / key if cache_dir else None
pages = restore(entry, key, target) if entry else None
if pages is None:
pages = write_pdf(target, document, fonts)
if entry:
store(entry, key, target, pages)
else:
reused += 1
pages_total += pages
if progress:
print(f'Print: {target.name}: {pages} pages', flush=True)
for stale in destination.glob('*.pdf'):
if stale not in expected:
stale.unlink()
if progress:
print(f'Print complete: {len(paths)} PDFs, {pages_total} pages, {reused} cached; {time.monotonic() - started:.1f}s', flush=True)
return len(paths)
+25 -320
View File
@@ -1,323 +1,23 @@
"""Independent, reproducible role generation and non-composing assembly.
Only source documents and production resources enter generate_role. Completed
roles and published assets are downstream values, never composition inputs.
"""
"""File discovery, process scheduling and publication of independent roles."""
from __future__ import annotations
import concurrent.futures
import copy
import dataclasses
import hashlib
import functools
import json
import multiprocessing
import os
import pathlib
import tempfile
import time
import fractions
import generator.accompaniment
import generator.comping
import generator.fretboard
import generator.model
import generator.arrange.accompaniment
import generator.arrange.assembly
import generator.composition
import generator.composition_types
import generator.musicxml
import generator.parts
import generator.score
import generator.vocabulary
import generator.arrange.accompaniment
import generator.arrange.form
import generator.arrange.generate
import generator.arrange.pickup
import generator.solo.analysis
import generator.solo.composer
import generator.solo.notation
import generator.solo.report
import generator.solo.learned
import generator.solo.authored
import generator.input_audit
import generator.solo.arrangement
VERSION = 'independent-roles-1'
ROLES = ('acoustic_accompaniment', 'electric_accompaniment', 'electric_melody', 'vocal_melody', 'acoustic_solo', 'electric_solo')
@dataclasses.dataclass(frozen=True)
class SourceAnalysis:
document_json: str
musical_key: str
@classmethod
def read(cls, document):
prepared = copy.deepcopy(document)
staff = generator.score.source_staff(prepared)
for i, m in enumerate(staff['measures']):
m['id'], m['number'] = f'source_{i}', str(i + 1)
staff['tuplets'] = generator.score.reidentify(staff['measures'], staff.get('tuplets', []))
prepared['metadata'] = {k: v for k, v in prepared['metadata'].items() if k not in ('title', 'composer', 'copyright', 'software')}
prepared['metadata'].update(title='Source', composer='')
staff.update(id='source', name='Source')
melodic = generator.solo.analysis.analyze(prepared)
content = {'melody': [(str(n.start), str(n.end), dataclasses.asdict(n.pitch)) for n in melodic.melody],
'measures': [{k: m.get(k) for k in ('duration', 'time_signature', 'key', 'harmonies', 'tempos', 'section_label', 'implicit')} for m in staff['measures']]}
# Fraction/string spelling is canonical and never includes filesystem IDs.
key = hashlib.sha256(json.dumps(content, sort_keys=True, default=str).encode()).hexdigest()
return cls(json.dumps(prepared, sort_keys=True), key)
def document(self):
return json.loads(self.document_json)
def accompaniment_key(self):
document = self.document()
document['metadata'].pop('tempo', None)
for measure in generator.score.source_staff(document)['measures']:
measure['tempos'] = []
return SourceAnalysis.read(document).musical_key
def windows(document, part):
source = generator.score.source_staff(document)['measures']
sections = generator.arrange.form.full_arrangement_sections(source, part)
result, cursor = [], fractions.Fraction()
for section in sections:
duration = sum((generator.model.fraction(m['duration']) for m in source[section.source_measure_index:section.source_measure_index + section.measure_count]), fractions.Fraction())
role = {'slash': 'solo', 'vocal': 'melody'}.get(section.role, section.role)
if section.role in ('vocal', 'melody') and generator.arrange.pickup.enters(section, source) and result:
attacks = [generator.model.fraction(n['onset']) for n in generator.score.measure_notes(source[0]) if n['pitches']]
if attacks:
start = cursor - generator.model.fraction(source[0]['duration']) + min(attacks)
a, _, old = result[-1]
result[-1] = (a, start, old)
result.append((start, cursor, part + '_' + role))
end = cursor + duration
start = cursor
if section.role == 'slash' and generator.score.body_start_measure_index(source) and result:
# Allocate the source's complete pickup bar before composition. This
# does not inspect either generated solo; a role may leave it silent.
start = cursor - generator.model.fraction(source[0]['duration'])
a, _, old = result[-1]
result[-1] = (a, start, old)
result.append((start, end, part + '_' + role))
cursor = end
return tuple(result)
def dependencies(role, resources):
names = ['harmony', 'lead_ins'] if role.endswith('_solo') else ['accompaniment'] if role.endswith('_accompaniment') else []
return {'roles': {'role': resources['roles']['roles'][role], 'difficulty': resources['roles']['difficulty']},
**{name: resources[name] for name in names}}
def _code_key(role):
root = pathlib.Path(__file__).parent
paths = [root / n for n in ('production.py', 'model.py', 'harmony.py', 'pitch.py', 'fretboard.py', 'parts.py', 'score.py', 'vocabulary.py')]
paths += list((root / 'arrange').glob('*.py'))
if role.endswith('_solo'):
paths += list((root / 'solo').glob('*.py'))
paths += [root / 'harmonic_time.py', root / 'musicxml.py', root / 'training_io.py']
elif role.endswith('_accompaniment'):
paths += [root / n for n in ('comping.py', 'comping_rhythm.py', 'accompaniment.py', 'guitar.py')]
if role == 'acoustic_accompaniment':
paths += [root / 'acoustic_voicing.py', root / 'acoustic.py']
elif role == 'electric_melody':
paths += [root / 'guitar.py', root / 'melody.py']
return generator.vocabulary.fingerprint([(p.relative_to(root).as_posix(), hashlib.sha256(p.read_bytes()).hexdigest()) for p in sorted(set(paths))])
def _resource_key(directory, role):
return {'model': hashlib.sha256((directory / 'models' / 'solo.json').read_bytes()).hexdigest()} if role.endswith('_solo') else {}
@functools.lru_cache(maxsize=4)
def _solo_model(directory, fingerprint):
return generator.solo.learned.Model.load(pathlib.Path(directory) / 'models' / 'solo.json')
def _mask(document, allowed):
"""Apply source-defined role exclusions, without observing another part."""
absolute = fractions.Fraction()
for measure in document['staves'][0]['measures']:
length = generator.model.fraction(measure['duration'])
for voice in measure['voices']:
selected = []
for n in voice['notes']:
start = absolute + generator.model.fraction(n['onset'])
end = start + generator.model.fraction(n['duration'])
intervals = [(max(start, a), min(end, b)) for a, b in allowed if a < end and b > start]
for a, b in intervals:
note = copy.deepcopy(n)
if a != start:
note['onset'] = generator.model.rational(a - absolute)
for pitch in note['pitches']:
pitch.pop('tie_from', None)
generator.arrange.pickup.truncate(note, b - absolute)
if a < b:
selected.append(note)
voice['notes'] = _fill(selected, length, measure['id'] + '_' + voice['id'], voice['id'])
absolute += length
staff = document['staves'][0]
staff['tuplets'] = generator.arrange.pickup.retain_links(staff['measures'], staff.get('tuplets', []))
def _fill(notes, length, prefix, voice='voice_arranged'):
notes = sorted(notes, key=lambda n: generator.model.fraction(n['onset']))
result = []
cursor = fractions.Fraction()
def rests(end):
nonlocal cursor
for duration, written in generator.accompaniment.written_durations(end - cursor):
result.append(generator.model.make_event(prefix + '_rest_' + str(len(result)), cursor, duration, 'rest', written=written) | {'voice': voice})
cursor += duration
for n in notes:
start = generator.model.fraction(n['onset'])
if start < cursor:
raise ValueError(prefix + ': overlapping independently generated roles')
rests(start)
n['voice'] = voice
result.append(n)
cursor = start + generator.model.fraction(n['duration'])
rests(length)
return result
def generate_role(source, role, data_dir, settings=None, cache_dir=None):
started = time.monotonic()
with generator.input_audit.composition(data_dir, role, cache_dir) as reads:
result = _generate_role(source, role, data_dir, settings, cache_dir)
# Observed reads are diagnostics, never cache identity or musical seeds.
result['trace'] = {**result['trace'], 'input_boundary': 'production data (including explicit authored repertoire), generator code, Python runtime, own role cache'}
result['observed_reads'] = sorted(reads)
result['seconds'] = time.monotonic() - started
return result
def _generate_role(source, role, data_dir, settings=None, cache_dir=None):
if role not in ROLES:
raise ValueError('Unknown generation role: ' + role)
data_dir = pathlib.Path(data_dir)
resources = generator.vocabulary.load(data_dir / 'composition')
settings = settings or {}
registered = generator.solo.authored.lookup(source, role.removesuffix('_solo'), data_dir) if role.endswith('_solo') and not settings.get('predict', False) else None
algorithm = VERSION + '/' + generator.solo.learned.VERSION if role.endswith('_solo') else VERSION
inputs = {'version': algorithm, 'source': source.musical_key, 'role': role, 'settings': settings,
'vocabulary': dependencies(role, resources), 'catalogs': ({'authored': registered['sha256'], 'id': registered['id'], 'pitch_convention': registered['pitch_convention']} if registered else _resource_key(data_dir, role)), 'code': _code_key(role)}
# Source notation/lyrics also invalidate cached score representation, never the musical seed.
key = generator.vocabulary.fingerprint({'inputs': inputs, 'notation': source.document_json})
path = pathlib.Path(cache_dir) / role / (key + '.json') if cache_dir else None
if path and path.is_file() and not path.is_symlink():
try:
entry = json.loads(path.read_text())
value = entry['result']
if entry['key'] == key and entry['digest'] == generator.vocabulary.fingerprint(value):
generator.model.validate_document(value['document'])
generator.fretboard.validate_document(value['document'])
return {**value, 'cache_hit': True}
except (ValueError, KeyError, TypeError):
pass
started = time.monotonic()
document = source.document()
part = role.split('_')[0]
trace = {'source': source.musical_key, 'role': role, 'production_resources': inputs['catalogs'],
'vocabulary': generator.vocabulary.fingerprint(inputs['vocabulary']), 'settings': settings, 'algorithm': algorithm, 'code': inputs['code'], 'cache_key': key}
choice_source = source.accompaniment_key() if role.endswith('_accompaniment') else source.musical_key
seed = generator.vocabulary.fingerprint({'source': choice_source, 'role': role, 'settings': settings, 'data': inputs['vocabulary'], 'version': algorithm})
details = {}
solo_report = ''
composition_timings = {}
with generator.vocabulary.using(resources, role, settings | {'choice_seed': seed}):
if role.endswith('_solo'):
result = generator.arrange.generate._arrange_document(document, part, {}, owned={'slash'})
si = 3 if part == 'acoustic' else 4
first, count, offset, length = generator.solo.arrangement.regions(document)[si]
# The template/harmony comes directly from source form, not another generated part.
authored = generator.score.source_staff(document)['measures']
section = generator.arrange.form.full_arrangement_sections(authored, part)[si]
effective = generator.arrange.generate.section_source(authored, section, generator.arrange.form.full_arrangement_sections(authored, part)[si + 1])
template = copy.deepcopy(effective[section.source_measure_index:section.source_measure_index + count])
initial = generator.accompaniment.carried_chords(effective)[section.source_measure_index]
start, end = next((a - offset, b - offset) for a, b, r in windows(document, part) if r == role)
notation_first = first
if start < 0:
# The preceding arrangement harmony comes from the source form. Do
# not invent harmony from a comparison score's unlabelled lead-in.
template.insert(0, copy.deepcopy(result['staves'][0]['measures'][first - 1]))
notation_first -= 1
initial = generator.accompaniment.carried_chords(result['staves'][0]['measures'])[first - 1]
if registered:
solo = generator.solo.authored.realize(registered, generator.solo.analysis.analyze(document), template, part, start, end, initial)
else:
solo_model = _solo_model(str(data_dir), inputs['catalogs']['model'])
solo = generator.solo.composer.compose(generator.solo.analysis.analyze(document), template, part, end, initial=initial, learned_model=solo_model, expressions_enabled=generator.vocabulary.role().get('expressions', True), start=start)
composition_timings = {k: v for k, v in solo.diagnostics.items() if k.endswith('_seconds')}
relative = tuple(dataclasses.replace(n, start=n.start - start, end=n.end - start) for n in solo.notes())
output = generator.solo.notation.measures(result['staves'][0]['measures'][notation_first:first + count], relative, 'solo_' + part)
generator.solo.notation.replace_region(result, notation_first, output)
details = generator.solo.report.structure(solo)
details['allocation'] = {'start': str(start), 'end': str(end), 'lead_in_measures': first - notation_first}
solo_report = generator.solo.report.describe(solo, first, offset, detail=details)
elif role.endswith('_accompaniment'):
canonical = generator.comping.Canonical(document, part, seed)
result = generator.arrange.generate._arrange_document(document, part, {}, owned={'accompaniment'}, accompaniment=canonical)
details = {'canonical_comping': canonical.report, 'accompaniment_rhythm': canonical.rhythm_report, 'rhythm_source': choice_source}
else:
result = generator.arrange.generate._arrange_document(document, part, {}, owned={'vocal' if part == 'vocal' else 'melody'})
allowed = tuple((a, b) for a, b, r in windows(document, part) if r == role)
_mask(result, allowed)
staff = result['staves'][0]
for measure in staff['measures']:
measure['id'] = role + '_' + measure['id']
staff['tuplets'] = generator.score.reidentify(staff['measures'], staff.get('tuplets', []))
if part != 'vocal':
result['staves'][0]['tablature'] = True
generator.model.validate_document(result)
generator.fretboard.validate_document(result)
value = {'role': role, 'document': result, 'trace': trace, 'details': details, 'report': solo_report, 'seconds': time.monotonic() - started, 'composition_timings': composition_timings, 'cache_hit': False}
# Sidecar diagnostics use the same rational-safe representation as reports.
# Identical insertion order after cold generation and cache loading also
# keeps serialized scores and the catalog byte-for-byte reproducible.
value = json.loads(json.dumps(value, default=str, sort_keys=True))
if path:
path.parent.mkdir(parents=True, exist_ok=True)
payload = {'key': key, 'digest': generator.vocabulary.fingerprint(value), 'result': value}
with tempfile.NamedTemporaryFile('w', dir=path.parent, delete=False) as out:
json.dump(payload, out, sort_keys=True)
temporary = out.name
os.replace(temporary, path)
return value
def assemble(source, results):
"""Union prevalidated role windows; no selection or pitch/fingering rewrite."""
documents = {}
for part in generator.parts.PART_TYPES:
selected = [results[r]['document'] for r in ROLES if r.startswith(part + '_')]
document = copy.deepcopy(selected[0])
staff = document['staves'][0]
if part == 'vocal':
documents[part] = document
continue
staff['tuplets'] = []
staff['octave_shifts'] = []
staff['scale_spans'] = []
for other in selected:
for field in ('tuplets', 'octave_shifts', 'scale_spans'):
staff[field].extend(copy.deepcopy(other['staves'][0].get(field, [])))
for i, m in enumerate(staff['measures']):
# Tuplet rests belong to the source/role rhythm and must survive union.
lanes = {}
for d in selected:
for voice in d['staves'][0]['measures'][i]['voices']:
lane = voice['id'] if part == 'acoustic' and voice['id'] in ('upper', 'bass') else 'voice_arranged'
sounding = [copy.deepcopy(n) for n in voice['notes'] if n['pitches'] or n.get('tuplet_ids')]
if sounding:
lanes.setdefault(lane, []).extend(sounding)
lanes = lanes or {'voice_arranged': []}
m['voices'] = [{'id': lane, 'notes': _fill(notes, generator.model.fraction(m['duration']), m['id'] + '_' + lane, lane)} for lane, notes in lanes.items()]
# Attribute changes belong to source melody pickups and are assembly metadata.
for d in selected:
other = d['staves'][0]['measures'][i]
if other.get('attributes'):
m['attributes'] = copy.deepcopy(other['attributes'])
staff['tuplets'] = generator.arrange.pickup.retain_links(staff['measures'], staff['tuplets'])
owners = {n['id']: v['id'] for m in staff['measures'] for v in m['voices'] for n in v['notes']}
for span in staff['tuplets']:
span['voice'] = owners[span['start']]
generator.model.validate_document(document)
generator.fretboard.validate_document(document)
documents[part] = document
return documents
import generator.score_io
import generator.source
def _job(request):
source, role, directory, settings, cache = request
return generate_role(source, role, directory, settings, cache)
return generator.composition.generate_role(request.source, request.role, request.directory, json.loads(request.settings_json), request.cache)
def generate_tree(source_dir, output_dir, *, jobs=2, cache_dir=None, progress=False, timings=None):
if type(jobs) is not int or not 1 <= jobs <= 16:
@@ -326,8 +26,8 @@ def generate_tree(source_dir, output_dir, *, jobs=2, cache_dir=None, progress=Fa
sources = {}
for path in generator.parts.source_paths(source_dir):
document = generator.parts.prepare_document(generator.musicxml.load_musicxml(path))
sources[path] = (document, SourceAnalysis.read(document))
requests = [(path, role, (s, role, source_dir.parent, {}, cache_dir)) for path, (_, s) in sources.items() for role in ROLES]
sources[path] = (document, generator.source.SourceAnalysis.read(document))
requests = [(path, role, generator.composition_types.RoleRequest(s, role, source_dir.parent, cache=cache_dir)) for path, (_, s) in sources.items() for role in generator.composition_types.ROLES]
results = {p: {} for p in sources}
def accept(path, role, value):
@@ -353,18 +53,23 @@ def generate_tree(source_dir, output_dir, *, jobs=2, cache_dir=None, progress=Fa
except Exception as error:
raise ValueError(f'{path.name}/{role}: {error}') from error
for path, (original, source) in sources.items():
assembled = assemble(source, results[path])
reuse = generator.arrange.accompaniment.audit(original, assembled)
for part, document in assembled.items():
document['metadata'] = copy.deepcopy(original['metadata'])
document['metadata']['song_id'] = generator.score.slugify(path.stem)
generator.score.write_json(output_dir / (generator.score.slugify(path.stem) + '_' + part + '.json'), document)
reuse = generator.arrange.accompaniment.audit(original, {role: value['document'] for role, value in results[path].items()}, role_documents=True)
for solos_enabled in (True, False):
assembled = generator.arrange.assembly.assemble(source, results[path], solos_enabled=solos_enabled)
generator.arrange.accompaniment.audit(original, assembled)
for part, document in assembled.items():
if part == 'vocal' and not solos_enabled:
continue
document['metadata'] = copy.deepcopy(original['metadata'])
document['metadata'].update(song_id=generator.score.slugify(path.stem), solos_enabled=solos_enabled)
suffix = '' if solos_enabled else '_improv'
generator.score_io.write_json(output_dir / (generator.score.slugify(path.stem) + '_' + part + suffix + '.json'), document)
analysis_dir = output_dir.parent / 'analysis'
analysis_dir.mkdir(parents=True, exist_ok=True)
(analysis_dir / (generator.score.slugify(path.stem) + '.txt')).write_text('\n'.join(results[path][r]['report'] for r in ROLES))
(analysis_dir / (generator.score.slugify(path.stem) + '.txt')).write_text('\n'.join(results[path][r]['report'] for r in generator.composition_types.ROLES))
# Not a score file: diagnostics are deliberately outside the songs schema.
stable = {role: {k: v for k, v in value.items() if k not in ('seconds', 'composition_timings', 'cache_hit', 'observed_reads')} for role, value in results[path].items()}
for part, audit in reuse.items():
stable[part + '_accompaniment']['details']['reuse_audit'] = audit
for role, audit in reuse.items():
stable[role]['details']['reuse_audit'] = audit
(analysis_dir / (generator.score.slugify(path.stem) + '.roles')).write_text(json.dumps(stable, sort_keys=True, indent=2))
return len(sources) * 3
return len(sources) * 5
+29
View File
@@ -0,0 +1,29 @@
"""Role cache persistence; cache identity never supplies musical randomness."""
import json
import generator.cache
import generator.fretboard
import generator.validation
ENTRYPOINTS = ('generator.composition',)
def code_key():
return generator.cache.fingerprint(generator.cache.source_identity(ENTRYPOINTS))
def restore(path, key):
if path is None or not path.is_file() or path.is_symlink():
return None
try:
entry = json.loads(path.read_text())
value = entry['result']
if entry['key'] == key and entry['digest'] == generator.cache.fingerprint(value):
generator.validation.validate_document(value['document'])
generator.fretboard.validate_document(value['document'])
return {**value, 'cache_hit': True}
except (OSError, ValueError, KeyError, TypeError):
pass
return None
def store(path, key, value):
if path is not None:
generator.cache.write_json(path, {'key': key, 'digest': generator.cache.fingerprint(value), 'result': value})
+1 -58
View File
@@ -1,53 +1,8 @@
"""Pure score navigation, cloning and identity operations."""
from __future__ import annotations
import copy
import json
import pathlib
import re
import generator.engraving.validation
import generator.fretboard
import generator.model
import generator.pico_artwork
import generator.performance
def load_json(path: pathlib.Path) -> dict:
document = json.loads(path.read_text(encoding='utf-8'))
return validate_json(document, path)
def validate_json(document: dict, path: pathlib.Path, validated_pages: set[str] | None = None) -> dict:
if not isinstance(document, dict):
raise ValueError('expected a score object')
if 'music' in document:
presentation = document.get('presentation', {})
if not isinstance(document['music'], dict) or not isinstance(presentation, dict) or not isinstance(presentation.get('pages'), list) or not presentation['pages']:
raise ValueError('invalid score bundle; regenerate score assets')
if (presentation.get('engine'), presentation.get('width'), presentation.get('height')) != (generator.engraving.validation.ENGINE_NAME, generator.engraving.validation.PAGE_WIDTH, generator.engraving.validation.PAGE_HEIGHT):
raise ValueError('unsupported score presentation; regenerate score assets')
generator.performance.validate_pages(document['music'], presentation['pages'])
if document.get('performance') != generator.performance.timing(document['music']):
raise ValueError('invalid performance timing')
for page in presentation['pages']:
if not isinstance(page, dict) or not isinstance(page.get('path'), str) or not isinstance(page.get('sha256'), str):
raise ValueError('invalid score page manifest')
name = page['path']
relative = pathlib.Path(name)
if '\x00' in name or '\\' in name or relative.is_absolute() or any(part in ('', '.', '..') for part in name.split('/')) or relative.suffix != '.png':
raise ValueError('invalid score page path')
resolved = (path.parent / relative).resolve()
if not resolved.is_relative_to(path.parent.resolve()):
raise ValueError('score page escapes its asset directory')
generator.engraving.validation.check_page(resolved, validated_pages, expected_sha256=page['sha256'])
document = document['music']
generator.model.validate_document(document)
return document
def write_json(path: pathlib.Path, document: dict) -> None:
generator.model.validate_document(document)
generator.fretboard.validate_document(document)
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text(json.dumps(document, indent=2, ensure_ascii=False) + '\n', encoding='utf-8')
def slugify(value: str) -> str:
return re.sub(r'[^a-z0-9]+', '_', value.strip().lower()).strip('_') or 'score'
@@ -124,15 +79,3 @@ def reidentify(measures: list[dict], source_tuplets: list[dict]) -> list[dict]:
def make_arranged_document(source_document: dict, staff: dict, *, staff_id: str, staff_name: str, role: str, arrangement_part_type: str, measures: list[dict], tuplets=None, octave_shifts=None) -> dict:
return {'metadata': copy.deepcopy(source_document['metadata']), 'staves': [{'id': staff_id, 'name': staff_name, 'clef': copy.deepcopy(staff['clef']), 'role': role, 'arranged': True, 'arrangement_part_type': arrangement_part_type, 'measures': measures, 'tuplets': tuplets or [], 'octave_shifts': copy.deepcopy(octave_shifts or []), 'instruments': copy.deepcopy(staff.get('instruments', []))}]}
def count_json_files(root: pathlib.Path) -> int:
return sum(1 for p in root.rglob('*.json') if p.is_file())
def validate_generated_tree(root: pathlib.Path, validated_pages: set[str] | None = None) -> None:
validated_pages = set() if validated_pages is None else validated_pages
for path in root.rglob('*.json'):
document = json.loads(path.read_text(encoding='utf-8'))
music = validate_json(document, path, validated_pages)
generator.fretboard.validate_document(music)
if 'presentation' in document:
generator.pico_artwork.validate_title(root, document['presentation'].get('title_image'))
+59
View File
@@ -0,0 +1,59 @@
from __future__ import annotations
import json
import pathlib
import generator.engraving.validation
import generator.fretboard
import generator.performance
import generator.pico_artwork
import generator.validation
def load_json(path: pathlib.Path) -> dict:
document = json.loads(path.read_text(encoding='utf-8'))
return validate_json(document, path)
def validate_json(document: dict, path: pathlib.Path, validated_pages: set[str] | None = None) -> dict:
if not isinstance(document, dict):
raise ValueError('expected a score object')
if 'music' in document:
presentation = document.get('presentation', {})
if not isinstance(document['music'], dict) or not isinstance(presentation, dict) or not isinstance(presentation.get('pages'), list) or not presentation['pages']:
raise ValueError('invalid score bundle; regenerate score assets')
if (presentation.get('engine'), presentation.get('width'), presentation.get('height')) != (generator.engraving.validation.ENGINE_NAME, generator.engraving.validation.PAGE_WIDTH, generator.engraving.validation.PAGE_HEIGHT):
raise ValueError('unsupported score presentation; regenerate score assets')
generator.performance.validate_views(document['music'], presentation['pages'], presentation.get('playback_pages'))
if document.get('performance') != generator.performance.timing(document['music']):
raise ValueError('invalid performance timing')
for page in presentation['pages'] + presentation['playback_pages']:
if not isinstance(page, dict) or not isinstance(page.get('path'), str) or not isinstance(page.get('sha256'), str):
raise ValueError('invalid score page manifest')
name = page['path']
relative = pathlib.Path(name)
if '\x00' in name or '\\' in name or relative.is_absolute() or any(part in ('', '.', '..') for part in name.split('/')) or relative.suffix != '.png':
raise ValueError('invalid score page path')
resolved = (path.parent / relative).resolve()
if not resolved.is_relative_to(path.parent.resolve()):
raise ValueError('score page escapes its asset directory')
generator.engraving.validation.check_page(resolved, validated_pages, expected_sha256=page['sha256'])
document = document['music']
generator.validation.validate_document(document)
return document
def write_json(path: pathlib.Path, document: dict) -> None:
generator.validation.validate_document(document)
generator.fretboard.validate_document(document)
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text(json.dumps(document, indent=2, ensure_ascii=False) + '\n', encoding='utf-8')
def count_json_files(root: pathlib.Path) -> int:
return sum(1 for p in root.rglob('*.json') if p.is_file())
def validate_generated_tree(root: pathlib.Path, validated_pages: set[str] | None = None) -> None:
validated_pages = set() if validated_pages is None else validated_pages
for path in root.rglob('*.json'):
document = json.loads(path.read_text(encoding='utf-8'))
music = validate_json(document, path, validated_pages)
generator.fretboard.validate_document(music)
if 'presentation' in document:
generator.pico_artwork.validate_title(root, document['presentation'].get('title_image'))
+15 -12
View File
@@ -6,20 +6,21 @@ policy. Unknown song/role pairs go to the learned composer.
"""
from __future__ import annotations
import dataclasses
import fractions
import hashlib
import json
import pathlib
import fractions
import generator.harmonic_time
import generator.musicxml
import generator.parts
import generator.training_io
import generator.harmonic_time
import generator.solo.analysis
import generator.solo.types
import generator.solo.harmonic
import generator.solo.placement
import generator.solo.profiles
import generator.solo.harmonic
import generator.production
import generator.solo.types
import generator.source
import generator.training_io
import generator.vocabulary
def sounding(evidence, offset=fractions.Fraction()):
result = []
@@ -32,9 +33,10 @@ def sounding(evidence, offset=fractions.Fraction()):
result.append(generator.solo.types.Note(fractions.Fraction(event['start']) - offset, fractions.Fraction(event['end']) - offset, pitch, role='authored', event_id=f'authored_{i}'))
return tuple(result)
def validate_evidence(document, evidence):
def validate_evidence(document, evidence, *, composition=None):
"""Training uses the same source-form harmonic context as solo playback."""
h = generator.solo.harmonic.Harmony(generator.harmonic_time.solo_source(document['staves'][0]))
composition = composition or generator.vocabulary.current()
h = generator.solo.harmonic.Harmony(generator.harmonic_time.solo_source(document['staves'][0]), composition=composition)
checked = h.evaluate(sounding(evidence), complete=True)
if not checked.valid:
raise ValueError('Unsupported harmonic relationship in authored solo: ' + checked.error)
@@ -56,7 +58,7 @@ def lookup(source, role, data_dir):
if not path.is_relative_to((root / 'songs').resolve()):
raise ValueError('Registered sources must be in data/songs')
doc = generator.parts.prepare_document(generator.musicxml.load_musicxml(path))
if generator.production.SourceAnalysis.read(doc).musical_key == source.musical_key:
if generator.source.SourceAnalysis.read(doc).musical_key == source.musical_key:
target = (manifest.parent / entry['solo']).resolve()
if not target.is_relative_to(manifest.parent.resolve()):
raise ValueError('Registered solo must be inside data/training')
@@ -67,7 +69,8 @@ def lookup(source, role, data_dir):
raise ValueError('Multiple authored solos registered for the same source music and role')
return matches[0] if matches else None
def realize(entry, source_analysis, measures, part, start, end, initial=None):
def realize(entry, source_analysis, measures, part, start, end, initial=None, *, composition=None):
composition = composition or generator.vocabulary.current()
evidence = generator.training_io.read(entry['path'], part, pitch_convention=entry['pitch_convention'])
if evidence['discrepancies']:
raise ValueError(entry['id'] + ': invalid authored timing/ties: ' + str(evidence['discrepancies']))
@@ -86,7 +89,7 @@ def realize(entry, source_analysis, measures, part, start, end, initial=None):
if placed is None:
raise ValueError(entry['id'] + ': no legal complete guitar placement')
spans = tuple(dataclasses.replace(s, start=s.start + start, end=s.end + start) for s in generator.harmonic_time.read({'measures': measures}, initial=initial))
checked = generator.solo.harmonic.Harmony(spans).evaluate(placed[1], complete=True)
checked = generator.solo.harmonic.Harmony(spans, composition=composition).evaluate(placed[1], complete=True)
if not checked.valid:
raise ValueError(entry['id'] + ': ' + checked.error)
phrase = generator.solo.types.Phrase('authored', start, end, placed[1], 'authored', 'authored', 'handoff', theme=entry['id'], expressions=checked.contracts)
+17 -14
View File
@@ -1,26 +1,28 @@
"""The sole production solo composer: frozen learned model plus music validity."""
import dataclasses
import time
import fractions
import pathlib
import time
import generator.harmonic_time
import generator.vocabulary
import generator.solo.types
import generator.solo.profiles
import generator.solo.harmonic
import generator.solo.placement
import generator.solo.learned
import generator.solo.decoder
import generator.solo.groups
import generator.solo.harmonic
import generator.solo.learned
import generator.solo.placement
import generator.solo.profiles
import generator.solo.types
import generator.vocabulary
def compose(analysis, measures, part, end, *, learned_model=None, initial=None, expressions_enabled=True, start=fractions.Fraction()):
def compose(analysis, measures, part, end, *, learned_model=None, initial=None, expressions_enabled=True, start=fractions.Fraction(), composition=None):
composition = composition or generator.vocabulary.current()
began = time.monotonic()
spans = tuple(dataclasses.replace(s, start=s.start + start, end=s.end + start) for s in generator.harmonic_time.read({'measures': measures}, initial=initial))
profile = generator.solo.profiles.for_part(part, analysis)
harmony = generator.solo.harmonic.Harmony(spans, profile)
harmony = generator.solo.harmonic.Harmony(spans, profile, composition=composition)
model = learned_model or generator.solo.learned.Model.load(pathlib.Path(__file__).resolve().parents[2] / 'data/models/solo.json')
settings = generator.vocabulary.role(part + '_solo')
builder = generator.solo.decoder.Decoder(analysis, harmony, model, part, start, end, expressions_enabled=expressions_enabled, attempts=settings.get('attempts', 4), seed=settings.get('choice_seed', ''))
settings = composition.role(part + '_solo')
builder = generator.solo.decoder.Decoder(analysis, harmony, model, part, start, end, expressions_enabled=expressions_enabled, attempts=settings.get('attempts', 4), seed=settings.get('choice_seed', ''), composition=composition)
selected = builder.compose()
decoded = time.monotonic()
placed = generator.solo.placement.place(selected.notes, analysis.tempo, profile=profile)
@@ -48,10 +50,11 @@ def compose(analysis, measures, part, end, *, learned_model=None, initial=None,
'counts': dict(builder.counts), 'frontiers': builder.trace, 'completed_candidates': [
{'rank': i + 1, 'cost': s.cost, 'events': [(str(a), str(b), p) for a, b, p in s.events]} for i, s in enumerate(builder.completed)],
'expressions_enabled': expressions_enabled}, profile, start)
validate(result)
validate(result, composition=composition)
return result
def validate(solo):
def validate(solo, *, composition=None):
composition = composition or generator.vocabulary.current()
previous = None
for n in solo.notes():
if n.start < solo.start or n.end > solo.end or n.end <= n.start or previous and previous.end > n.start:
@@ -59,7 +62,7 @@ def validate(solo):
if n.position not in generator.solo.placement.positions(n.pitch.number(), solo.profile):
raise ValueError('invalid guitar placement')
previous = n
checked = generator.solo.harmonic.Harmony(solo.harmony).evaluate(solo.notes(), until=solo.end, complete=True,
checked = generator.solo.harmonic.Harmony(solo.harmony, composition=composition).evaluate(solo.notes(), until=solo.end, complete=True,
expressions=tuple(c for p in solo.phrases for c in p.expressions))
if not checked.valid:
raise ValueError(checked.error)
+19 -17
View File
@@ -8,17 +8,18 @@ legacy fallback. A bounded restart handles an exhausted/entirely silent sample.
from __future__ import annotations
import collections
import dataclasses
import hashlib
import random
import math
import fractions
import hashlib
import math
import random
import generator.harmony
import generator.model
import generator.vocabulary
import generator.solo.expressions
import generator.solo.groups
import generator.solo.learned
import generator.solo.types
import generator.harmony
import generator.vocabulary
class SearchExhausted(ValueError):
pass
@@ -35,7 +36,8 @@ class State:
def event_key(events): return tuple((a, b, -1 if p is None else p) for a, b, p in events)
class Decoder:
def __init__(self, analysis, harmony, model, role, start, end, *, expressions_enabled=True, attempts=4, seed=''):
def __init__(self, analysis, harmony, model, role, start, end, *, expressions_enabled=True, attempts=4, seed='', composition=None):
self.composition = composition or generator.vocabulary.current()
if type(attempts) is not int or not 1 <= attempts <= 16:
raise ValueError('attempts must be between 1 and 16')
self.analysis, self.harmony, self.model, self.role = analysis, harmony, model, role
@@ -45,7 +47,7 @@ class Decoder:
self.seed = seed or hashlib.sha256(repr((source, role, generator.solo.learned.VERSION)).encode()).hexdigest()
self.expressions_enabled = expressions_enabled
self.low, self.high = harmony.profile.register
limits = generator.vocabulary.data('roles')['difficulty']
limits = self.composition.data('roles')['difficulty']
self.durations = tuple(d for d in model.durations if 0 < d <= 4 and d.denominator in (1, 2, 4) and
(d.denominator != 4 or analysis.tempo <= limits['sixteenth_max_bpm']))
self.allow_triplets = analysis.tempo <= limits['triplet_max_bpm']
@@ -92,12 +94,12 @@ class Decoder:
bases = []
regions = [(None, n)]
regions.extend((s.start, dataclasses.replace(n, start=s.start)) for s in self.harmony.spans
if n.start < s.start < n.end and s.start - n.start <= fractions.Fraction(generator.vocabulary.data('harmony')['anticipation_max']))
if n.start < s.start < n.end and s.start - n.start <= fractions.Fraction(self.composition.data('harmony')['anticipation_max']))
for boundary, arrived in regions:
exposed = [s for s, _, _ in self.harmony.segments(arrived) if n.pitch.number() % 12 not in s.roles.basic | s.roles.specified]
if not exposed:
continue
for rule in generator.vocabulary.data('harmony')['colors']:
for rule in self.composition.data('harmony')['colors']:
if arrived.end - arrived.start > fractions.Fraction(rule['max_beats']):
continue
if any(s.chord == 'N.C.' or not generator.solo.expressions.eligible_color(rule, s, self.harmony) or
@@ -139,7 +141,7 @@ class Decoder:
if self.harmony.evaluate((n,), complete=True, expressions=(c,), infer=False).valid:
return tuple([c])
for arriving in self.harmony.spans:
if n.start < arriving.start < n.end and arriving.start - n.start <= fractions.Fraction(generator.vocabulary.data('harmony')['anticipation_max']):
if n.start < arriving.start < n.end and arriving.start - n.start <= fractions.Fraction(self.composition.data('harmony')['anticipation_max']):
c = generator.solo.types.ExpressionContract(n.event_id + ':anticipation', 'anticipation', 'early_chord_tone', (n,), n, arriving.chord, arriving.start)
if self.harmony.evaluate((n,), complete=True, expressions=(c,), infer=False).valid:
return tuple([c])
@@ -175,9 +177,9 @@ class Decoder:
for rule, boundary in self.color_bases(n):
if rule.get('resolve'):
for gap in (fractions.Fraction(), fractions.Fraction(1, 2), fractions.Fraction(1)):
if gap <= fractions.Fraction(generator.vocabulary.data('harmony')['resolution_gap']):
if gap <= fractions.Fraction(self.composition.data('harmony')['resolution_gap']):
requests.append(('color', rule, boundary, n.end + gap, (-2, -1, 1, 2)))
delay = generator.vocabulary.data('lead_ins')['delayed_approach']
delay = self.composition.data('lead_ins')['delayed_approach']
if n.end - n.start <= fractions.Fraction(delay['max_note']) and n.pitch.number() % 12 not in self.harmony.permitted(n.start, n.end):
for arrival in map(fractions.Fraction, delay['arrivals']):
if n.end <= n.start + arrival <= n.start + fractions.Fraction(delay['deadline']):
@@ -219,7 +221,7 @@ class Decoder:
if self.expressions_enabled and not self.harmony.ordinary(n):
for events, ns, contracts in self.resolutions(n):
add(events, ns, contracts)
rule = generator.vocabulary.data('lead_ins')['passing']
rule = self.composition.data('lead_ins')['passing']
if duration <= fractions.Fraction(rule['max_note']):
for step in rule['steps']:
p = number + step
@@ -235,8 +237,8 @@ class Decoder:
c = generator.solo.types.ExpressionContract(n.event_id + ':passing', 'passing', rule['id'], (n,), target, self.harmony.at(end).chord)
add(((time, end, number), (end, end + hold, p)), (n, target), (c, *extra))
if self.expressions_enabled:
limits = generator.vocabulary.data('roles')['difficulty']
for rule in generator.vocabulary.data('lead_ins')['patterns']:
limits = self.composition.data('roles')['difficulty']
for rule in self.composition.data('lead_ins')['patterns']:
difficulty = rule.get('difficulty')
if difficulty and self.analysis.tempo > limits[difficulty + '_max_bpm']:
continue
@@ -313,9 +315,9 @@ class Decoder:
return None
contracts = tuple(dataclasses.replace(c, preparation=state.notes[-1]) if c.kind in ('connection', 'passing') and c.preparation is None else c for c in contracts)
if self.harmony.ordinary(state.notes[-1]):
_, error = generator.solo.expressions.validate((state.notes[-1], *notes), contracts, self.harmony)
_, error = generator.solo.expressions.validate((state.notes[-1], *notes), contracts, self.harmony, composition=self.composition)
else:
_, error = generator.solo.expressions.validate((*state.notes, *notes), (*state.contracts, *contracts), self.harmony)
_, error = generator.solo.expressions.validate((*state.notes, *notes), (*state.contracts, *contracts), self.harmony, composition=self.composition)
if error:
return None
history = state.history
-85
View File
@@ -1,85 +0,0 @@
"""Optional MusicXML views of finished production roles; never composes."""
from __future__ import annotations
import copy
import json
import pathlib
import fractions
import generator.model
import generator.musicxml_writer
import generator.score
def region(document, part):
measures = document['staves'][0]['measures']
first = next(i for i, m in enumerate(measures) if m.get('section_label') == part.capitalize() + ' Solo')
end = next((i for i in range(first + 1, len(measures)) if measures[i].get('section_label')), len(measures))
return first, end - first
def excerpt(document, first, count):
result = copy.deepcopy(document)
staff = result['staves'][0]
original = staff['measures']
staff['measures'] = original[first:first + count]
if not staff['measures']:
raise ValueError('Empty solo export region')
notes = [n for m in staff['measures'] for n in generator.score.measure_notes(m)]
identities = {p['id'] for n in notes for p in n['pitches']}
events = {n['id'] for n in notes}
for note in notes:
for pitch in note['pitches']:
for key in ('tie_from', 'tie_to'):
if pitch.get(key) not in identities:
pitch.pop(key, None)
staff['tuplets'] = [t for t in staff.get('tuplets', []) if t['start'] in events and t['end'] in events]
tuplets = {t['id'] for t in staff['tuplets']}
for note in notes:
if 'tuplet_ids' in note:
note['tuplet_ids'] = [i for i in note['tuplet_ids'] if i in tuplets]
offset = sum((generator.model.fraction(m['duration']) for m in original[:first]), fractions.Fraction())
end = offset + sum((generator.model.fraction(m['duration']) for m in staff['measures']), fractions.Fraction())
for key in ('scale_spans', 'octave_shifts'):
staff[key] = [{**s, 'start': generator.model.rational(max(offset, generator.model.fraction(s['start'])) - offset),
'end': generator.model.rational(min(end, generator.model.fraction(s['end'])) - offset)} for s in staff.get(key, [])
if generator.model.fraction(s['start']) < end and generator.model.fraction(s['end']) > offset]
generator.model.validate_document(result)
return result
def write_role(result, path):
role = result['role']
if role not in ('acoustic_solo', 'electric_solo'):
raise ValueError('Solo XML export requires an acoustic_solo or electric_solo role')
part = role.split('_')[0]
document = result['document']
first, count = region(document, part)
leadin = int(result.get('details', {}).get('allocation', {}).get('lead_in_measures', 0))
first -= leadin
count += leadin
selected = excerpt(document, first, count)
numbers = [m['number'] for m in selected['staves'][0]['measures']]
for i, measure in enumerate(selected['staves'][0]['measures'], 1):
measure['number'] = str(i)
path = pathlib.Path(path)
path.parent.mkdir(parents=True, exist_ok=True)
generator.musicxml_writer.write_musicxml(path, selected, tablature=True)
return {'role': role, 'file': path.name, 'form_start_measure': 1 + leadin,
'measure_count': count, 'arrangement_measures': numbers,
'arrangement_start_beat': str(sum((generator.model.fraction(m['duration']) for m in document['staves'][0]['measures'][:first]), fractions.Fraction())),
'pitch_convention': 'guitar-written; explicit octave transposition -1',
'trace': result['trace'], 'phrase_report': result.get('details', {})}
def export_tree(assets, output=None):
assets = pathlib.Path(assets)
output = pathlib.Path(output) if output else assets / 'solo_xml'
output.mkdir(parents=True, exist_ok=True)
entries = {}
for path in sorted((assets / 'analysis').glob('*.roles')):
roles = json.loads(path.read_text())
for i, part in enumerate(('acoustic', 'electric'), 1):
name = path.stem.replace('_', '-') + f'-solo{i}.xml'
entries[path.stem + '/' + part] = write_role(roles[part + '_solo'], output / name)
manifest = {'version': 1, 'composition_inputs': False, 'solos': entries}
# Runtime score discovery treats *.json under assets as score documents.
# Diagnostic manifests deliberately use a non-score extension, like .roles.
(output / 'manifest.solo').write_text(json.dumps(manifest, sort_keys=True, indent=2) + '\n')
return manifest
+21 -18
View File
@@ -1,13 +1,14 @@
"""Typed, target-driven harmonic expression against written harmony and explicit musical relationships."""
from __future__ import annotations
import dataclasses
import functools
import fractions
import functools
import generator.harmony
import generator.model
import generator.pitch
import generator.vocabulary
import generator.solo.types
import generator.vocabulary
@functools.lru_cache(maxsize=512)
def parsed_chord(symbol):
@@ -90,8 +91,9 @@ def _eligible_color(rule, span, harmony):
return False
return True
def validate(notes, contracts, harmony):
def validate(notes, contracts, harmony, *, composition=None):
"""Return event permissions only after checking complete actual gestures."""
composition = composition or generator.vocabulary.current()
actual = {n.event_id: n for n in notes}
approved = {}
@@ -115,7 +117,7 @@ def validate(notes, contracts, harmony):
if not previous or previous.chord.strip('()') == span.chord.strip('()'):
return {}, c.id + ': anticipation requires a harmonic change'
if c.kind in ('approach', 'enclosure', 'connection'):
rule = next((r for r in generator.vocabulary.data('lead_ins')['patterns'] if r['id'] == c.rule and r['kind'] == c.kind), None)
rule = next((r for r in composition.data('lead_ins')['patterns'] if r['id'] == c.rule and r['kind'] == c.kind), None)
if not rule or len(c.events) != len(rule['semitones']):
return {}, c.id + ': unknown approach formula'
arrival = c.boundary if c.boundary is not None else target.start
@@ -129,7 +131,7 @@ def validate(notes, contracts, harmony):
return {}, c.id + ': invalid internal approach gaps'
gap = fractions.Fraction(rule['gap'])
cursor = target.start - gap - sum((fractions.Fraction(d) for d in rule['durations']), fractions.Fraction()) - sum(gaps, fractions.Fraction())
if target.start - cursor > fractions.Fraction(generator.vocabulary.data('lead_ins')['max_approach']):
if target.start - cursor > fractions.Fraction(composition.data('lead_ins')['max_approach']):
return {}, c.id + ': approach too long'
for i, (n, step, duration) in enumerate(zip(c.events, rule['semitones'], rule['durations'])):
if n.start != cursor or n.end != cursor + fractions.Fraction(duration) or n.pitch.number() != target.pitch.number() + step:
@@ -144,7 +146,7 @@ def validate(notes, contracts, harmony):
if c.kind == 'connection' and (not c.preparation or c.preparation.end != c.events[0].start or abs(c.preparation.pitch.number() - c.events[0].pitch.number()) > 2):
return {}, c.id + ': chromatic connection lacks its incoming motion'
elif c.kind == 'passing':
rule = generator.vocabulary.data('lead_ins')['passing']
rule = composition.data('lead_ins')['passing']
if c.rule != rule['id'] or len(c.events) != 1 or not c.preparation:
return {}, c.id + ': unsupported passing figure'
n, = c.events
@@ -160,7 +162,7 @@ def validate(notes, contracts, harmony):
if not supported(before) or not supported(target):
return {}, c.id + ': unsupported passing endpoints'
elif c.kind == 'delayed_approach':
rule = generator.vocabulary.data('lead_ins').get('delayed_approach', {})
rule = composition.data('lead_ins').get('delayed_approach', {})
if c.rule != rule.get('id') or len(c.events) != 1:
return {}, c.id + ': unknown delayed approach'
n, = c.events
@@ -171,7 +173,7 @@ def validate(notes, contracts, harmony):
if target.pitch.number() % 12 not in harmony.members(target.start, target.end) or target.pitch.number() % 12 not in harmony.permitted(target.start, target.end):
return {}, c.id + ': invalid delayed destination'
elif c.kind == 'color':
rule = next((r for r in generator.vocabulary.data('harmony')['colors'] if r['id'] == c.rule), None)
rule = next((r for r in composition.data('harmony')['colors'] if r['id'] == c.rule), None)
if not rule:
return {}, c.id + ': unknown color policy'
colored = False
@@ -193,10 +195,10 @@ def validate(notes, contracts, harmony):
return {}, c.id + ': no interval expresses the declared color'
last = c.events[-1]
if rule.get('resolve'):
if target.event_id == last.event_id or not 0 <= target.start - last.end <= fractions.Fraction(generator.vocabulary.data('harmony')['resolution_gap']) or not 0 < abs(target.pitch.number() - last.pitch.number()) <= 2 or target.pitch.number() % 12 not in harmony.members(target.start, target.end):
if target.event_id == last.event_id or not 0 <= target.start - last.end <= fractions.Fraction(composition.data('harmony')['resolution_gap']) or not 0 < abs(target.pitch.number() - last.pitch.number()) <= 2 or target.pitch.number() % 12 not in harmony.members(target.start, target.end):
return {}, c.id + ': unresolved color'
elif c.kind == 'suspension':
rule = next((r for r in generator.vocabulary.data('harmony').get('suspensions', []) if r['id'] == c.rule), None)
rule = next((r for r in composition.data('harmony').get('suspensions', []) if r['id'] == c.rule), None)
if not rule or len(c.events) != 1 or c.boundary is None:
return {}, c.id + ': unsupported suspension'
held, = c.events
@@ -211,23 +213,23 @@ def validate(notes, contracts, harmony):
if held.pitch.number() % 12 not in harmony.permitted(held.start, held.end):
return {}, c.id + ': suspension outside source-key/chord motion'
elif c.kind == 'anticipated_color':
rule = next((r for r in generator.vocabulary.data('harmony')['colors'] if r['id'] == c.rule), None)
rule = next((r for r in composition.data('harmony')['colors'] if r['id'] == c.rule), None)
if not rule or len(c.events) != 1 or c.boundary != span.start:
return {}, c.id + ': unsupported anticipated color'
n, = c.events
if not n.start < c.boundary < n.end or c.boundary - n.start > fractions.Fraction(generator.vocabulary.data('harmony')['anticipation_max']):
if not n.start < c.boundary < n.end or c.boundary - n.start > fractions.Fraction(composition.data('harmony')['anticipation_max']):
return {}, c.id + ': invalid anticipated color interval'
arrived = dataclasses.replace(n, start=c.boundary)
target = arrived if c.target == n else c.target
inner = generator.solo.types.ExpressionContract(c.id + ':arrived', 'color', rule['id'], (arrived,), target, span.chord)
_, error = validate((arrived, *((target,) if target != arrived else ())), (inner,), harmony)
_, error = validate((arrived, *((target,) if target != arrived else ())), (inner,), harmony, composition=composition)
if error:
return {}, error
elif c.kind == 'anticipation':
if c.rule not in ('early_chord_tone', 'early_reattack') or len(c.events) != 1 or span.start != c.boundary:
return {}, c.id + ': unknown anticipation or non-boundary target'
n, = c.events
if c.boundary is None or not n.start < c.boundary or c.boundary - n.start > fractions.Fraction(generator.vocabulary.data('harmony')['anticipation_max']):
if c.boundary is None or not n.start < c.boundary or c.boundary - n.start > fractions.Fraction(composition.data('harmony')['anticipation_max']):
return {}, c.id + ': invalid anticipation interval'
if c.rule == 'early_chord_tone' and (n != target or not c.boundary < n.end):
return {}, c.id + ': invalid held anticipation'
@@ -238,7 +240,7 @@ def validate(notes, contracts, harmony):
elif c.kind == 'blues':
if len(c.events) != 1:
return {}, c.id + ': blues treatment requires one inflected event'
rule = next((r for r in generator.vocabulary.data('lead_ins')['blues'] if r['id'] == c.rule), None)
rule = next((r for r in composition.data('lead_ins')['blues'] if r['id'] == c.rule), None)
n, = c.events
chord = parsed_chord(span.chord)
if not rule or n.end - n.start > fractions.Fraction(1, 2) or n.end != target.start or target.pitch.number() % 12 not in span.roles.basic:
@@ -262,15 +264,16 @@ def validate(notes, contracts, harmony):
approved[n.event_id] = c
return approved, ''
def validate_frontier(notes, contracts, harmony, until, complete):
def validate_frontier(notes, contracts, harmony, until, complete, *, composition=None):
"""Validate heard prefixes and bounded future obligations separately.
Future contract events are used ONLY to establish rule feasibility. They do
not count as heard resolution; the contract stays pending until its entire
target hold is present. Missing past events and expired deadlines fail.
"""
composition = composition or generator.vocabulary.current()
if complete:
approved, error = validate(notes, contracts, harmony)
approved, error = validate(notes, contracts, harmony, composition=composition)
return approved, (), error
actual = {n.event_id: n for n in notes}
future = dict(actual)
@@ -290,5 +293,5 @@ def validate_frontier(notes, contracts, harmony, until, complete):
return {}, (), c.id + ': missing/changed event before resolution deadline'
if incomplete:
pending.append(c)
approved, error = validate(tuple(sorted(future.values(), key=lambda n: (n.start, n.event_id))), contracts, harmony)
approved, error = validate(tuple(sorted(future.values(), key=lambda n: (n.start, n.event_id))), contracts, harmony, composition=composition)
return {key: c for key, c in approved.items() if key in actual}, tuple(pending), error
+10 -7
View File
@@ -5,14 +5,16 @@ permission follows the actual sounded interval and validated resolution.
"""
from __future__ import annotations
import dataclasses
import functools
import fractions
import functools
import generator.harmony
import generator.model
import generator.solo.types
import generator.solo.profiles
import generator.solo.expressions
import generator.solo.profiles
import generator.solo.recognition
import generator.solo.types
import generator.vocabulary
@dataclasses.dataclass(frozen=True)
class Roles:
@@ -55,7 +57,8 @@ class Result:
contracts: tuple = ()
class Harmony:
def __init__(self, spans, profile=None):
def __init__(self, spans, profile=None, *, composition=None):
self.composition = composition or generator.vocabulary.current()
self.profile = profile or generator.solo.profiles.UNRESTRICTED
self.source_spans = spans
self.spans = []
@@ -112,14 +115,14 @@ class Harmony:
expressions = tuple(dataclasses.replace(c, events=tuple(self.identified(n) for n in c.events),
target=self.identified(c.target), preparation=self.identified(c.preparation) if c.preparation else None) for c in expressions)
frontier = until if until is not None else max((n.end for n in notes), default=fractions.Fraction())
permissions, pending, error = generator.solo.expressions.validate_frontier(notes, expressions, self, frontier, complete or until is None)
permissions, pending, error = generator.solo.expressions.validate_frontier(notes, expressions, self, frontier, complete or until is None, composition=self.composition)
if error:
return Result(False, 0, error=error)
if infer and not pending and (complete or until is None) and any(not self.ordinary(n) and n.event_id not in permissions for n in notes):
expressions, error = generator.solo.recognition.recognize(notes, self, expressions)
expressions, error = generator.solo.recognition.recognize(notes, self, expressions, composition=self.composition)
if error:
return Result(False, 0, error=error)
permissions, pending, error = generator.solo.expressions.validate_frontier(notes, expressions, self, frontier, True)
permissions, pending, error = generator.solo.expressions.validate_frontier(notes, expressions, self, frontier, True, composition=self.composition)
if error:
return Result(False, 0, error=error)
exposed = sounded = fractions.Fraction()
+69 -40
View File
@@ -5,77 +5,106 @@ import fractions
import functools
import generator.fretboard
import generator.hand_position
import generator.solo.types
import generator.solo.profiles
import generator.solo.policy
def travel(previous: generator.solo.types.Note | None, current: generator.solo.types.Note, tempo: fractions.Fraction) -> int:
if previous is None:
return 0
return transition(previous.position, current.position, current.start - previous.start, tempo)
@functools.lru_cache(maxsize=16384)
def transition(previous, current, duration, tempo):
distance = abs(previous.fret - current.fret) + abs(previous.string_number - current.string_number)
seconds = float(duration * 60 / tempo)
# Movement is a preference, not an unsupported claim about a player's limits.
return round(100 * distance / max(seconds, 0.05))
def hand_positions(position):
return tuple(h for h in range(1, 10) if h <= position.fret <= h + 3)
return generator.hand_position.regions((position,))
@functools.lru_cache(maxsize=512)
def position_rank(position):
return generator.solo.policy.stable_rank('guitar-position', position)
def stable_path(path):
return tuple(position_rank(n.position) for n in path)
def seconds(duration, tempo):
return max(fractions.Fraction(1, 20), duration * 60 / tempo)
@functools.lru_cache(maxsize=4096)
def alternatives(notes, tempo, previous=None, limit=2, profile=generator.solo.profiles.UNRESTRICTED):
"""Phrase paths with a four-fret hand region and distinct endpoint choices."""
states = [(0, (), h) for h in hand_positions(previous.position)] if previous and previous.position else [(0, (), None)]
@dataclasses.dataclass(frozen=True)
class Path:
travel: int = 0
peak: int = 0
effort: fractions.Fraction = fractions.Fraction()
notes: tuple = ()
hands: tuple = ()
ties: tuple = ()
@property
def rank(self):
return self.travel, self.peak, self.effort, self.ties
@functools.lru_cache(maxsize=512)
def paths(notes, tempo, previous=None, profile=generator.solo.profiles.UNRESTRICTED, fixed=False):
"""Complete TAB paths: hand travel first, then maximum hand position.
Preserve different peaks at a common endpoint. No barline or tied fragment
resets the hand or shortens the elapsed time from the previous attack.
"""
states = [(Path(peak=h), h) for h in hand_positions(previous.position)] if previous and previous.position else [(Path(), 0)]
last_attack = previous.start if previous else None
for note in notes:
following = {}
for position in positions(note.pitch.number(), profile):
options = (note.position,) if fixed and note.position else positions(note.pitch.number(), profile)
for position in options:
current = dataclasses.replace(note, position=position)
for hand in hand_positions(position):
best = None
for cost, path, old_hand in states:
prior = path[-1] if path else previous
if note.continuation and (prior is None or prior.pitch != note.pitch or prior.position != position or prior.end != note.start):
for path, old_hand in states:
prior = path.notes[-1] if path.notes else previous
if note.continuation and (prior is None or prior.pitch != note.pitch or prior.position != position or prior.end != note.start or hand != old_hand):
continue
movement = 0
motion = generator.hand_position.Motion()
effort = fractions.Fraction()
if prior and not note.continuation:
seconds = max(.05, float((note.start - prior.start) * 60 / tempo))
distance = abs(hand - old_hand) if old_hand is not None else 0
distance += .25 * abs(position.fret - prior.position.fret) + .5 * abs(position.string_number - prior.position.string_number)
movement = round(100 * distance / seconds)
candidate = (cost + movement, (*path, current), hand)
if best is None or candidate[0] < best[0] or candidate[0] == best[0] and stable_path(candidate[1]) < stable_path(best[1]):
best = candidate
if best is not None:
following[position, hand] = best
motion = generator.hand_position.motion((prior.position,), (position,), old_hand, hand)
effort = 100 * (motion.shift + motion.ergonomics) / seconds(note.start - last_attack, tempo)
candidate = Path(path.travel + motion.shift, max(path.peak, hand), path.effort + effort, (*path.notes, current), (*path.hands, hand), (*path.ties, (position_rank(position), hand)))
key = (position, hand, candidate.peak)
if key not in following or candidate.rank < following[key].rank:
following[key] = candidate
if not following:
return ()
states = list(following.values())
# Endpoints survive so the following phrase can choose a better transition.
# A strictly worse hand travel at the identical endpoint/hand cannot recover.
best = {}
for (position, hand, _), path in following.items():
best[position, hand] = min(best.get((position, hand), path.travel), path.travel)
states = [(path, hand) for (position, hand, _), path in following.items() if path.travel == best[position, hand]]
if not note.continuation:
last_attack = note.start
return tuple(sorted((path for path, _ in states), key=lambda path: path.rank))
@functools.lru_cache(maxsize=512)
def alternatives(notes, tempo, previous=None, limit=2, profile=generator.solo.profiles.UNRESTRICTED):
selected, seen = [], set()
for cost, path, hand in sorted(states, key=lambda v: (v[0], stable_path(v[1]))):
endpoint = path[-1].position if path else None
for path in paths(notes, tempo, previous, profile):
endpoint = (path.notes[-1].position, path.hands[-1]) if path.notes else None
if endpoint in seen:
continue
seen.add(endpoint)
selected.append((cost, path))
selected.append((path.travel, path.notes))
if len(selected) == limit:
break
return tuple(selected)
@functools.lru_cache(maxsize=4096)
@functools.lru_cache(maxsize=512)
def place(notes, tempo, previous=None, profile=generator.solo.profiles.UNRESTRICTED):
result = alternatives(notes, tempo, previous, 1, profile)
return result[0] if result else None
def describe(notes, tempo):
candidates = paths(notes, tempo, fixed=True)
if not candidates:
raise ValueError('cannot describe an invalid guitar path')
path = candidates[0]
result, prior, old_hand, last_attack = [], None, 0, None
for note, hand in zip(path.notes, path.hands):
motion = generator.hand_position.motion((prior.position,), (note.position,), old_hand, hand) if prior and not note.continuation else generator.hand_position.Motion()
effort = 100 * (motion.shift + motion.ergonomics) / seconds(note.start - last_attack, tempo) if prior and not note.continuation else 0
result.append({'start': str(note.start), 'end': str(note.end), 'hand_position': hand, 'string': note.position.string_number,
'fret': note.position.fret, 'hand_shift': motion.shift, 'finger_adjustment': motion.fingers, 'string_changes': motion.strings, 'secondary_effort': str(effort)})
if not note.continuation:
last_attack = note.start
prior, old_hand = note, hand
return {'version': generator.hand_position.VERSION, **generator.hand_position.summary(r['hand_shift'] for r in result), 'secondary_effort': str(path.effort), 'peak_position': path.peak, 'positions': result}
@functools.lru_cache(maxsize=2048)
def positions(number: int, profile=generator.solo.profiles.UNRESTRICTED):
profile = profile or generator.solo.profiles.UNRESTRICTED
+1 -2
View File
@@ -2,11 +2,10 @@
from __future__ import annotations
import dataclasses
import functools
import fractions
import functools
import generator.fretboard
import generator.vocabulary
@dataclasses.dataclass(frozen=True)
class Instrument:
+14 -12
View File
@@ -5,9 +5,10 @@ Existing expression validators prove each candidate; deterministic set-cover
search chooses a mutually consistent explanation, never edits the notes.
"""
import fractions
import generator.vocabulary
import generator.solo.expressions
import generator.solo.types
import generator.vocabulary
def signature(c):
return (c.kind, c.rule, tuple(n.event_id for n in c.events), c.target.event_id,
@@ -20,7 +21,8 @@ def merge(*groups):
result.setdefault(signature(c), c)
return tuple(result.values())
def recognize(notes, harmony, provided=(), *, budget=4096):
def recognize(notes, harmony, provided=(), *, budget=4096, composition=None):
composition = composition or generator.vocabulary.current()
required = {n.event_id for n in notes if not harmony.ordinary(n)}
fixed = {n.event_id for c in provided for n in c.events}
if required <= fixed:
@@ -46,7 +48,7 @@ def recognize(notes, harmony, provided=(), *, budget=4096):
if not (covered & required):
return False
combined = merge(provided, bundle)
_, error = generator.solo.expressions.validate(notes, combined, harmony)
_, error = generator.solo.expressions.validate(notes, combined, harmony, composition=composition)
if error:
return False
candidates[tuple(signature(a) for a in bundle)] = (bundle, covered)
@@ -57,11 +59,11 @@ def recognize(notes, harmony, provided=(), *, budget=4096):
for i, n in enumerate(notes):
if n.event_id not in required:
continue
future = [t for t in notes[i + 1:] if n.end <= t.start <= n.end + fractions.Fraction(generator.vocabulary.data('harmony')['resolution_gap'])
future = [t for t in notes[i + 1:] if n.end <= t.start <= n.end + fractions.Fraction(composition.data('harmony')['resolution_gap'])
and 0 < abs(t.pitch.number() - n.pitch.number()) <= 2]
regions = [(None, harmony.at(n.start))]
regions.extend((s.start, s) for s in harmony.spans if n.start < s.start < n.end
and s.start - n.start <= fractions.Fraction(generator.vocabulary.data('harmony')['anticipation_max']))
and s.start - n.start <= fractions.Fraction(composition.data('harmony')['anticipation_max']))
for boundary, span in regions:
if not span or span.chord == 'N.C.':
continue
@@ -69,7 +71,7 @@ def recognize(notes, harmony, provided=(), *, budget=4096):
c = contract('anticipation', 'early_chord_tone', (n,), n, boundary)
if add(c):
single.setdefault(n.event_id, []).append((c,))
for rule in generator.vocabulary.data('harmony')['colors']:
for rule in composition.data('harmony')['colors']:
if not generator.solo.expressions.eligible_color(rule, span, harmony) and boundary is not None:
continue
kind = 'anticipated_color' if boundary is not None else 'color'
@@ -85,7 +87,7 @@ def recognize(notes, harmony, provided=(), *, budget=4096):
target = notes[i + 1]
for s in harmony.spans:
if n.start < s.start < n.end:
for rule in generator.vocabulary.data('harmony').get('suspensions', []):
for rule in composition.data('harmony').get('suspensions', []):
add(contract('suspension', rule['id'], (n,), target, s.start))
elif s.start == n.end == target.start and n.pitch.number() == target.pitch.number():
add(contract('anticipation', 'early_reattack', (n,), target, s.start))
@@ -99,7 +101,7 @@ def recognize(notes, harmony, provided=(), *, budget=4096):
targets.append((None, support))
elif c.kind == 'anticipation':
targets.append((c.boundary, support))
for rule in generator.vocabulary.data('lead_ins')['patterns']:
for rule in composition.data('lead_ins')['patterns']:
size = len(rule['semitones'])
if i < size:
continue
@@ -113,7 +115,7 @@ def recognize(notes, harmony, provided=(), *, budget=4096):
add(contract(rule['kind'], rule['id'], ns, target, boundary, preparation), extras)
# Delayed approaches may include real space or intervening valid music.
# They still have an exact semitone target and a finite deadline.
rule = generator.vocabulary.data('lead_ins')['delayed_approach']
rule = composition.data('lead_ins')['delayed_approach']
for n in reversed(notes[:i]):
if target.start - n.start > fractions.Fraction(rule['deadline']):
break
@@ -124,8 +126,8 @@ def recognize(notes, harmony, provided=(), *, budget=4096):
if n.event_id in required:
for left in [(), *single.get(before.event_id, ())]:
for right in [(), *single.get(target.event_id, ())]:
add(contract('passing', generator.vocabulary.data('lead_ins')['passing']['id'], (n,), target, preparation=before), merge(left, right))
for rule in generator.vocabulary.data('lead_ins')['blues']:
add(contract('passing', composition.data('lead_ins')['passing']['id'], (n,), target, preparation=before), merge(left, right))
for rule in composition.data('lead_ins')['blues']:
add(contract('blues', rule['id'], (n,), target, preparation=before))
options = {identifier: [] for identifier in sorted(required - fixed, key=lambda identifier: (by_id[identifier].start, identifier))}
for bundle, covered in candidates.values():
@@ -152,7 +154,7 @@ def recognize(notes, harmony, provided=(), *, budget=4096):
identifier = min(remaining, key=lambda x: (len(options[x]), by_id[x].start, x))
for bundle, added in options[identifier]:
combined = merge(chosen, bundle)
_, error = generator.solo.expressions.validate(notes, combined, harmony)
_, error = generator.solo.expressions.validate(notes, combined, harmony, composition=composition)
if error:
continue
result = solve(combined, covered | added)
+12 -9
View File
@@ -1,9 +1,10 @@
"""Compact reports of actual selected phrases, not duplicated draft ancestry."""
import dataclasses, fractions, json
import generator.solo.placement
import generator.solo.harmonic
import collections
import generator.fretboard
import dataclasses, fractions, json
import generator.solo.harmonic
import generator.solo.placement
import generator.vocabulary
def plain(value):
if dataclasses.is_dataclass(value):
@@ -16,8 +17,9 @@ def plain(value):
return str(value)
return value
def structure(solo):
harmony = generator.solo.harmonic.Harmony(solo.harmony)
def structure(solo, *, composition=None):
composition = composition or generator.vocabulary.current()
harmony = generator.solo.harmonic.Harmony(solo.harmony, composition=composition)
contracts = tuple(c for p in solo.phrases for c in p.expressions)
checked = harmony.evaluate(solo.notes(), until=solo.end, complete=True, expressions=contracts)
phrases = []
@@ -30,15 +32,16 @@ def structure(solo):
ns = solo.notes()
duration = solo.end - solo.start
return {'schema': 'composer-report-3', 'selection_trace': plain({k: v for k, v in solo.diagnostics.items() if not k.endswith('_seconds')}),
'instrument_profile': plain(solo.profile), 'phrases': phrases, 'expressions': plain(contracts), 'fretboard': fretboard_report(solo),
'instrument_profile': plain(solo.profile), 'phrases': phrases, 'expressions': plain(contracts), 'fretboard': fretboard_report(solo), 'guitar_placement': generator.solo.placement.describe(solo.notes(), solo.tempo),
'phrasing': {'attacks': len(ns), 'allocation_beats': str(duration),
'attacks_per_four_beats': 4 * len(ns) / float(duration) if duration else 0,
'occupancy': sum(float(n.end - n.start) for n in ns) / float(duration) if duration else 0},
'harmonic_roles': harmony.describe(ns, expressions=contracts), 'harmonic_policy': 'contextual (shared by authored and predicted music)', 'harmonic_valid': checked.valid, 'harmonic_error': checked.error,
'harmonic_exposure': checked.exposure, 'unresolved_treatments': plain(checked.pending)}
def describe(solo, measure_offset=0, time_offset=0, *, detail=None):
detail = detail or structure(solo)
def describe(solo, measure_offset=0, time_offset=0, *, detail=None, composition=None):
composition = composition or generator.vocabulary.current()
detail = detail or structure(solo, composition=composition)
lines = [f'{solo.diagnostics.get("construction", "solo")}: {solo.part}', 'Times are exact quarter beats from the chorus start; negative times are allocated lead-ins. Pitches sound one octave below guitar notation.',
'Approximate fingering costs are not a biomechanical guarantee.', json.dumps(detail['phrasing'])]
for p in solo.phrases:
@@ -1,7 +1,14 @@
"""Immutable source events, meter boundaries and tempo. No solo construction."""
from __future__ import annotations
import dataclasses, fractions
import generator.model, generator.score, generator.solo.types
import copy
import dataclasses
import fractions
import hashlib
import json
import generator.model
import generator.score
import generator.solo.types
@dataclasses.dataclass(frozen=True)
class Analysis:
@@ -43,3 +50,32 @@ def analyze(document):
boundaries.append(boundaries[-1] + generator.model.fraction(m['duration']))
tempo = next((generator.model.fraction(t['bpm']) * generator.model.written_length(t['written']) for m in measures for t in m.get('tempos', []) if 'bpm' in t), fractions.Fraction(120))
return Analysis(tuple(boundaries), tempo, attacks(document), boundaries[generator.score.body_start_measure_index(measures)])
@dataclasses.dataclass(frozen=True)
class SourceAnalysis:
document_json: str
musical_key: str
@classmethod
def read(cls, document):
prepared = copy.deepcopy(document)
staff = generator.score.source_staff(prepared)
for i, m in enumerate(staff['measures']):
m['id'], m['number'] = f'source_{i}', str(i + 1)
staff['tuplets'] = generator.score.reidentify(staff['measures'], staff.get('tuplets', []))
prepared['metadata'] = {k: v for k, v in prepared['metadata'].items() if k not in ('title', 'composer', 'copyright', 'software')}
prepared['metadata'].update(title='Source', composer='')
staff.update(id='source', name='Source')
melodic = analyze(prepared)
content = {'melody': [(str(n.start), str(n.end), dataclasses.asdict(n.pitch)) for n in melodic.melody],
'measures': [{k: m.get(k) for k in ('duration', 'time_signature', 'key', 'harmonies', 'tempos', 'section_label', 'implicit')} for m in staff['measures']]}
# Fraction/string spelling is canonical and never includes filesystem IDs.
key = hashlib.sha256(json.dumps(content, sort_keys=True, default=str).encode()).hexdigest()
return cls(json.dumps(prepared, sort_keys=True), key)
def document(self):
return json.loads(self.document_json)
def accompaniment_key(self):
document = self.document()
document['metadata'].pop('tempo', None)
for measure in generator.score.source_staff(document)['measures']:
measure['tempos'] = []
return SourceAnalysis.read(document).musical_key
+2 -1
View File
@@ -6,6 +6,7 @@ import typing
import generator.model
import generator.score
import generator.score_io
def _arranged_staff(document: dict[str, typing.Any]) -> dict[str, typing.Any]:
staves = document.get("staves")
@@ -61,7 +62,7 @@ def performance_document_summary(document: dict[str, typing.Any]) -> dict[str, t
def performance_tree_summary(root: pathlib.Path) -> dict[str, typing.Any]:
return {
path.name: performance_document_summary(generator.score.load_json(path))
path.name: performance_document_summary(generator.score_io.load_json(path))
for path in sorted(root.glob("*.json"))
}
+10 -11
View File
@@ -3,26 +3,25 @@ from __future__ import annotations
import argparse
import collections
import dataclasses
import fractions
import hashlib
import json
import os
import pathlib
import shutil
import tempfile
import time
import fractions
import generator.fretboard
import generator.harmonic_time
import generator.harmony
import generator.model
import generator.musicxml
import generator.parts
import generator.solo.authored
import generator.solo.learned
import generator.source
import generator.training_io
import generator.vocabulary
import generator.harmonic_time
import generator.solo.analysis
import generator.solo.learned
import shutil
import generator.production
import generator.solo.authored
import generator.fretboard
@dataclasses.dataclass(frozen=True)
class Span:
@@ -57,8 +56,8 @@ def load_examples(manifest):
if not source.is_relative_to((manifest.parent.parent / 'songs').resolve()):
raise ValueError('Training sources must be inside data/songs')
document = generator.parts.prepare_document(generator.musicxml.load_musicxml(source))
a = generator.solo.analysis.analyze(document)
pair = (generator.production.SourceAnalysis.read(document).musical_key, entry['slot'])
a = generator.source.analyze(document)
pair = (generator.source.SourceAnalysis.read(document).musical_key, entry['slot'])
if pair in pairs:
raise ValueError('Duplicate source music and solo slot')
pairs.add(pair)
+161
View File
@@ -0,0 +1,161 @@
"""Score document validation, above pure musical values and instrument rules."""
from __future__ import annotations
import fractions
import generator.fretboard
import generator.model
import generator.pitch
def validate_document(document: dict) -> None:
if not isinstance(document, dict) or not isinstance(document.get('metadata'), dict):
raise ValueError('score requires a metadata object')
if any(not isinstance(document['metadata'].get(name), str) for name in ('title', 'composer', 'key_signature', 'time_signature')):
raise ValueError('score metadata requires title, composer, key_signature and time_signature strings')
staves = document.get('staves', [])
if not isinstance(staves, list) or len(staves) != 1 or not isinstance(staves[0], dict):
raise ValueError('exactly one staff is currently supported')
if not isinstance(staves[0].get('measures'), list) or not staves[0]['measures']:
raise ValueError('score requires measures')
instruments = staves[0].get('instruments', [])
instrument_ids = {i['id'] for i in instruments}
if len(instruments) != len(instrument_ids) or any(not isinstance(i, str) or not i for i in instrument_ids):
raise ValueError('score instruments require unique nonempty IDs')
ids: set[str] = set()
events: dict[str, dict] = {}
tones: dict[str, tuple[dict, fractions.Fraction, fractions.Fraction, str]] = {}
ownership: dict[str, str] = {}
absolute = fractions.Fraction()
for measure in staves[0]['measures']:
if {'repeats', 'endings', 'initial_attributes'} & measure.keys():
raise ValueError('repeat notation is unsupported; regenerate scores from music written out in reading order')
length = generator.model.fraction(measure['duration'])
if length <= 0:
raise ValueError('measure duration must be positive')
voices = measure.get('voices', [])
if not voices or len({v['id'] for v in voices}) != len(voices) or any(not v['id'] for v in voices):
raise ValueError('measure requires uniquely identified voice lanes')
previous_ends = {v['id']: fractions.Fraction() for v in voices}
for voice, note in ((v, n) for v in voices for n in v['notes']):
if any({'sound_ties', 'printed_ties'} & pitch.keys() for pitch in note['pitches']):
raise ValueError('pass-specific tie metadata is unsupported; regenerate scores')
if not note['id'] or note['id'] in ids:
raise ValueError(f'duplicate event ID: {note["id"]}')
ids.add(note['id'])
events[note['id']] = note
ownership[note['id']] = voice['id']
if note.get('voice', voice['id']) != voice['id']:
raise ValueError('event voice ownership disagrees with its lane')
onset, duration = generator.model.fraction(note['onset']), generator.model.fraction(note['duration'])
if onset < 0 or duration < 0 or onset + duration > length:
raise ValueError(f'event outside measure: {note["id"]}')
if note['kind'] not in ('note', 'rest', 'spacer'):
raise ValueError('invalid event kind')
if not note.get('grace'):
if duration == 0 or onset < previous_ends[voice['id']]:
raise ValueError('overlapping events in one rhythmic voice')
previous_ends[voice['id']] = onset + duration
elif duration != 0:
raise ValueError('grace notes must not advance metric time')
expected = generator.model.metric_length(note['written'])
if not note.get('grace') and not note.get('measure_rest') and duration != expected:
raise ValueError('metric and written event durations disagree')
if note['kind'] != 'note' and note.get('pitches'):
raise ValueError('rests and spacers cannot contain pitches')
if note['kind'] == 'note' and not note.get('pitches') and note.get('notehead') != 'slash':
raise ValueError('pitched event requires at least one pitch')
for p in note.get('pitches', []):
if p.get('instrument') and p['instrument'] not in instrument_ids:
raise ValueError('note refers to an unknown score instrument')
if 'unpitched' in p:
position = p['unpitched']
if position['letter'] not in generator.model.LETTERS or type(position['octave']) is not int:
raise ValueError('invalid unpitched display position')
else:
generator.model.pitch_number(p)
if staves[0].get('tablature'):
tab = p.get('tablature', {})
string, fret = tab.get('string'), tab.get('fret')
if type(string) is not int or type(fret) is not int or string not in dict(generator.fretboard.STANDARD_TUNING) or not generator.fretboard.MIN_FRET <= fret <= generator.fretboard.MAX_FRET:
raise ValueError(f'{p["id"]}: invalid generated tablature position')
state = dict(measure)
for change in measure.get('attributes', []):
if generator.model.fraction(change['onset']) <= onset:
state.update(change)
if dict(generator.fretboard.STANDARD_TUNING)[string] + fret != generator.pitch.sounding_pitch(p, state):
raise ValueError(f'{p["id"]}: tablature disagrees with sounding pitch')
pd = generator.model.fraction(p['duration'])
if pd < 0 or (pd == 0 and not note.get('grace')) or pd > duration or not p['id'] or p['id'] in tones:
raise ValueError('invalid chord-tone duration or duplicate ID')
if not note.get('grace') and pd != generator.model.metric_length(p['written']):
raise ValueError('metric and written chord-tone durations disagree')
tones[p['id']] = (p, absolute + onset, pd, voice['id'])
for harmony in measure.get('harmonies', []):
if not 0 <= generator.model.fraction(harmony['onset']) < length:
raise ValueError('harmony outside measure')
for change in measure.get('attributes', []):
if not 0 <= generator.model.fraction(change['onset']) < length:
raise ValueError('attribute change outside measure')
for state in [measure, *measure.get('attributes', [])]:
if 'meter' in state:
generator.model.validate_meter(state['meter'])
if 'key' in state:
if len(state['key']['alterations']) != 7:
raise ValueError('key alterations must contain seven exact alterations')
for value in state['key']['alterations']:
generator.model.alteration(value)
if 'clef' in state and (state['clef']['sign'] not in ('G', 'F', 'C', 'percussion', 'none') or not 1 <= state['clef']['line'] <= 6 or not -3 <= state['clef']['octave_change'] <= 3):
raise ValueError('invalid clef')
absolute += length
for identifier, (p, start, duration, voice) in tones.items():
if target := p.get('tie_to'):
if target not in tones:
raise ValueError(f'dangling tie: {identifier} -> {target}')
other, next_start, _, next_voice = tones[target]
same_pitch = all(p.get(k) == other.get(k) for k in ('unpitched', 'instrument')) if 'unpitched' in p else all(p.get(k) == other.get(k) for k in ('letter', 'alter', 'octave'))
if other.get('tie_from') != identifier or not same_pitch or next_voice != voice or next_start != start + duration:
raise ValueError(f'invalid tie: {identifier} -> {target}')
if staves[0].get('tablature') and p['tablature'] != other['tablature']:
raise ValueError(f'{identifier}: tied guitar tones must retain their string and fret')
if source := p.get('tie_from'):
if source not in tones or tones[source][0].get('tie_to') != identifier:
raise ValueError(f'dangling incoming tie: {identifier}')
span_ids = set()
event_order = {identifier: index for index, identifier in enumerate(events)}
for span in staves[0].get('tuplets', []):
if not span['id'] or span['id'] in span_ids or span['start'] not in ids or span['end'] not in ids or not 0 < span['note_count'] <= 1000000 or not 0 < span['space_count'] <= 1000000 or not 0 <= span['depth'] <= 16:
raise ValueError('invalid tuplet span')
members = [n['id'] for n in events.values() if span['id'] in n.get('tuplet_ids', [])]
if not members or members[0] != span['start'] or members[-1] != span['end'] or event_order[span['start']] > event_order[span['end']]:
raise ValueError('tuplet endpoints disagree with member events')
if len({ownership[n] for n in members}) != 1 or span.get('voice', ownership[members[0]]) != ownership[members[0]]:
raise ValueError('tuplet crosses independent voice lanes')
if span.get('bracket', 'auto') not in ('yes', 'no', 'auto') or span.get('show_number', 'actual') not in ('none', 'actual', 'both'):
raise ValueError('invalid tuplet appearance')
span_ids.add(span['id'])
for note in events.values():
for verse in note.get('lyrics', []):
start = tones[note['pitches'][0]['id']][1] if note['pitches'] else fractions.Fraction()
if 'extend_to' in verse and not start < generator.model.fraction(verse['extend_to']) <= absolute:
raise ValueError('lyric extension endpoint is outside the score')
if any(t not in span_ids for t in note.get('tuplet_ids', [])):
raise ValueError('event refers to an unknown tuplet')
if tremolo := note.get('tremolo'):
if tremolo['type'] not in ('single', 'start', 'stop') or type(tremolo['marks']) is not int or not 0 <= tremolo['marks'] <= 8:
raise ValueError('invalid measured tremolo')
if tremolo['type'] in ('start', 'stop'):
other = events.get(tremolo.get('partner'))
expected_type = 'stop' if tremolo['type'] == 'start' else 'start'
if not other or other.get('tremolo', {}).get('partner') != note['id'] or other['tremolo']['type'] != expected_type or other['tremolo']['marks'] != tremolo['marks']:
raise ValueError('invalid paired tremolo')
for span in staves[0].get('octave_shifts', []):
if not 0 <= generator.model.fraction(span['start']) < generator.model.fraction(span['end']) <= absolute or not -3 <= span['octaves'] <= 3:
raise ValueError('invalid octave-shift span')
previous_end = fractions.Fraction()
for span in staves[0].get('scale_spans', []):
start, end = generator.model.fraction(span['start']), generator.model.fraction(span['end'])
if not previous_end <= start < end <= absolute or not isinstance(span.get('label'), str) or not span['label'].strip() or type(span.get('matched')) is not bool:
raise ValueError('invalid solo scale span')
if not isinstance(span.get('id'), str) or not span['id'] or span['id'] in ids:
raise ValueError('solo scale spans require unique IDs')
ids.add(span['id'])
previous_end = end
+114 -20
View File
@@ -2,12 +2,14 @@
from __future__ import annotations
import contextlib
import contextvars
import copy
import dataclasses
import fractions
import functools
import hashlib
import json
import pathlib
import fractions
import types
ROOT = pathlib.Path(__file__).resolve().parents[1] / 'data' / 'composition'
ACTIVE = contextvars.ContextVar('composition_vocabulary', default=None)
@@ -16,27 +18,87 @@ def load(root=ROOT):
# Content, not just the directory, keys memoization. Long-lived individual
# role builds must observe edited production data without restarting Python.
names = ('roles', 'harmony', 'lead_ins', 'accompaniment')
return _load(tuple((name, (pathlib.Path(root) / (name + '.json')).read_text()) for name in names))
return copy.deepcopy(_load(tuple((name, (pathlib.Path(root) / (name + '.json')).read_text()) for name in names)))
@functools.lru_cache(maxsize=16)
def _load(contents):
result = {}
for name, text in contents:
value = json.loads(text)
if value.get('version') != (2 if name == 'accompaniment' else 1) or not value.get('provenance') or not value.get('license'):
if value.get('version') != (6 if name == 'accompaniment' else 1) or not value.get('provenance') or not value.get('license'):
raise ValueError(f'{name}: unsupported or unprovenanced production vocabulary')
if name == 'accompaniment':
if fractions.Fraction(value['grid']) != fractions.Fraction(1, 2):
raise ValueError('accompaniment requires an eighth-note placement grid')
for lane in ('electric', 'bass', 'upper'):
layer = value['layers'][lane]
if not 0 <= layer['attacks'][0] <= layer['attacks'][1] <= 3 or not layer['families']:
raise ValueError('invalid accompaniment attack range or duration families')
for family in layer['families']:
if not value['families'][family] or any(fractions.Fraction(d) <= 0 for d in value['families'][family]):
raise ValueError('accompaniment durations must be positive')
if not 1 <= value['lane_candidates'] <= 64 or not 1 <= value['measure_candidates'] <= 64:
raise ValueError('accompaniment candidate budgets must be 1–64')
signatures = {}
for part in ('electric', 'acoustic'):
policy = value['instruments'][part]
if part == 'acoustic' and policy.get('first_attack') != 'bass_per_harmony':
raise ValueError('acoustic patterns require bass at the first attack of each harmony')
if part == 'acoustic' and policy.get('attack_assignment') != {'version': 1, 'mode': 'combined_except_eighth_pairs'}:
raise ValueError('acoustic patterns require automatic eighth-pair assignment')
groove = policy['groove']
if any(type(groove[k]) is not int for k in ('cycle_patterns', 'slot_candidates', 'fill_spacing_measures')) or not 1 <= groove['cycle_patterns'] <= 4 or not 4 <= groove['slot_candidates'] <= 8 or groove['fill_spacing_measures'] < 8:
raise ValueError('invalid bounded accompaniment groove policy')
identifiers = set()
signatures[part] = set()
for pattern in policy['patterns']:
if pattern['id'] in identifiers or not pattern['family']:
raise ValueError('duplicate or unnamed accompaniment pattern')
identifiers.add(pattern['id'])
lengths = tuple(map(fractions.Fraction, pattern['lengths']))
if not 1 <= len(lengths) <= 2 or any(n <= 0 for n in lengths):
raise ValueError('patterns require one or two positive measure lengths')
meter = pattern.get('meter')
grouping = tuple(pattern.get('grouping', ()))
if meter == 'partial':
if len(lengths) != 1 or grouping:
raise ValueError('partial patterns require one measure and no grouping')
elif meter not in ('3/4', '4/4', '5/4') or lengths != (fractions.Fraction(meter[0]),) * 2:
raise ValueError('full patterns require an explicit supported meter and two complete bars')
if (meter == '5/4' and grouping not in ((3, 2), (2, 3))) or (meter != '5/4' and grouping):
raise ValueError('5/4 patterns require a 3+2 or 2+3 grouping')
# Validate musical events before any measure projection or ties.
previous, releases = fractions.Fraction(), {}
onsets = []
for row in pattern['events']:
onset, duration = fractions.Fraction(row['onset']), fractions.Fraction(row['duration'])
if onset < previous or duration <= 0 or onset + duration > sum(lengths):
raise ValueError('overlapping or out-of-bounds accompaniment pattern')
if onset.denominator > 2 or duration.denominator > 2:
raise ValueError('comping vocabulary uses a quarter/eighth grid')
if part == 'acoustic':
if row['layer'] != 'acoustic':
raise ValueError('acoustic pattern layers are assigned from the complete rhythm')
elif row['layer'] != 'electric':
raise ValueError('electric pattern must contain electric chord attacks')
if row.get('anticipate') and row['layer'] not in ('acoustic', 'electric'):
raise ValueError('only acoustic/electric chords can anticipate')
# Acoustic overlaps are checked after deterministic string-lane
# assignment, including neighboring figures in the source form.
lanes = () if part == 'acoustic' else (row['layer'],)
if any(releases.get(lane, fractions.Fraction()) > onset for lane in lanes):
raise ValueError('overlapping accompaniment attacks on the same strings')
releases.update({lane: onset + duration for lane in lanes})
previous = onset
onsets.append(onset)
if len(lengths) == 2:
signatures[part].add((meter, grouping, tuple(onsets)))
families = policy['voicing_families']
if not families.get('provenance'):
raise ValueError('guitar voicing families require provenance')
if part == 'electric':
if set(families['rank']) != {'drop-two', 'close-position', 'compact-open', 'compact-doubled', 'three-note-shell'} or any(type(v) is not int or not 0 <= v <= 2 for v in families['rank'].values()):
raise ValueError('invalid electric family ranking')
else:
for kind in ('triad', 'tetrad', 'extended'):
if set(families[kind]) != {'5/1', '5/5', '6/1', '6/5'}:
raise ValueError('acoustic families require root/fifth bass on both bass strings')
for orders in families[kind].values():
if not orders or any(len(o) != 3 or set(o) - {'root', 'fifth', 'guide', 'terminal', 'color'} for o in orders):
raise ValueError('invalid acoustic upper chord order')
if signatures['acoustic'] & signatures['electric']:
raise ValueError('acoustic/electric two-bar onset patterns must be distinct')
if not 1 <= value['pattern_candidates'] <= 64:
raise ValueError('accompaniment pattern budget must be 1–64')
entries = value.get('cells', value.get('patterns', value.get('colors', value.get('transformations', []))))
if len({v['id'] for v in entries}) != len(entries):
raise ValueError(f'{name}: duplicate vocabulary ID')
@@ -45,22 +107,54 @@ def _load(contents):
@functools.lru_cache(maxsize=1)
def _default():
return {'data': load(), 'role': '', 'settings': {}}
return CompositionContext.create(load())
def _freeze(value):
if isinstance(value, dict):
return types.MappingProxyType({key: _freeze(item) for key, item in value.items()})
if isinstance(value, list):
return tuple(_freeze(item) for item in value)
return value
@functools.lru_cache(maxsize=32)
def _frozen_json(contents):
return _freeze(json.loads(contents))
@dataclasses.dataclass(frozen=True)
class CompositionContext:
"""Owned, immutable, pickleable policy inputs with stable iteration order."""
resources_json: str
name: str = ''
settings_json: str = '{}'
@classmethod
def create(cls, resources, name='', settings=None):
return cls(json.dumps(resources), name, json.dumps(settings or {}))
def data(self, name):
return _frozen_json(self.resources_json)[name]
def role(self, name=None):
return {**self.data('roles')['roles'].get(name or self.name, {}), **_frozen_json(self.settings_json)}
def accompaniment(self, part):
value = self.data('accompaniment')
return {**{key: item for key, item in value.items() if key != 'instruments'}, **value['instruments'][part]}
def current():
return ACTIVE.get() or _default()
def data(name):
return current()['data'][name]
return current().data(name)
def accompaniment(part, resources=None):
if resources is None:
return current().accompaniment(part)
value = resources['accompaniment']
return {**{k: v for k, v in value.items() if k != 'instruments'}, **value['instruments'][part]}
def role(name=None):
active = current()
name = name or active['role']
return {**active['data']['roles']['roles'].get(name, {}), **active['settings']}
return current().role(name)
@contextlib.contextmanager
def using(resources, name, settings=None):
token = ACTIVE.set({'data': resources, 'role': name, 'settings': settings or {}})
token = ACTIVE.set(CompositionContext.create(resources, name, settings))
try:
yield
finally:
+1
View File
@@ -44,6 +44,7 @@ enum class sprite : std::size_t {
SETTINGS,
BACKING,
METRONOME,
SOLOS,
TEMPO,
BACK,
ON,
+2 -1
View File
@@ -25,13 +25,14 @@ struct remote_display_state {
std::bool_t error{};
std::array<std::char_t, 16> phase{};
std::bool_t metronome{};
std::bool_t solos{true};
std::bool_t editing{};
std::uint32_t bpm{120U};
std::array<std::char_t, vamp_protocol::title_id_size + 1U> title_image{};
std::uint32_t page{};
std::uint32_t pages{};
auto operator==(remote_display_state const &other) const -> std::bool_t {
return backing_available == other.backing_available && error == other.error && phase == other.phase && active == other.active && std::string_view{title} == other.title && std::string_view{part} == other.part && std::string_view{mode} == other.mode && std::string_view{focus} == other.focus && backing == other.backing && metronome == other.metronome && editing == other.editing && bpm == other.bpm && title_image == other.title_image && page == other.page && pages == other.pages;
return backing_available == other.backing_available && error == other.error && phase == other.phase && active == other.active && std::string_view{title} == other.title && std::string_view{part} == other.part && std::string_view{mode} == other.mode && std::string_view{focus} == other.focus && backing == other.backing && metronome == other.metronome && solos == other.solos && editing == other.editing && bpm == other.bpm && title_image == other.title_image && page == other.page && pages == other.pages;
}
};
+1 -1
View File
@@ -25,7 +25,7 @@ public:
auto refresh_connection() -> std::optional<vamp_zero::app_state>;
auto set_observer(std::function<void(vamp_zero::app_state)> observer) -> void;
auto finish_playback(std::uint64_t session, std::string error = {}, std::shared_ptr<vamp_zero::catalog const> catalog = {}) -> void;
auto update_performance(std::uint64_t session, std::size_t page, std::string phase, std::shared_ptr<vamp_zero::catalog const> catalog) -> void;
auto update_performance(std::uint64_t session, std::size_t page, std::string phase, std::shared_ptr<vamp_zero::catalog const> catalog, std::optional<std::size_t> measure = {}) -> void;
private:
auto pico_connected_locked() const -> std::bool_t;
auto snapshot_locked() const -> vamp_zero::app_state;
+8
View File
@@ -7,6 +7,14 @@
namespace vamp_zero {
namespace settings_row {
inline constexpr std::size_t backing = 1U;
inline constexpr std::size_t metronome = 2U;
inline constexpr std::size_t solos = 3U;
inline constexpr std::size_t tempo = 4U;
inline constexpr std::size_t count = 5U;
}
enum class menu_action_kind { ACTIVATE,
PREVIOUS,
NEXT,
+1
View File
@@ -12,6 +12,7 @@
namespace vamp_zero {
auto selected_group(vamp_zero::app_state const &state) -> vamp_zero::song_group const *;
auto visible_parts(vamp_zero::app_state const &state) -> std::vector<std::size_t>;
auto selected_part(vamp_zero::app_state const &state) -> vamp_zero::library_part const *;
auto active_part(vamp_zero::app_state const &state) -> vamp_zero::library_part const *;
auto active_pages(vamp_zero::app_state const &state) -> std::size_t;
+1
View File
@@ -19,6 +19,7 @@ auto prepare_performance(vamp_zero::score_document const &score, vamp_zero::app_
struct performance_position {
std::size_t page{};
std::string phase{};
std::optional<std::size_t> measure{};
};
auto performance_at(vamp_zero::score_document const &score, std::uint64_t frames, std::uint32_t bpm) -> vamp_zero::performance_position;
+5 -3
View File
@@ -28,8 +28,10 @@ private:
std::vector<entry> entries_{};
};
auto score_page_count(vamp_zero::score_document const &score) -> std::size_t;
auto validated_page_path(vamp_zero::score_document const &score, std::size_t index) -> std::expected<std::string, modulus::error>;
auto validate_score_page(vamp_zero::score_document const &score, std::size_t index) -> std::expected<void, modulus::error>;
auto score_page_count(vamp_zero::score_document const &score, bool playback = false) -> std::size_t;
auto validated_page_path(vamp_zero::score_document const &score, std::size_t index, bool playback = false) -> std::expected<std::string, modulus::error>;
auto validate_score_page(vamp_zero::score_document const &score, std::size_t index, bool playback = false) -> std::expected<void, modulus::error>;
auto page_rectangle(luma::rect bounds) -> luma::rect;
auto measure_highlight(vamp_zero::score_page const &page, std::optional<std::size_t> measure, luma::rect image) -> std::optional<luma::rect>;
}
+2 -1
View File
@@ -25,7 +25,8 @@ public:
// An already-running completion may overlap stop; capture its consumer weakly.
score_loader(boost::asio::any_io_executor executor,
std::function<boost::asio::awaitable<std::expected<vamp_zero::score_document, modulus::error>>(vamp_zero::score_reference)> load,
std::function<void()> completed = {});
std::function<void()> completed = {},
std::optional<boost::asio::any_io_executor> worker = {});
~score_loader();
score_loader(score_loader const &) = delete;
auto operator=(score_loader const &) -> score_loader & = delete;
+21
View File
@@ -3,6 +3,8 @@
#include <cstddef>
#include <cstdint>
#include <memory>
#include <optional>
#include <array>
#include <string>
#include <vector>
@@ -23,6 +25,18 @@ struct score_page {
std::size_t measure_count{};
vamp_zero::beat_position start_beat{};
vamp_zero::beat_position end_beat{};
struct measure_label {
std::size_t measure{};
std::array<double, 4> bounds{};
};
struct system {
std::size_t first_measure{};
std::size_t measure_count{};
vamp_zero::beat_position start_beat{};
vamp_zero::beat_position end_beat{};
std::vector<measure_label> labels{};
};
std::vector<system> systems{};
};
struct score_document {
@@ -39,7 +53,10 @@ struct score_document {
std::vector<vamp_zero::score_page> pages{};
std::string song_id{};
vamp_zero::beat_position duration{};
vamp_zero::beat_position sustain_start{};
std::uint32_t count_in_beats{4};
std::vector<vamp_zero::score_page> playback_pages{};
std::vector<vamp_zero::beat_position> measure_boundaries{};
};
struct library_part {
@@ -53,6 +70,8 @@ struct library_part {
std::size_t total_pages{};
std::string title_image{};
std::string song_id{};
std::size_t playback_pages{};
std::bool_t solos_enabled{true};
};
struct song_group {
@@ -105,6 +124,7 @@ struct app_state {
std::shared_ptr<vamp_zero::catalog const> catalog{vamp_zero::empty_catalog()};
vamp_zero::app_mode mode{vamp_zero::app_mode::MAIN_MENU};
vamp_zero::audio_state audio{};
std::bool_t solos_enabled{true};
std::size_t selected_main_menu_index{};
std::size_t selected_settings_index{1U};
std::size_t remembered_settings_index{1U};
@@ -115,6 +135,7 @@ struct app_state {
std::uint64_t score_session{};
std::uint64_t input_revision{};
std::bool_t pico_connected{false};
std::optional<std::size_t> active_measure{};
};
auto to_string(vamp_zero::app_mode value) -> std::string;
+2 -1
View File
@@ -4,6 +4,7 @@
#include <cstdint>
#include <functional>
#include <memory>
#include <optional>
#include <string>
#include <boost/asio/any_io_executor.hpp>
@@ -24,7 +25,7 @@ class score_loader;
class zero_ui {
public:
zero_ui(boost::asio::any_io_executor executor, luma::application_config config, vamp_zero::database_config database, std::string assets_path, std::function<void(vamp_protocol::page_command)> command_handler = {}, std::function<void(vamp_zero::menu_action)> menu_handler = {});
zero_ui(boost::asio::any_io_executor executor, luma::application_config config, vamp_zero::database_config database, std::string assets_path, std::function<void(vamp_protocol::page_command)> command_handler = {}, std::function<void(vamp_zero::menu_action)> menu_handler = {}, std::optional<boost::asio::any_io_executor> score_worker = {});
~zero_ui();
zero_ui(zero_ui const &) = delete;
auto operator=(zero_ui const &) -> zero_ui & = delete;
+2 -1
View File
@@ -76,13 +76,14 @@ auto vamp_pico::parse_remote_display_body(std::string_view body, vamp_pico::remo
return false;
}
std::copy(value.begin(), value.end(), parsed.phase.begin());
} else if (key == "backing" || key == "metronome" || key == "editing" || key == "error" || key == "backing_available") {
} else if (key == "backing" || key == "metronome" || key == "solos" || key == "editing" || key == "error" || key == "backing_available") {
if (value != "0" && value != "1") {
return false;
}
auto &flag = key == "backing_available" ? parsed.backing_available : key == "error" ? parsed.error
: key == "backing" ? parsed.backing
: key == "metronome" ? parsed.metronome
: key == "solos" ? parsed.solos
: parsed.editing;
flag = value == "1";
} else if (key == "bpm") {
+4 -4
View File
@@ -11,8 +11,8 @@ auto blend(std::uint16_t background, vamp_style::color foreground, std::uint8_t
}
auto label_sprite(std::string_view text) -> vamp_pico::sprite {
constexpr auto names = std::array<std::string_view, 10>{"Acoustic", "Electric", "Vocal", "Performance", "Settings", "Backing", "Metronome", "Tempo", "Back", "Main Menu"};
constexpr auto sprites = std::array{vamp_pico::sprite::ACOUSTIC, vamp_pico::sprite::ELECTRIC, vamp_pico::sprite::VOCAL, vamp_pico::sprite::PERFORMANCE, vamp_pico::sprite::SETTINGS, vamp_pico::sprite::BACKING, vamp_pico::sprite::METRONOME, vamp_pico::sprite::TEMPO, vamp_pico::sprite::BACK, vamp_pico::sprite::MAIN_MENU};
constexpr auto names = std::array<std::string_view, 11>{"Acoustic", "Electric", "Vocal", "Performance", "Settings", "Backing", "Metronome", "Solos", "Tempo", "Back", "Main Menu"};
constexpr auto sprites = std::array{vamp_pico::sprite::ACOUSTIC, vamp_pico::sprite::ELECTRIC, vamp_pico::sprite::VOCAL, vamp_pico::sprite::PERFORMANCE, vamp_pico::sprite::SETTINGS, vamp_pico::sprite::BACKING, vamp_pico::sprite::METRONOME, vamp_pico::sprite::SOLOS, vamp_pico::sprite::TEMPO, vamp_pico::sprite::BACK, vamp_pico::sprite::MAIN_MENU};
for (auto i = std::size_t{}; i < names.size(); ++i) {
if (names[i] == text) {
return sprites[i];
@@ -118,11 +118,11 @@ auto vamp_pico::render_scanline(std::array<std::uint16_t, vamp_pico::display_wid
if (state.editing && (y == 184U || y == 226U)) {
fill(64U, 256U, vamp_style::accent);
}
} else if (focus == "Backing" || focus == "Metronome") {
} else if (focus == "Backing" || focus == "Metronome" || focus == "Solos") {
if (focus == "Backing" && !state.backing_available) {
centered(sprite::UNAVAILABLE, 192U, vamp_style::muted);
} else {
centered((focus == "Backing" ? state.backing : state.metronome) ? sprite::ON : sprite::OFF, 192U, vamp_style::accent);
centered((focus == "Backing" ? state.backing : focus == "Metronome" ? state.metronome : state.solos) ? sprite::ON : sprite::OFF, 192U, vamp_style::accent);
}
}
}
+12 -7
View File
@@ -22,6 +22,7 @@
#include <boost/asio/post.hpp>
#include <boost/asio/signal_set.hpp>
#include <boost/asio/steady_timer.hpp>
#include <boost/asio/thread_pool.hpp>
#include <boost/asio/use_future.hpp>
#include <boost/json/object.hpp>
#include <boost/json/serialize.hpp>
@@ -180,10 +181,12 @@ auto validate_score_pages(boost::asio::any_io_executor executor, vamp_zero::conf
if (!score) {
co_return std::unexpected(score.error());
}
for (auto page = std::size_t{}; page < vamp_zero::score_page_count(*score); ++page) {
auto valid = vamp_zero::validate_score_page(*score, page);
if (!valid) {
co_return std::unexpected(valid.error());
for (auto playback : {false, true}) {
for (auto page = std::size_t{}; page < vamp_zero::score_page_count(*score, playback); ++page) {
auto valid = vamp_zero::validate_score_page(*score, page, playback);
if (!valid) {
co_return std::unexpected(valid.error());
}
}
}
co_return std::expected<void, modulus::error>{};
@@ -301,7 +304,7 @@ private:
}
if (loaded.document) {
if (auto position = audio_->position(*loaded.document, app.audio.tempo_bpm)) {
state_.update_performance(app.score_session, position->page, position->phase, app.catalog);
state_.update_performance(app.score_session, position->page, position->phase, app.catalog, position->measure);
}
}
} else if (vamp_zero::automatic(app.audio) && vamp_zero::selected_score_reference(app) && app.audio.playback_error.empty()) {
@@ -320,6 +323,7 @@ private:
auto run_headless(vamp_zero::config const &config, vamp_zero::control_state &state, vamp_zero::audio_controller *audio) -> std::expected<void, modulus::error> {
auto io = boost::asio::io_context{};
auto score_worker = boost::asio::thread_pool{1};
auto endpoint = make_server_endpoint(config);
if (!endpoint) {
return std::unexpected(endpoint.error());
@@ -333,7 +337,7 @@ auto run_headless(vamp_zero::config const &config, vamp_zero::control_state &sta
if (audio != nullptr) {
audio->sync(state.snapshot());
}
auto loader = std::make_shared<vamp_zero::score_loader>(io.get_executor(), [executor = io.get_executor(), database = config.database, assets = config.runtime.assets_path](vamp_zero::score_reference reference) { return vamp_zero::async_load_score(executor, database, std::move(reference), assets); });
auto loader = std::make_shared<vamp_zero::score_loader>(io.get_executor(), [executor = score_worker.get_executor(), database = config.database, assets = config.runtime.assets_path](vamp_zero::score_reference reference) { return vamp_zero::async_load_score(executor, database, std::move(reference), assets); }, std::function<void()>{}, score_worker.get_executor());
auto playback = playback_poll{io, state, audio, loader, config.runtime.assets_path, true};
auto heartbeat = write_heartbeat(config);
if (!heartbeat) {
@@ -352,11 +356,12 @@ auto run_headless(vamp_zero::config const &config, vamp_zero::control_state &sta
auto run_display(vamp_zero::config const &config, vamp_zero::control_state &state, vamp_zero::audio_controller *audio) -> std::expected<void, modulus::error> {
auto io = boost::asio::io_context{};
auto score_worker = boost::asio::thread_pool{1};
auto endpoint = make_server_endpoint(config);
if (!endpoint) {
return std::unexpected(endpoint.error());
}
auto ui = vamp_zero::zero_ui{io.get_executor(), config.display, config.database, config.runtime.assets_path, [&state](vamp_protocol::page_command command) { static_cast<void>(state.apply(command)); }, [&state](vamp_zero::menu_action action) { static_cast<void>(state.apply(action)); }};
auto ui = vamp_zero::zero_ui{io.get_executor(), config.display, config.database, config.runtime.assets_path, [&state](vamp_protocol::page_command command) { static_cast<void>(state.apply(command)); }, [&state](vamp_zero::menu_action action) { static_cast<void>(state.apply(action)); }, score_worker.get_executor()};
state.set_observer([&ui](vamp_zero::app_state app) {
auto status = ui.publish(std::move(app));
if (!status) {
+4 -2
View File
@@ -227,6 +227,7 @@ auto vamp_zero::control_state::finish_playback(std::uint64_t session, std::strin
} else {
state_.audio.playback_error = std::move(error);
state_.audio.phase = "Error";
state_.active_measure.reset();
}
updated = snapshot_locked();
observer = observer_;
@@ -280,7 +281,7 @@ auto vamp_zero::make_router(vamp_zero::control_state &state) -> ligo::service_ro
return router;
}
auto vamp_zero::control_state::update_performance(std::uint64_t session, std::size_t page, std::string phase, std::shared_ptr<vamp_zero::catalog const> catalog) -> void {
auto vamp_zero::control_state::update_performance(std::uint64_t session, std::size_t page, std::string phase, std::shared_ptr<vamp_zero::catalog const> catalog, std::optional<std::size_t> measure) -> void {
std::function<void(vamp_zero::app_state)> observer;
vamp_zero::app_state updated;
{
@@ -288,11 +289,12 @@ auto vamp_zero::control_state::update_performance(std::uint64_t session, std::si
if (!vamp_zero::automatic(state_.audio) || state_.mode != vamp_zero::app_mode::PERFORMANCE_SCORE || state_.score_session != session || state_.catalog != catalog || !state_.audio.playback_error.empty()) {
return;
}
if (state_.page_index == page && state_.audio.phase == phase) {
if (state_.page_index == page && state_.audio.phase == phase && state_.active_measure == measure) {
return;
}
state_.page_index = page;
state_.audio.phase = std::move(phase);
state_.active_measure = measure;
++state_.input_revision;
updated = snapshot_locked();
observer = observer_;
+19 -5
View File
@@ -95,7 +95,7 @@ auto valid_title_image(noto::sqlite_value const &value) -> std::bool_t {
}
auto compatible_catalog(noto::connection &connection) -> boost::asio::awaitable<std::bool_t> {
auto columns = std::vector<std::string_view>{"id", "title", "composer", "key_signature", "source_path", "source_json", "measure_count", "total_pages", "title_image", "part"};
auto columns = std::vector<std::string_view>{"id", "title", "composer", "key_signature", "source_path", "source_json", "measure_count", "total_pages", "title_image", "part", "solos_enabled"};
auto parameters = std::vector<noto::sqlite_value>{noto::sqlite_value{"songs"}};
auto selected = co_await connection.async_execute("SELECT name, type, \"notnull\", pk FROM pragma_table_info(?1) "
"WHERE EXISTS (SELECT 1 FROM pragma_table_list WHERE schema = 'main' AND name = ?1 AND type = 'table' AND strict = 1) ORDER BY cid",
@@ -110,7 +110,7 @@ auto compatible_catalog(noto::connection &connection) -> boost::asio::awaitable<
}
auto required = std::get_if<std::int64_t>(&row[2].value);
auto primary = std::get_if<std::int64_t>(&row[3].value);
auto type = index == 6U || index == 7U ? "INTEGER" : "TEXT";
auto type = index == 6U || index == 7U || index == 10U ? "INTEGER" : "TEXT";
if (text_value(row[0]) != columns[index] || text_value(row[1]) != type || required == nullptr || *required != 1 || primary == nullptr || *primary != (index == 0U ? 1 : 0)) {
co_return false;
}
@@ -138,6 +138,17 @@ auto vamp_zero::async_validate_database(boost::asio::any_io_executor executor, v
if (status && !(co_await compatible_catalog(connection))) {
status = std::unexpected(vamp_zero::make_error(vamp_zero::error_code::PERSISTENCE, "incompatible songs catalog: " + config.path + "; rebuild or reinstall Product Vamp"));
}
if (status) {
auto variants = co_await connection.async_execute(
"SELECT json_extract(source_json, '$.music.metadata.song_id'), part FROM songs "
"WHERE json_extract(source_json, '$.music.staves[0].arranged') = 1 "
"GROUP BY json_extract(source_json, '$.music.metadata.song_id'), part "
"HAVING (part IN ('Acoustic', 'Electric') AND (count(*) != 2 OR sum(solos_enabled) != 1)) "
"OR (part = 'Vocal' AND (count(*) != 1 OR sum(solos_enabled) != 1)) LIMIT 1");
if (!variants || !variants->rows.empty()) {
status = std::unexpected(vamp_zero::make_error(vamp_zero::error_code::PERSISTENCE, "missing or duplicate solo variants; rebuild or reinstall Product Vamp"));
}
}
if (status && integrity) {
auto checked = co_await connection.async_quick_check();
if (!checked || *checked != std::vector<std::string>{"ok"}) {
@@ -159,7 +170,7 @@ auto vamp_zero::async_load_catalog(boost::asio::any_io_executor executor, vamp_z
co_return std::unexpected(connected.error());
}
auto selected =
co_await connection.async_prepare("SELECT id, title, composer, part, source_path, measure_count, key_signature, total_pages, title_image, json_extract(source_json, '$.music.metadata.song_id') FROM "
co_await connection.async_prepare("SELECT id, title, composer, part, source_path, measure_count, key_signature, total_pages, title_image, json_extract(source_json, '$.music.metadata.song_id'), json_array_length(source_json, '$.presentation.playback_pages'), solos_enabled FROM "
"songs ORDER BY title, composer, part, id");
if (!selected) {
auto close = co_await connection.async_close();
@@ -180,8 +191,9 @@ auto vamp_zero::async_load_catalog(boost::asio::any_io_executor executor, vamp_z
break;
}
auto const &row = **next;
if (row.size() != 10U || count_value(row[5]) == 0U || count_value(row[7]) == 0U || !valid_title_image(row[8])) {
status = std::unexpected(vamp_zero::make_error(vamp_zero::error_code::PERSISTENCE, "invalid performance metadata"));
auto solos = row.size() == 12U ? std::get_if<std::int64_t>(&row[11].value) : nullptr;
if (!solos || (*solos != 0 && *solos != 1) || count_value(row[5]) == 0U || count_value(row[7]) == 0U || count_value(row[10]) == 0U || !valid_title_image(row[8])) {
status = std::unexpected(vamp_zero::make_error(vamp_zero::error_code::PERSISTENCE, "invalid performance metadata; regenerate score assets"));
break;
}
auto source = resolve_source_path(assets_path, text_value(row[4]));
@@ -200,6 +212,8 @@ auto vamp_zero::async_load_catalog(boost::asio::any_io_executor executor, vamp_z
.total_pages = count_value(row[7]),
.title_image = text_value(row[8]),
.song_id = text_value(row[9]),
.playback_pages = count_value(row[10]),
.solos_enabled = *solos == 1,
});
}
auto audio_assets = std::expected<std::vector<vamp_zero::audio_asset>, modulus::error>{};
+11 -11
View File
@@ -12,14 +12,11 @@ auto vamp_zero::menu_count(vamp_zero::app_state const &state) -> std::size_t {
case vamp_zero::app_mode::MAIN_MENU:
return 2U;
case vamp_zero::app_mode::SETTINGS_MENU:
return 4U;
return settings_row::count;
case vamp_zero::app_mode::PERFORMANCE_SONG_MENU:
return state.catalog->groups.size() + 1U;
case vamp_zero::app_mode::PERFORMANCE_PART_MENU:
if (auto group = selected_group(state)) {
return group->parts.size() + 1U;
}
return 1U;
return visible_parts(state).size() + 1U;
case vamp_zero::app_mode::PERFORMANCE_SCORE:
return 0U;
}
@@ -72,23 +69,26 @@ auto vamp_zero::menu_row(vamp_zero::app_state const &state, std::size_t row) ->
return {"Back", ""};
}
if (state.mode == vamp_zero::app_mode::SETTINGS_MENU) {
if (row == 1U) {
if (row == settings_row::backing) {
auto enabled = state;
enabled.audio.backing_enabled = true;
return {"Backing", vamp_zero::available_tempos(enabled).empty() ? "Unavailable" : state.audio.backing_enabled ? "On"
: "Off"};
}
if (row == 2U) {
if (row == settings_row::metronome) {
return {"Metronome", state.audio.metronome_enabled ? "On" : "Off"};
}
if (row == settings_row::solos) {
return {"Solos", state.solos_enabled ? "On" : "Off"};
}
return {"Tempo", std::to_string(state.audio.tempo_bpm) + " BPM"};
}
if (state.mode == vamp_zero::app_mode::PERFORMANCE_SONG_MENU) {
auto const &group = state.catalog->groups[row - 1U];
return {group.title, group.composer};
}
if (auto group = selected_group(state)) {
auto const &part = state.catalog->parts[group->parts[row - 1U]];
if (auto parts = visible_parts(state); row <= parts.size()) {
auto const &part = state.catalog->parts[parts[row - 1U]];
return {part.part, std::to_string(part.total_pages) + " pages"};
}
return {};
@@ -105,10 +105,10 @@ auto vamp_zero::apply_menu_action(vamp_zero::app_state state, vamp_zero::menu_ac
return state;
}
if (action.kind == vamp_zero::menu_action_kind::TEMPO_DOWN || action.kind == vamp_zero::menu_action_kind::TEMPO_UP) {
if (state.mode != vamp_zero::app_mode::SETTINGS_MENU || action.row != 3U) {
if (state.mode != vamp_zero::app_mode::SETTINGS_MENU || action.row != settings_row::tempo) {
return state;
}
state.selected_settings_index = 3U;
state.selected_settings_index = settings_row::tempo;
state.audio.tempo_editing = true;
state = apply_app_command(std::move(state), action.kind == vamp_zero::menu_action_kind::TEMPO_UP ? vamp_protocol::page_command::NEXT : vamp_protocol::page_command::PREVIOUS);
state.audio.tempo_editing = false;
+4 -4
View File
@@ -50,7 +50,7 @@ auto vamp_zero::menu_layout(luma::rect bounds, vamp_zero::app_state const &state
for (auto i = std::size_t{}; i < visible; ++i) {
auto row = first + i;
auto rectangle = luma::rect{bounds.x + 36.0F, bounds.y + 112.0F + static_cast<std::float32_t>(i) * 72.0F, bounds.width - 72.0F, 72.0F};
if (state.mode == vamp_zero::app_mode::SETTINGS_MENU && row == 3U) {
if (state.mode == vamp_zero::app_mode::SETTINGS_MENU && row == settings_row::tempo) {
add({rectangle.x + rectangle.width - 240.0F, rectangle.y + 12.0F, 48.0F, 48.0F}, vamp_zero::menu_action_kind::TEMPO_DOWN, row);
add({rectangle.x + rectangle.width - 64.0F, rectangle.y + 12.0F, 48.0F, 48.0F}, vamp_zero::menu_action_kind::TEMPO_UP, row);
}
@@ -92,7 +92,7 @@ auto vamp_zero::draw_header(luma::draw_context &context, luma::rect bounds, vamp
context.stroke_line({bounds.x + 36.0F, bounds.y + 79.0F}, {bounds.x + bounds.width - 36.0F, bounds.y + 79.0F}, 1.0F, vamp_zero::to_luma(vamp_style::rule));
draw_label(context, {bounds.x + 36.0F, bounds.y + 8.0F, 260.0F, 60.0F}, "Product Vamp", 30.0F, vamp_style::ink);
if (auto part = active_part(state); state.mode == vamp_zero::app_mode::PERFORMANCE_SCORE && part != nullptr) {
auto summary = state.audio.phase + " " + std::to_string(state.audio.tempo_bpm) + " BPM " + std::to_string(state.page_index + 1U) + "/" + std::to_string(part->total_pages);
auto summary = state.audio.phase + " " + std::to_string(state.audio.tempo_bpm) + " BPM " + (vamp_zero::automatic(state.audio) ? "Line " : "Page ") + std::to_string(state.page_index + 1U) + "/" + std::to_string(vamp_zero::active_pages(state));
draw_label(context, {bounds.x + 310.0F, bounds.y + 46.0F, bounds.width - 550.0F, 26.0F}, "Hold to exit", 15.0F, vamp_style::muted);
draw_label(context, {bounds.x + 310.0F, bounds.y + 7.0F, bounds.width - 550.0F, 38.0F}, state.audio.playback_error.empty() ? summary : state.audio.playback_error, 20.0F, state.audio.playback_error.empty() ? vamp_style::muted : vamp_style::danger);
}
@@ -130,9 +130,9 @@ auto vamp_zero::draw_menu(luma::draw_context &context, luma::rect bounds, vamp_z
draw_label(context, {row.x + 22.0F, row.y + (songs ? 4.0F : 12.0F), row.width - (songs ? 90.0F : 290.0F), songs ? 36.0F : 48.0F}, item.label, 26.0F, vamp_style::ink);
if (songs) {
draw_label(context, {row.x + 22.0F, row.y + 39.0F, row.width - 90.0F, 28.0F}, item.detail, 17.0F, vamp_style::muted);
} else if (settings && action.row < 3U) {
} else if (settings && action.row != settings_row::tempo) {
draw_label(context, {row.x + row.width - 245.0F, row.y + 12.0F, 145.0F, 48.0F}, item.detail, 20.0F, vamp_style::muted);
draw_switch(context, row, action.row == 1U ? state.audio.backing_enabled : state.audio.metronome_enabled);
draw_switch(context, row, action.row == settings_row::backing ? state.audio.backing_enabled : action.row == settings_row::metronome ? state.audio.metronome_enabled : state.solos_enabled);
} else {
draw_label(context, {row.x + row.width - (settings ? 181.0F : 250.0F), row.y + 12.0F, settings ? 112.0F : 180.0F, 48.0F}, item.detail, 20.0F, settings && state.audio.tempo_editing ? vamp_style::accent : vamp_style::muted);
}
+21 -5
View File
@@ -1,6 +1,7 @@
#include <algorithm>
#include <vamp_zero/navigation.hpp>
#include <vamp_zero/performance.hpp>
auto vamp_zero::selected_group(vamp_zero::app_state const &state) -> vamp_zero::song_group const * {
@@ -14,16 +15,31 @@ auto vamp_zero::selected_group(vamp_zero::app_state const &state) -> vamp_zero::
return &state.catalog->groups[index];
}
auto vamp_zero::visible_parts(vamp_zero::app_state const &state) -> std::vector<std::size_t> {
auto parts = std::vector<std::size_t>{};
if (auto group = selected_group(state); group != nullptr) {
for (auto index : group->parts) {
if (index < state.catalog->parts.size()) {
auto const &part = state.catalog->parts[index];
if (part.part == "Vocal" || part.solos_enabled == state.solos_enabled) {
parts.push_back(index);
}
}
}
}
return parts;
}
auto vamp_zero::selected_part(vamp_zero::app_state const &state) -> vamp_zero::library_part const * {
auto const *group = vamp_zero::selected_group(state);
if (state.selected_part_index == 0U || group == nullptr || group->parts.empty()) {
auto parts = visible_parts(state);
if (state.selected_part_index == 0U) {
return nullptr;
}
auto index = state.selected_part_index - 1U;
if (index >= group->parts.size()) {
if (index >= parts.size()) {
return nullptr;
}
auto part_index = group->parts[index];
auto part_index = parts[index];
return part_index < state.catalog->parts.size() ? &state.catalog->parts[part_index] : nullptr;
}
@@ -40,7 +56,7 @@ auto vamp_zero::active_part(vamp_zero::app_state const &state) -> vamp_zero::lib
auto vamp_zero::active_pages(vamp_zero::app_state const &state) -> std::size_t {
if (state.mode == vamp_zero::app_mode::PERFORMANCE_SCORE) {
auto const *part = vamp_zero::active_part(state);
return part == nullptr ? 0U : part->total_pages;
return part == nullptr ? 0U : (automatic(state.audio) ? part->playback_pages : part->total_pages);
}
return 0U;
}
+123 -32
View File
@@ -1,5 +1,6 @@
#include <algorithm>
#include <cstdint>
#include <cmath>
#include <expected>
#include <filesystem>
#include <string>
@@ -109,9 +110,21 @@ auto vamp_zero::parse_notation_document(std::string_view json, std::string sourc
return invalid("invalid performance duration or count-in");
}
document.duration = *duration;
auto sustain = performance.if_contains("sustain_start") ? vamp_zero::parse_beat(performance.at("sustain_start")) : duration;
if (!sustain || std::find(times.begin(), times.end(), rational(*sustain)) == times.end()) {
return invalid("invalid held-ending boundary");
}
document.sustain_start = *sustain;
for (auto i = std::size_t{}; i < measures->size(); ++i) {
auto marker = (*measures)[i].as_object().if_contains("ending_sustain");
auto ending = marker && marker->is_bool() && marker->as_bool();
if (ending != (times[i] >= rational(*sustain))) {
return invalid("held-ending measures disagree with performance timing");
}
}
auto const &clicks = performance.at("clicks").as_array();
auto click = std::size_t{};
for (auto measure = std::size_t{}; measure + 1 < times.size(); ++measure) {
for (auto measure = std::size_t{}; measure + 1 < times.size() && times[measure] < rational(*sustain); ++measure) {
for (auto beat = times[measure]; beat < times[measure + 1]; ++beat) {
if (click >= clicks.size()) {
return invalid("missing metronome beat");
@@ -129,42 +142,120 @@ auto vamp_zero::parse_notation_document(std::string_view json, std::string sourc
} catch (...) {
return invalid("missing performance timing; regenerate score assets");
}
auto cursor = std::size_t{};
for (auto const &item : *pages) {
if (!item.is_object()) {
return invalid("page must be an object");
try {
for (auto const &time : times) {
document.measure_boundaries.push_back({numerator(time).convert_to<std::uint64_t>(), denominator(time).convert_to<std::uint64_t>()});
}
auto path = string_field(item.as_object(), "path");
auto hash = string_field(item.as_object(), "sha256");
if (!path || !hash) {
return invalid("page requires path and sha256 strings");
auto const *playback = array_field(*presentation, "playback_pages");
if (!playback || playback->empty() || playback->size() > 10000) {
return invalid("missing playback pages; regenerate score assets");
}
auto relative = std::filesystem::path{*path};
if (path->empty() || path->find('\0') != std::string::npos || path->find('\\') != std::string::npos ||
relative.is_absolute() || relative.extension() != ".png" ||
std::any_of(relative.begin(), relative.end(), [](auto const &component) { return component == ".." || component == "."; })) {
return invalid("page paths must be safe relative PNG paths");
}
if (hash->size() != 64 || !std::all_of(hash->begin(), hash->end(), [](std::char_t ch) {
return (ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f');
})) {
return invalid("page sha256 must be 64 lowercase hexadecimal digits");
}
try {
auto first = item.at("first_measure").to_number<std::size_t>();
auto count = item.at("measure_count").to_number<std::size_t>();
auto start = vamp_zero::parse_beat(item.at("start_beat")), end = vamp_zero::parse_beat(item.at("end_beat"));
if (first != cursor + 1 || count == 0 || count > measures->size() - cursor || !start || !end || rational(*start) != times[cursor] || rational(*end) != times[cursor + count]) {
auto parse_page = [&](boost::json::value const &item) -> score_page {
if (!item.is_object()) {
throw std::invalid_argument("page must be an object");
}
auto path = string_field(item.as_object(), "path");
auto hash = string_field(item.as_object(), "sha256");
if (!path || !hash) {
throw std::invalid_argument("page requires path and sha256 strings");
}
auto relative = std::filesystem::path{*path};
if (path->empty() || path->find('\0') != std::string::npos || path->find('\\') != std::string::npos ||
relative.is_absolute() || relative.extension() != ".png" ||
std::any_of(relative.begin(), relative.end(), [](auto const &component) { return component == ".." || component == "."; })) {
throw std::invalid_argument("page paths must be safe relative PNG paths");
}
if (hash->size() != 64 || !std::all_of(hash->begin(), hash->end(), [](std::char_t ch) {
return (ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f');
})) {
throw std::invalid_argument("page sha256 must be 64 lowercase hexadecimal digits");
}
auto parse_range = [&](boost::json::value const &value, auto &range) {
range.first_measure = value.at("first_measure").to_number<std::size_t>();
range.measure_count = value.at("measure_count").to_number<std::size_t>();
auto a = range.first_measure, count = range.measure_count;
auto start = parse_beat(value.at("start_beat")), end = parse_beat(value.at("end_beat"));
if (!a || a > measures->size() || !count || count > measures->size() - (a - 1) || !start || !end || rational(*start) != times[a - 1] || rational(*end) != times[a + count - 1]) {
throw std::invalid_argument("invalid page/system timing or coverage");
}
range.start_beat = *start;
range.end_beat = *end;
};
auto result = score_page{};
result.path = std::move(*path);
result.sha256 = std::move(*hash);
parse_range(item, result);
auto const &systems = item.at("systems").as_array();
if (systems.empty() || systems.size() > 2) {
throw std::invalid_argument("invalid page systems");
}
auto cursor = result.first_measure;
for (auto const &value : systems) {
auto system = score_page::system{};
parse_range(value, system);
if (system.first_measure != cursor) {
throw std::invalid_argument("system gap or overlap");
}
auto const &labels = value.at("labels").as_array();
if (labels.size() != system.measure_count) {
throw std::invalid_argument("invalid measure label coverage");
}
for (auto const &label : labels) {
auto parsed = score_page::measure_label{};
parsed.measure = label.at("measure").to_number<std::size_t>();
auto const &bounds = label.at("bounds").as_array();
if (parsed.measure != cursor++ || bounds.size() != 4) {
throw std::invalid_argument("invalid measure label");
}
for (std::size_t k = 0; k < 4; ++k) {
parsed.bounds[k] = bounds[k].to_number<double>();
if (!std::isfinite(parsed.bounds[k])) {
throw std::invalid_argument("non-finite label bounds");
}
}
auto const &r = parsed.bounds;
if (!(4 <= r[0] && r[0] < r[2] && r[2] <= 972 && 4 <= r[1] && r[1] < r[3] && r[3] <= 480)) {
throw std::invalid_argument("invalid label bounds");
}
system.labels.push_back(parsed);
}
result.systems.push_back(std::move(system));
}
if (cursor != result.first_measure + result.measure_count) {
throw std::invalid_argument("systems disagree with page coverage");
}
return result;
};
auto cursor = std::size_t{1};
auto canonical = std::vector<score_page::system>{};
for (auto const &item : *pages) {
auto page = parse_page(item);
if (page.first_measure != cursor || (page.systems.size() != 2 && &item != &pages->back())) {
return invalid("invalid page measure coverage");
}
document.pages.push_back({std::move(*path), std::move(*hash), first, count, *start, *end});
cursor += count;
} catch (...) {
return invalid("missing page timing; regenerate score assets");
cursor += page.measure_count;
canonical.insert(canonical.end(), page.systems.begin(), page.systems.end());
document.pages.push_back(std::move(page));
}
}
if (cursor != measures->size()) {
return invalid("incomplete page measure coverage");
if (cursor != measures->size() + 1 || playback->size() != canonical.size()) {
return invalid("incomplete normal or playback coverage");
}
for (std::size_t i = 0; i < playback->size(); ++i) {
auto page = parse_page((*playback)[i]);
if (page.systems.size() != std::min(std::size_t{2}, canonical.size() - i)) {
return invalid("invalid playback system pairing");
}
for (std::size_t j = 0; j < page.systems.size(); ++j) {
auto const &a = canonical[i + j];
auto const &b = page.systems[j];
if (a.first_measure != b.first_measure || a.measure_count != b.measure_count) {
return invalid("playback changes system boundaries");
}
}
document.playback_pages.push_back(std::move(page));
}
} catch (std::exception const &error) {
return invalid(std::string{"invalid playback presentation: "} + error.what() + "; regenerate score assets");
}
document.id = std::filesystem::path{source_path}.stem().string();
document.source_path = std::move(source_path);
+25 -17
View File
@@ -18,9 +18,6 @@
namespace {
constexpr auto main_menu_performance = std::size_t{0};
constexpr auto settings_backing = std::size_t{1};
constexpr auto settings_metronome = std::size_t{2};
constexpr auto settings_tempo = std::size_t{3};
constexpr auto main_menu_count = std::size_t{2};
auto wrap_next(std::size_t value, std::size_t count) -> std::size_t {
@@ -70,15 +67,15 @@ auto clamp_state(vamp_zero::app_state state) -> vamp_zero::app_state {
state.catalog = vamp_zero::empty_catalog();
}
normalize_tempo(state);
state.selected_settings_index = std::min<std::size_t>(state.selected_settings_index, 3U);
state.remembered_settings_index = std::clamp<std::size_t>(state.remembered_settings_index, 1U, 3U);
state.selected_settings_index = std::min<std::size_t>(state.selected_settings_index, vamp_zero::settings_row::count - 1U);
state.remembered_settings_index = std::clamp<std::size_t>(state.remembered_settings_index, vamp_zero::settings_row::backing, vamp_zero::settings_row::count - 1U);
if (state.mode == vamp_zero::app_mode::SETTINGS_MENU && state.selected_settings_index != 0U) {
state.remembered_settings_index = state.selected_settings_index;
}
state.selected_main_menu_index = std::min(state.selected_main_menu_index, main_menu_count - 1U);
state.selected_song_index = std::min(state.selected_song_index, menu_row_count(state.catalog->groups.size()) - 1U);
if (auto const *group = selected_group(state); group != nullptr) {
state.selected_part_index = std::min(state.selected_part_index, menu_row_count(group->parts.size()) - 1U);
state.selected_part_index = std::min(state.selected_part_index, menu_row_count(visible_parts(state).size()) - 1U);
} else {
state.selected_part_index = 0U;
}
@@ -90,6 +87,7 @@ auto clamp_state(vamp_zero::app_state state) -> vamp_zero::app_state {
: vamp_zero::app_mode::PERFORMANCE_PART_MENU;
state.active_part_id.clear();
state.page_index = 0;
state.active_measure.reset();
}
if (state.mode != vamp_zero::app_mode::SETTINGS_MENU) {
state.audio.tempo_editing = false;
@@ -98,6 +96,10 @@ auto clamp_state(vamp_zero::app_state state) -> vamp_zero::app_state {
state.page_index = std::min(state.page_index, pages - 1U);
} else if (state.mode != vamp_zero::app_mode::PERFORMANCE_SCORE) {
state.page_index = 0;
state.active_measure.reset();
}
if (!automatic(state.audio)) {
state.active_measure.reset();
}
return state;
}
@@ -141,16 +143,18 @@ auto vamp_zero::apply_app_command(vamp_zero::app_state state, vamp_protocol::pag
state.audio.tempo_editing = false;
}
} else if (command == vamp_protocol::page_command::NEXT) {
state.selected_settings_index = wrap_next(state.selected_settings_index, 4U);
state.selected_settings_index = wrap_next(state.selected_settings_index, settings_row::count);
} else if (command == vamp_protocol::page_command::PREVIOUS) {
state.selected_settings_index = wrap_previous(state.selected_settings_index, 4U);
state.selected_settings_index = wrap_previous(state.selected_settings_index, settings_row::count);
} else if (state.selected_settings_index == 0U) {
state.mode = vamp_zero::app_mode::MAIN_MENU;
} else if (state.selected_settings_index == settings_backing) {
} else if (state.selected_settings_index == settings_row::backing) {
state.audio.backing_enabled = !state.audio.backing_enabled;
} else if (state.selected_settings_index == settings_metronome) {
} else if (state.selected_settings_index == settings_row::metronome) {
state.audio.metronome_enabled = !state.audio.metronome_enabled;
} else if (state.selected_settings_index == settings_tempo) {
} else if (state.selected_settings_index == settings_row::solos) {
state.solos_enabled = !state.solos_enabled;
} else if (state.selected_settings_index == settings_row::tempo) {
state.audio.tempo_editing = true;
}
return clamp_state(std::move(state));
@@ -172,16 +176,18 @@ auto vamp_zero::apply_app_command(vamp_zero::app_state state, vamp_protocol::pag
case vamp_zero::app_mode::PERFORMANCE_PART_MENU:
if (auto const *group = selected_group(state); group != nullptr) {
if (command == vamp_protocol::page_command::NEXT) {
state.selected_part_index = wrap_next(state.selected_part_index, menu_row_count(group->parts.size()));
state.selected_part_index = wrap_next(state.selected_part_index, menu_row_count(visible_parts(state).size()));
} else if (command == vamp_protocol::page_command::PREVIOUS) {
state.selected_part_index = wrap_previous(state.selected_part_index, menu_row_count(group->parts.size()));
state.selected_part_index = wrap_previous(state.selected_part_index, menu_row_count(visible_parts(state).size()));
} else if (state.selected_part_index == 0U) {
state.mode = vamp_zero::app_mode::PERFORMANCE_SONG_MENU;
state.active_part_id.clear();
state.page_index = 0;
state.active_measure.reset();
} else if (auto const *part = selected_part(state); part != nullptr) {
state.active_part_id = part->id;
state.page_index = 0;
state.active_measure.reset();
state.mode = vamp_zero::app_mode::PERFORMANCE_SCORE;
++state.score_session;
state.audio.playback_error.clear();
@@ -202,6 +208,7 @@ auto vamp_zero::apply_app_command(vamp_zero::app_state state, vamp_protocol::pag
state.mode = vamp_zero::app_mode::PERFORMANCE_PART_MENU;
state.active_part_id.clear();
state.page_index = 0;
state.active_measure.reset();
}
}
return clamp_state(std::move(state));
@@ -223,7 +230,7 @@ auto vamp_zero::remote_display_text(vamp_zero::app_state const &state) -> std::s
title_image = selected->title_image;
part = selected->part;
page = state.page_index + 1U;
pages = selected->total_pages;
pages = active_pages(state);
}
}
auto focus = menu_row(state, menu_selection(state)).label;
@@ -244,6 +251,7 @@ auto vamp_zero::remote_display_text(vamp_zero::app_state const &state) -> std::s
output << "backing_available=" << (vamp_zero::available_tempos(backing_state).empty() ? "0" : "1") << "\n";
output << "backing=" << (state.audio.backing_enabled ? "1" : "0") << "\n";
output << "metronome=" << (state.audio.metronome_enabled ? "1" : "0") << "\n";
output << "solos=" << (state.solos_enabled ? "1" : "0") << "\n";
output << "phase=" << sanitize_line_value(state.audio.phase) << "\n";
output << "error=" << (state.audio.playback_error.empty() ? "0" : "1") << "\n";
output << "bpm=" << state.audio.tempo_bpm << "\n";
@@ -264,7 +272,7 @@ auto vamp_zero::validate_app_state(vamp_zero::app_state const &state) -> std::ex
if (state.selected_main_menu_index >= main_menu_count) {
return std::unexpected(vamp_zero::make_error(vamp_zero::error_code::INVALID_ARGUMENT, "selected main menu index is out of range"));
}
if (state.selected_settings_index >= 4U) {
if (state.selected_settings_index >= settings_row::count) {
return std::unexpected(vamp_zero::make_error(vamp_zero::error_code::INVALID_ARGUMENT, "selected settings index is out of range"));
}
auto tempos = vamp_zero::available_tempos(state);
@@ -278,7 +286,7 @@ auto vamp_zero::validate_app_state(vamp_zero::app_state const &state) -> std::ex
return std::unexpected(vamp_zero::make_error(vamp_zero::error_code::INVALID_ARGUMENT, "selected performance song row is out of range"));
}
if (auto const *group = selected_group(state);
group != nullptr && state.selected_part_index >= menu_row_count(group->parts.size())) {
group != nullptr && state.selected_part_index >= menu_row_count(visible_parts(state).size())) {
return std::unexpected(vamp_zero::make_error(vamp_zero::error_code::INVALID_ARGUMENT, "selected performance part row is out of range"));
}
if (state.mode == vamp_zero::app_mode::PERFORMANCE_SCORE) {
@@ -286,7 +294,7 @@ auto vamp_zero::validate_app_state(vamp_zero::app_state const &state) -> std::ex
if (part == nullptr) {
return std::unexpected(vamp_zero::make_error(vamp_zero::error_code::INVALID_ARGUMENT, "performance score mode requires an active part"));
}
if (part->total_pages == 0U || state.page_index >= part->total_pages) {
if (active_pages(state) == 0U || state.page_index >= active_pages(state)) {
return std::unexpected(vamp_zero::make_error(vamp_zero::error_code::INVALID_ARGUMENT, "performance score page index is out of range"));
}
}
+6 -2
View File
@@ -201,10 +201,14 @@ auto vamp_zero::performance_at(vamp_zero::score_document const &score, std::uint
}
auto beat_frames = frames - count_in;
auto page = std::size_t{};
while (page + 1 < score.pages.size() && frame_at(score.pages[page + 1].start_beat, bpm) <= beat_frames) {
while (page + 1 < score.playback_pages.size() && frame_at(score.playback_pages[page + 1].start_beat, bpm) <= beat_frames) {
++page;
}
return {page, beat_frames < frame_at(score.duration, bpm) ? "Playing" : "Sustain"};
auto measure = std::size_t{1};
while (measure < score.measure_count && frame_at(score.measure_boundaries[measure], bpm) <= beat_frames) {
++measure;
}
return {page, beat_frames < frame_at(score.sustain_start, bpm) ? "Playing" : "Sustain", measure};
}
auto vamp_zero::validate_audio_assets(vamp_zero::catalog const &catalog, std::filesystem::path const &assets) -> std::expected<void, modulus::error> {
+38 -10
View File
@@ -43,8 +43,35 @@ auto vamp_zero::score_page_cache::size() const -> std::size_t {
return entries_.size();
}
auto vamp_zero::score_page_count(vamp_zero::score_document const &score) -> std::size_t {
return score.pages.size();
auto vamp_zero::score_page_count(vamp_zero::score_document const &score, bool playback) -> std::size_t {
return (playback ? score.playback_pages : score.pages).size();
}
auto vamp_zero::page_rectangle(luma::rect bounds) -> luma::rect {
auto scale = std::min(bounds.width / 976.0F, bounds.height / 484.0F);
return {.x = bounds.x + (bounds.width - 976.0F * scale) / 2.0F,
.y = bounds.y + (bounds.height - 484.0F * scale) / 2.0F,
.width = 976.0F * scale,
.height = 484.0F * scale};
}
auto vamp_zero::measure_highlight(vamp_zero::score_page const &page, std::optional<std::size_t> measure, luma::rect image) -> std::optional<luma::rect> {
if (!measure) {
return {};
}
for (auto const &system : page.systems) {
for (auto const &label : system.labels) {
if (label.measure == *measure) {
auto scale = image.width / 976.0F;
auto const &b = label.bounds;
return luma::rect{.x = image.x + static_cast<float>(b[0] - 3) * scale,
.y = image.y + static_cast<float>(b[1] - 3) * scale,
.width = static_cast<float>(b[2] - b[0] + 6) * scale,
.height = static_cast<float>(b[3] - b[1] + 6) * scale};
}
}
}
return {};
}
namespace {
@@ -54,11 +81,12 @@ struct page_file {
std::vector<std::uchar_t> bytes;
};
auto read_page(vamp_zero::score_document const &score, std::size_t index) -> std::expected<page_file, modulus::error> {
auto read_page(vamp_zero::score_document const &score, std::size_t index, bool playback) -> std::expected<page_file, modulus::error> {
auto fail = [&](std::string message) -> std::expected<page_file, modulus::error> {
return std::unexpected(vamp_zero::make_error(vamp_zero::error_code::INVALID_ARGUMENT, score.source_path + ": " + std::move(message) + "; regenerate score page assets"));
};
if (index >= score.pages.size()) {
auto const &pages = playback ? score.playback_pages : score.pages;
if (index >= pages.size()) {
return fail("page index outside score");
}
auto error = std::error_code{};
@@ -66,7 +94,7 @@ auto read_page(vamp_zero::score_document const &score, std::size_t index) -> std
if (error) {
return fail("score asset directory is missing");
}
auto path = std::filesystem::canonical(root / score.pages[index].path, error);
auto path = std::filesystem::canonical(root / pages[index].path, error);
if (error) {
return fail("score page is missing");
}
@@ -95,7 +123,7 @@ auto read_page(vamp_zero::score_document const &score, std::size_t index) -> std
hash.push_back(digits[byte >> 4U]);
hash.push_back(digits[byte & 15U]);
}
if (hash != score.pages[index].sha256) {
if (hash != pages[index].sha256) {
return fail("score page checksum mismatch");
}
return page_file{path.string(), std::move(bytes)};
@@ -103,16 +131,16 @@ auto read_page(vamp_zero::score_document const &score, std::size_t index) -> std
}
auto vamp_zero::validated_page_path(vamp_zero::score_document const &score, std::size_t index) -> std::expected<std::string, modulus::error> {
auto page = read_page(score, index);
auto vamp_zero::validated_page_path(vamp_zero::score_document const &score, std::size_t index, bool playback) -> std::expected<std::string, modulus::error> {
auto page = read_page(score, index, playback);
if (!page) {
return std::unexpected(page.error());
}
return std::move(page->path);
}
auto vamp_zero::validate_score_page(vamp_zero::score_document const &score, std::size_t index) -> std::expected<void, modulus::error> {
auto page = read_page(score, index);
auto vamp_zero::validate_score_page(vamp_zero::score_document const &score, std::size_t index, bool playback) -> std::expected<void, modulus::error> {
auto page = read_page(score, index, playback);
if (!page) {
return std::unexpected(page.error());
}
+11 -9
View File
@@ -6,6 +6,7 @@
#include <utility>
#include <boost/asio/co_spawn.hpp>
#include <boost/asio/bind_executor.hpp>
#include <boost/asio/post.hpp>
#include <vamp_zero/errors.hpp>
@@ -13,8 +14,8 @@
struct vamp_zero::score_loader::state : std::enable_shared_from_this<state> {
state(boost::asio::any_io_executor executor, std::function<boost::asio::awaitable<std::expected<vamp_zero::score_document, modulus::error>>(vamp_zero::score_reference)> load, std::function<void()> completed)
: executor{std::move(executor)}, load{std::move(load)}, completed{std::move(completed)} {}
state(boost::asio::any_io_executor executor, std::function<boost::asio::awaitable<std::expected<vamp_zero::score_document, modulus::error>>(vamp_zero::score_reference)> load, std::function<void()> completed, std::optional<boost::asio::any_io_executor> worker)
: executor{executor}, worker{worker.value_or(executor)}, load{std::move(load)}, completed{std::move(completed)} {}
static auto run(std::weak_ptr<state> weak, std::uint64_t generation, std::function<boost::asio::awaitable<std::expected<vamp_zero::score_document, modulus::error>>(vamp_zero::score_reference)> load, vamp_zero::score_reference reference) -> boost::asio::awaitable<std::expected<vamp_zero::score_document, modulus::error>> {
{
auto self = weak.lock();
@@ -63,15 +64,16 @@ struct vamp_zero::score_loader::state : std::enable_shared_from_this<state> {
auto start() -> void {
in_flight = true;
// post is required: co_spawn can enter inline on an already-running executor.
boost::asio::post(executor, [weak = weak_from_this(), generation = generation, load = load,
reference = *reference, executor = executor]() mutable {
boost::asio::co_spawn(executor, run(weak, generation, std::move(load), std::move(reference)),
[weak, generation](std::exception_ptr exception, std::expected<vamp_zero::score_document, modulus::error> loaded) {
boost::asio::post(worker, [weak = weak_from_this(), generation = generation, load = load,
reference = *reference, executor = executor, worker = worker]() mutable {
boost::asio::co_spawn(worker, run(weak, generation, std::move(load), std::move(reference)),
boost::asio::bind_executor(executor, [weak, generation](std::exception_ptr exception, std::expected<vamp_zero::score_document, modulus::error> loaded) {
finish(weak, generation, exception, std::move(loaded));
});
}));
});
}
boost::asio::any_io_executor executor;
boost::asio::any_io_executor worker;
std::function<boost::asio::awaitable<std::expected<vamp_zero::score_document, modulus::error>>(vamp_zero::score_reference)> load;
std::function<void()> completed;
std::mutex mutex{};
@@ -83,8 +85,8 @@ struct vamp_zero::score_loader::state : std::enable_shared_from_this<state> {
std::bool_t stopped{};
};
vamp_zero::score_loader::score_loader(boost::asio::any_io_executor executor, std::function<boost::asio::awaitable<std::expected<vamp_zero::score_document, modulus::error>>(vamp_zero::score_reference)> load, std::function<void()> completed)
: state_{std::make_shared<state>(std::move(executor), std::move(load), std::move(completed))} {}
vamp_zero::score_loader::score_loader(boost::asio::any_io_executor executor, std::function<boost::asio::awaitable<std::expected<vamp_zero::score_document, modulus::error>>(vamp_zero::score_reference)> load, std::function<void()> completed, std::optional<boost::asio::any_io_executor> worker)
: state_{std::make_shared<state>(std::move(executor), std::move(load), std::move(completed), std::move(worker))} {}
vamp_zero::score_loader::~score_loader() {
stop();
+22 -16
View File
@@ -23,6 +23,7 @@
#include <vamp_zero/navigation.hpp>
#include <vamp_zero/menu_view.hpp>
#include <vamp_zero/score.hpp>
#include <vamp_zero/performance.hpp>
#include <vamp_zero/score_loader.hpp>
#include <vamp_zero/touch_input.hpp>
@@ -46,8 +47,9 @@ struct score_draw_cache {
if (!score) {
return std::unexpected(vamp_zero::make_error(vamp_zero::error_code::UNAVAILABLE, "score no longer selected"));
}
auto found = std::find_if(score->pages.begin(), score->pages.end(), [&](auto const &page) { return page.path == name; });
auto path = vamp_zero::validated_page_path(*score, static_cast<std::size_t>(std::distance(score->pages.begin(), found)));
auto const &pages = playback ? score->playback_pages : score->pages;
auto found = std::find_if(pages.begin(), pages.end(), [&](auto const &page) { return page.path == name; });
auto path = vamp_zero::validated_page_path(*score, static_cast<std::size_t>(std::distance(pages.begin(), found)), playback);
if (!path) {
return std::unexpected(path.error());
}
@@ -60,30 +62,34 @@ struct score_draw_cache {
textures.clear();
document = score;
}
auto draw(luma::draw_context &context, luma::rect bounds, std::size_t index) -> std::expected<void, modulus::error> {
auto draw(luma::draw_context &context, luma::rect bounds, std::size_t index, bool automatic, std::optional<std::size_t> measure) -> std::expected<void, modulus::error> {
auto score = document.lock();
if (!score || index >= score->pages.size()) {
playback = automatic;
if (!score || index >= vamp_zero::score_page_count(*score, playback)) {
return std::unexpected(vamp_zero::make_error(vamp_zero::error_code::INVALID_ARGUMENT, "page index outside score"));
}
auto texture = textures.get(score->pages[index].path);
auto const &pages = playback ? score->playback_pages : score->pages;
auto texture = textures.get(pages[index].path);
if (!texture) {
return std::unexpected(texture.error());
}
if (index + 1 < score->pages.size()) {
auto next = textures.get(score->pages[index + 1].path);
if (index + 1 < pages.size()) {
auto next = textures.get(pages[index + 1].path);
if (!next) {
return std::unexpected(next.error());
}
}
auto scale = std::min(bounds.width / 976.0F, bounds.height / 484.0F);
auto page = luma::rect{.x = bounds.x + (bounds.width - 976.0F * scale) / 2.0F,
.y = bounds.y + (bounds.height - 484.0F * scale) / 2.0F,
.width = 976.0F * scale,
.height = 484.0F * scale};
auto page = vamp_zero::page_rectangle(bounds);
context.fill_rect(page, vamp_zero::to_luma(vamp_style::background));
context.draw_texture(**texture, {.x = 0, .y = 0, .width = 976, .height = 484}, page, {.r = 255, .g = 255, .b = 255, .a = 255});
if (playback) {
if (auto highlight = vamp_zero::measure_highlight(pages[index], measure, page)) {
context.stroke_rect(*highlight, std::max(1.0F, 1.5F * page.width / 976.0F), vamp_zero::to_luma(vamp_style::accent));
}
}
return {};
}
bool playback{};
vamp_zero::score_page_cache textures;
std::weak_ptr<vamp_zero::score_document const> document{};
};
@@ -108,7 +114,7 @@ auto draw_score(luma::draw_context &context, luma::rect bounds, vamp_zero::app_s
.width = bounds.width - 48.0F,
.height = bounds.height - 36.0F,
};
auto status = score_cache.draw(context, paper_bounds, state.page_index);
auto status = score_cache.draw(context, paper_bounds, state.page_index, vamp_zero::automatic(state.audio), state.active_measure);
loader.pages_prepared(loaded.document, status);
if (!status) {
vamp_zero::draw_label(context, {bounds.x + 36.0F, bounds.y + 38.0F, bounds.width - 72.0F, 48.0F}, "SCORE PAGE ERROR", 26.0F, vamp_style::danger);
@@ -178,13 +184,13 @@ private:
}
vamp_zero::zero_ui::zero_ui(boost::asio::any_io_executor executor, luma::application_config config, vamp_zero::database_config database, std::string assets_path, std::function<void(vamp_protocol::page_command)> command_handler, std::function<void(vamp_zero::menu_action)> menu_handler)
vamp_zero::zero_ui::zero_ui(boost::asio::any_io_executor executor, luma::application_config config, vamp_zero::database_config database, std::string assets_path, std::function<void(vamp_protocol::page_command)> command_handler, std::function<void(vamp_zero::menu_action)> menu_handler, std::optional<boost::asio::any_io_executor> score_worker)
: application_{std::make_shared<luma::application>(std::move(config))},
runtime_{std::make_shared<vamp_zero::ui_runtime>(executor, std::move(command_handler), std::move(menu_handler))},
score_loader_{std::make_shared<vamp_zero::score_loader>(executor, [executor, database = std::move(database), assets = std::move(assets_path)](vamp_zero::score_reference reference) { return vamp_zero::async_load_score(executor, database, std::move(reference), assets); }, [weak = std::weak_ptr{application_}] {
score_loader_{std::make_shared<vamp_zero::score_loader>(executor, [executor = score_worker.value_or(executor), database = std::move(database), assets = std::move(assets_path)](vamp_zero::score_reference reference) { return vamp_zero::async_load_score(executor, database, std::move(reference), assets); }, [weak = std::weak_ptr{application_}] {
if (auto application = weak.lock()) {
static_cast<void>(application->request_layout());
} })} {}
} }, score_worker)} {}
vamp_zero::zero_ui::~zero_ui() {
stop();
+5
View File
@@ -61,6 +61,11 @@ add_test(
# Complete deterministic phrase searches make this suite CPU-sensitive;
# leave headroom for concurrent asset generation on development machines.
set_tests_properties(product_vamp_generator PROPERTIES TIMEOUT 600)
add_test(
NAME product_vamp_assets
COMMAND ${VAMP_PYTHON_COMMAND} -m tests.asset_contract ${CMAKE_BINARY_DIR}/generated_assets
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
add_custom_target(check
COMMAND ${CMAKE_CTEST_COMMAND}
--test-dir ${CMAKE_BINARY_DIR}
+4
View File
@@ -12,3 +12,7 @@ def section_document(document, part_type):
with unittest.mock.patch('generator.arrange.form.full_arrangement_sections', return_value=[section]), generator.vocabulary.using(generator.vocabulary.load(), part_type + '_accompaniment'):
backing = generator.comping.Canonical(prepared, part_type, 'fixture') if part_type == 'acoustic' else None
return generator.arrange.generate._arrange_document(prepared, part_type, accompaniment=backing)
def melody_performance(document, part_type):
"""Isolate unchanged source melody from accompaniment/ending construction."""
return generator.arrange.generate._arrange_document(generator.parts.prepare_document(document), part_type, owned={'melody', 'vocal'})
+17
View File
@@ -0,0 +1,17 @@
"""Compare complete generated assets with the reviewed, pinned output baseline."""
import hashlib
import json
import pathlib
import sys
def verify(root):
expected = json.loads(pathlib.Path(__file__).with_name('fixtures').joinpath('assets_manifest.json').read_text())
actual = {path.relative_to(root).as_posix(): hashlib.sha256(path.read_bytes()).hexdigest()
for path in sorted(root.rglob('*')) if path.is_file() and path.relative_to(root).parts[0] != 'analysis'}
changed = sorted(name for name in expected.keys() | actual.keys() if expected.get(name) != actual.get(name))
if changed:
raise AssertionError('Generated assets differ from the reviewed baseline:\n' + '\n'.join(changed))
print(f'All {len(expected)} generated assets match the reviewed baseline.')
if __name__ == '__main__':
verify(pathlib.Path(sys.argv[1]))
+31 -3
View File
@@ -20,7 +20,7 @@ inline auto add_timing(boost::json::value &value) -> void {
music.at("metadata").as_object()["song_id"] = "fixture";
auto &measures = music.at("staves").as_array().front().at("measures").as_array();
auto &pages = value.at("presentation").at("pages").as_array();
while (measures.size() < pages.size()) {
while (measures.size() < 2 * pages.size() - 1) {
measures.push_back(boost::json::object{});
}
auto beat = [](std::size_t n) { return boost::json::object{{"numerator", n}, {"denominator", 1}}; };
@@ -32,15 +32,43 @@ inline auto add_timing(boost::json::value &value) -> void {
}
}
std::size_t cursor{};
auto systems = boost::json::array{};
for (std::size_t i = 0; i < pages.size(); ++i) {
auto count = i + 1 == pages.size() ? measures.size() - cursor : 1U;
auto count = i + 1 == pages.size() ? measures.size() - cursor : 2U;
auto &page = pages[i].as_object();
page["first_measure"] = cursor + 1;
page["measure_count"] = count;
page["start_beat"] = beat(cursor * 4);
page["end_beat"] = beat((cursor + count) * 4);
cursor += count;
auto members = boost::json::array{};
for (std::size_t j = 0; j < (i + 1 == pages.size() ? 1U : 2U); ++j) {
auto n = i + 1 == pages.size() ? count : 1U;
auto labels = boost::json::array{};
for (std::size_t k = 0; k < n; ++k) {
labels.push_back(boost::json::object{{"measure", cursor + k + 1}, {"bounds", boost::json::array{30 + k * 30, 70 + j * 220, 42 + k * 30, 82 + j * 220}}});
}
auto system = boost::json::object{{"first_measure", cursor + 1}, {"measure_count", n}, {"start_beat", beat(cursor * 4)}, {"end_beat", beat((cursor + n) * 4)}, {"labels", labels}};
members.push_back(system);
systems.push_back(system);
cursor += n;
}
page["systems"] = members;
}
auto playback = boost::json::array{};
for (std::size_t i = 0; i < systems.size(); ++i) {
auto page = pages[std::min(i / 2, pages.size() - 1)].as_object();
auto members = boost::json::array{systems[i]};
if (i + 1 < systems.size()) {
members.push_back(systems[i + 1]);
}
page["systems"] = members;
page["first_measure"] = members.front().at("first_measure");
page["start_beat"] = members.front().at("start_beat");
page["end_beat"] = members.back().at("end_beat");
page["measure_count"] = members.back().at("first_measure").to_number<std::size_t>() + members.back().at("measure_count").to_number<std::size_t>() - members.front().at("first_measure").to_number<std::size_t>();
playback.push_back(page);
}
value.at("presentation").as_object()["playback_pages"] = playback;
value.as_object()["performance"] = boost::json::object{{"song_id", "fixture"}, {"duration", beat(measures.size() * 4)}, {"count_in_beats", 4}, {"clicks", clicks}};
}
+693
View File
@@ -0,0 +1,693 @@
{
"backing/all_of_me_120.wav": "5104097be1d4ed0459dacedb61c2509effcfe0e26025b24574291a3467962f3d",
"backing/autumn_leaves_120.wav": "990e0218f9a09161a7a8a255bd1e64daf9fd01ac41935faa273228906775d016",
"catalog.db": "3bb66b4460363bbab987bae5a36e00ac1d6575deb9815b6b6ce07cb64cc83764",
"fonts/petaluma/OFL.txt": "5789e74d38031e93a4fbdb0a72392d1fd58cf15c29da3efa695c5099433ad0ce",
"fonts/petaluma/PetalumaScript.otf": "3b4be972cc9f857a7c1019ff49cd07cb083d5cc99058c0fb8563897fc75c32c8",
"pico/titles/42076b2eaa61a6fb408eeaec133b130967cf2c32981a9444dde6903ed7771fc8.mask": "42076b2eaa61a6fb408eeaec133b130967cf2c32981a9444dde6903ed7771fc8",
"pico/titles/8ed7df6668e9e4a24c148ba0fe9ac57209e504ca6a7e8a9b29179c097076ecae.mask": "8ed7df6668e9e4a24c148ba0fe9ac57209e504ca6a7e8a9b29179c097076ecae",
"print/all_of_me_acoustic.pdf": "210000b746f411e68b38c2be58dd8807d5da263799084708972a5a11ac9ba724",
"print/all_of_me_acoustic_improv.pdf": "882c2c5a855cf411d2d443de4661452edb0ec6e624c0ddc17b49f4fc07a3cd4a",
"print/all_of_me_electric.pdf": "83cd1c2780b64cc6194d42baf95e85c39ab68ba8789572f266310724ce16c403",
"print/all_of_me_electric_improv.pdf": "4642f8a81052502979ac867d40fb3248a7674f587939f5ecc9adaff3bae30fa4",
"print/all_of_me_vocal.pdf": "0ff78cb9d315dff93e7a88209610e959fa804c480cf63a8c4fb018a17c46ff66",
"print/autumn_leaves_acoustic.pdf": "f31537d21ea65ba410f0423fe98798f85e0a82600460c41eecc577f427617125",
"print/autumn_leaves_acoustic_improv.pdf": "d15456a77bdb4dfb5e78b0f3045b7a1d10ada056f03ee3994e6c98e310186419",
"print/autumn_leaves_electric.pdf": "11532f29ba9a7543fbd2c64917137fe4acf838a0fed801dedb09b0a3abd81aeb",
"print/autumn_leaves_electric_improv.pdf": "a0099729711f40367ff54a8554fcafd5aa2c3d529b4ccac882d8cb81026da830",
"print/autumn_leaves_vocal.pdf": "78cc66dd27c7088e196f917eb752266989de13c51361692195b6bb9765210001",
"songs/all_of_me_acoustic.json": "6ea2b9f38a902cd011e851c9e3c9db4ead9247b8f1809b4731865bf6e0398a73",
"songs/all_of_me_acoustic.pages/0001.png": "6948328c81efda868613241c6c87d620bb88a9d72c3503ca8741d8c4e2d3ab6e",
"songs/all_of_me_acoustic.pages/0002.png": "ec2a3460bf961c08a297d480eab25e08fb7cbd8070bb286dc0e6dbf44b63336e",
"songs/all_of_me_acoustic.pages/0003.png": "ea3cc201d6d524295313cfeefca133f09216729f8fb43b1f8af08fbc0fd9a0d5",
"songs/all_of_me_acoustic.pages/0004.png": "9973275f27d61dcca851b7f5c82549ffbb6098349f54daaa7849c8794fb0577a",
"songs/all_of_me_acoustic.pages/0005.png": "1e6822e6a69de4397fb4135a072ef4b13926d026ca82758933087aba5b84f95d",
"songs/all_of_me_acoustic.pages/0006.png": "4a4622622165b22df36bad0d9d68a57f2691809791fec92dcd4a96a2cb7ca504",
"songs/all_of_me_acoustic.pages/0007.png": "9455f6730e8ba0a423d90d42ab9ebbc7c152f178402d323f2e4d1c4b67bd920c",
"songs/all_of_me_acoustic.pages/0008.png": "5e677e76625a518f315a7231242cf264f847f2e4a912ac9e4d8519b095749d62",
"songs/all_of_me_acoustic.pages/0009.png": "547776c3ab3746361b1e86162631071e41b2ec5eb358cfa80fa94c94a9a73545",
"songs/all_of_me_acoustic.pages/0010.png": "ea4a777b604af4f7245071494c488bf015be41f39fa80b47615f76abf33610f2",
"songs/all_of_me_acoustic.pages/0011.png": "8e537c7d8f8adee6cbb841d12144e47bdd842d6a4d7483c650564abd4ee0d419",
"songs/all_of_me_acoustic.pages/0012.png": "ac8ad03632f908d4b3b3b353ac1e84678398e74fc9a776520fb73115cb290de5",
"songs/all_of_me_acoustic.pages/0013.png": "cad6681e2b17a48f17749077f7ed34064783e21fbf973b22d9603b5a45cf2c40",
"songs/all_of_me_acoustic.pages/0014.png": "b5ccd0b027437716e718d221b13ad2f5c8a78abb9c2b2dc290df43fe2f3e2928",
"songs/all_of_me_acoustic.pages/0015.png": "0025f0ee929c11e0cf8bf59746f37d57e191458650dd302839c9b0b78e5a8b9e",
"songs/all_of_me_acoustic.pages/0016.png": "c738908f9de0b2281e4c625e31efe3952cf8061f61e26127ecf9a50bfa1847b1",
"songs/all_of_me_acoustic.pages/0017.png": "f93aba261ea619c318388a24a216ccc8d3d520e30ed287cb335432fb66495ed8",
"songs/all_of_me_acoustic.pages/0018.png": "5fa1034c023b489f404385202666ab9ef9e91166ef31f5620eead3ae17dc05e7",
"songs/all_of_me_acoustic.pages/0019.png": "fabbb1223ea9f17c9d183169194b3000bf30aa9a69a29fc981ccdcbb61b9890f",
"songs/all_of_me_acoustic.pages/0020.png": "5a079a94509cd5f4dc3cd50af508f1c7228e0dc8f8e0f0756267a95a5619fce9",
"songs/all_of_me_acoustic.pages/0021.png": "9caa8383805c07dffce2fd778c024c5985ab13defaa14e52fbf2225ac4a44003",
"songs/all_of_me_acoustic.pages/0022.png": "5d2b3ad95807a0a32a60ad5c91cfe82e5e626e5d6eb5fea671e34bd558bd52f2",
"songs/all_of_me_acoustic.pages/0023.png": "2bd55dd9012c516acddbab0890de58108af1d9422e1682fbfd3cd2224487cf34",
"songs/all_of_me_acoustic.pages/0024.png": "aeb5d2adb983511335a0f0a23cf42e5ab6934d935c7416271da6d0471425d1cd",
"songs/all_of_me_acoustic.pages/0025.png": "d657e45864e01bcd4a757fdc1bd43fefca6276b549a45f0a733681466c57a448",
"songs/all_of_me_acoustic.pages/0026.png": "7b80fb28fa47446e2ec18be64271a8082c0a7c92d123c841bace99ea0ab02dfa",
"songs/all_of_me_acoustic.pages/0027.png": "05551515bf93f660e371c6f26798f8ab0560c7e84c404c11b5432575e53992cd",
"songs/all_of_me_acoustic.pages/0028.png": "700e865258c21b92353c9e764a3395adfc91c9045695586934e6766a543b88ff",
"songs/all_of_me_acoustic.pages/playback-0002.png": "0c7a810b3550add99456e5dbee8ed520f664d0a294d4e3672b2a68c898d4184c",
"songs/all_of_me_acoustic.pages/playback-0003.png": "36f47fe4c0fe860ac178ce2b12145b0eee52469655358798e4d7e3104594a212",
"songs/all_of_me_acoustic.pages/playback-0004.png": "0d38c62684a33cac380dda87782e806edd0b5931bffed72f2da069fecadfe75a",
"songs/all_of_me_acoustic.pages/playback-0005.png": "c42feaa1db61e48245a0577bbd4ab6fe7a80582e47dbac5e9fb804614767b779",
"songs/all_of_me_acoustic.pages/playback-0006.png": "6e604209db5d889f86c5395f22a69e649e37823c679b9e70d5d12a2168c64a87",
"songs/all_of_me_acoustic.pages/playback-0007.png": "e4d8fafd269de531e9c2a618ee58bfb5a5c505c710979f3c991249f601a65128",
"songs/all_of_me_acoustic.pages/playback-0008.png": "9d0a3fb48b0418140fc6f28503113e5b81b7485b6ffde675b5388a5b9b97757d",
"songs/all_of_me_acoustic.pages/playback-0009.png": "4d55c12934f9c9dcb611a2ae749d6cf7a7a65e000ffb21d38cb4341db0c90694",
"songs/all_of_me_acoustic.pages/playback-0010.png": "b774c61de2f7a49672cf3a912436914a5d0f3376c9941876ae7a376a26eae4c5",
"songs/all_of_me_acoustic.pages/playback-0011.png": "9f7f4ee1540252f8a066df53d46fd4e8ce0de6baafd55caaaec3fd52ddf46180",
"songs/all_of_me_acoustic.pages/playback-0012.png": "6318a460b8706400524f7b897c30f3e705b257fc93fb1ade7f947a963e4308c3",
"songs/all_of_me_acoustic.pages/playback-0013.png": "8705102e6d873d89a86532e9b6936c5fc9d1b8b6b40fd10e00eb741a872f8500",
"songs/all_of_me_acoustic.pages/playback-0014.png": "78b7a97b2c92872671150dfa0e9806e2bfba7eb88e56e1845b705612c88edae3",
"songs/all_of_me_acoustic.pages/playback-0015.png": "fb9bcdbad5c364f22270bfcc6439ccf090601791eabcc0eda7bb825d5b9133b5",
"songs/all_of_me_acoustic.pages/playback-0016.png": "f9bf1dfc3f01d8c16619ec5949f4ce8bd63b0a93f9b665cebb8bcb1587b6efa9",
"songs/all_of_me_acoustic.pages/playback-0017.png": "c1600567151bb1c9c55578a106a98981704937ba53bbe40707bf602a488f26bd",
"songs/all_of_me_acoustic.pages/playback-0018.png": "65451cc2753bc6ee09ff6f6c4c854e57000b69d5061fb0da6675b80299081ec3",
"songs/all_of_me_acoustic.pages/playback-0019.png": "d0af98812bc7a58eeb294886cf14e99a66d024c90cbe184c945ba3311d6ae4f4",
"songs/all_of_me_acoustic.pages/playback-0020.png": "5fa5e50c6700bdb7b4421e8990290d96d80bac66c10dac4eb2de90b60d485f37",
"songs/all_of_me_acoustic.pages/playback-0021.png": "cf34bbfb65e50ada490446fa0f3d716f12441456b90401f6651a69e64e1e73a9",
"songs/all_of_me_acoustic.pages/playback-0022.png": "9f602c971da1a3e83acaf586175d74ab7478dbf1e2cc40d43a1564d43c5e2a31",
"songs/all_of_me_acoustic.pages/playback-0023.png": "c96a191ca680d797010aaf5cc308e07b16a2e530eb6f33d77bf3afff074136d6",
"songs/all_of_me_acoustic.pages/playback-0024.png": "febe6a1cf13751148d0dc13654b871930ff3d8f01485e8710a86bed3b8891996",
"songs/all_of_me_acoustic.pages/playback-0025.png": "9214956d4c421ee6d2fec2bcf79e60765403cec91553cc090fd6009055e10a52",
"songs/all_of_me_acoustic.pages/playback-0026.png": "895353db4a1753e173777f2e25d193f3f7f9d45f48996a787f79a52a74cb100a",
"songs/all_of_me_acoustic.pages/playback-0027.png": "ecf1e302e95d53d4c4d3b788662d5f4bb93514ff2137e050dacd2145c2a65b2b",
"songs/all_of_me_acoustic.pages/playback-0028.png": "f8b60cf8bbc47057ddd1afa2cf192ef6b2b3cdcd2f00de8f2ffe30534f9de120",
"songs/all_of_me_acoustic.pages/playback-0029.png": "20ea66c6e6f0498fc41689068b984540667fe2aeaecf879ca808bcb8b7935222",
"songs/all_of_me_acoustic.pages/playback-0030.png": "c71c58b7dbeba20cf9416383dee295f4cc9a6f5faded58c209a0ff0d7c2a3ae5",
"songs/all_of_me_acoustic.pages/playback-0031.png": "63e3042cfc12f43311fa4a0dcddc06d42e48be2a1ee2e6a0d24deff80beb84cb",
"songs/all_of_me_acoustic.pages/playback-0032.png": "6224a1efd4c9a869b2b966dda98586f6d9fb4c3a198f13b30a24e612c848b998",
"songs/all_of_me_acoustic.pages/playback-0033.png": "a834362ba19691b432a97b4dd2176fca7b38799f9e53e9d6e535929d5de9b922",
"songs/all_of_me_acoustic.pages/playback-0034.png": "63038a745f7a1700383c43b90a1aabc67773c63fecb130788c8f5872f75722c2",
"songs/all_of_me_acoustic.pages/playback-0035.png": "47c8a0c7dbe5499e9e68ced5c05e09693a68f781dbf0c3d236a6dc1813b32780",
"songs/all_of_me_acoustic.pages/playback-0036.png": "e4c3f7c2cf5e49a612cbd508d0e90d63c3d3b9bbb5f91ee8b7be1229c1c6cc7a",
"songs/all_of_me_acoustic.pages/playback-0037.png": "0a6167c4e5d56da7ad37fcfb2fa47f0aa3b8b44b075b57dc720c7969a1a42113",
"songs/all_of_me_acoustic.pages/playback-0038.png": "ab65dcd046d6a5ad070551bdbdad3be2f6b526b529ea0d71807182890a0bd14b",
"songs/all_of_me_acoustic.pages/playback-0039.png": "4cac5dcecc44f5b2b5f49d445c76869ad6664742c1b2c4389b343075791c77ea",
"songs/all_of_me_acoustic.pages/playback-0040.png": "e5ba773de82e1062efc109626c6a744f7a8edb00d86625f67f8d6f4ad54de597",
"songs/all_of_me_acoustic.pages/playback-0041.png": "d0ddfa3fd259f8a091fa18746e83c475b3f64c25c9f2240f75e5fac1f27c4b92",
"songs/all_of_me_acoustic.pages/playback-0042.png": "76a8127d4d1b87bd3d62162559617951314379eaa75141ecc8ee8852b375d68f",
"songs/all_of_me_acoustic.pages/playback-0043.png": "a0959998579d3f2c24b96bcdd31c8fb69852b4810cd4d00fd3c65af10740dfcb",
"songs/all_of_me_acoustic.pages/playback-0044.png": "9f51830d3e1a16a85d8b66e19e6fcbc63d0eb07e29494b46576e7ecd3cacf7b4",
"songs/all_of_me_acoustic.pages/playback-0045.png": "eba577283878f5b0c100aa0c817005ca829ef01157027eaa5c11b9ccc2b302f3",
"songs/all_of_me_acoustic.pages/playback-0046.png": "e73079cf481a613ec1ef151382751ca995eaaa9300107915dbf86f2d7415b25d",
"songs/all_of_me_acoustic.pages/playback-0047.png": "ff53312206eca688db65d6f6b98cc07775219a8ade385df3388d9c5d665afeb8",
"songs/all_of_me_acoustic.pages/playback-0048.png": "18354efb13a24a3f9ca5742a4499febc6a245f6f4b459e6f7afef09dda15b514",
"songs/all_of_me_acoustic.pages/playback-0049.png": "105140cf22f8ded503d789c7ddb19583c331174562a511be833d78385eb8b27e",
"songs/all_of_me_acoustic.pages/playback-0050.png": "684ea0f0c8bc5d369f582e600ac96741b40f64b9caaffffd1c3facb5e35fe7a5",
"songs/all_of_me_acoustic.pages/playback-0051.png": "f40161362e8cee056b7873e5446078f2a45226c7792492310d893487ce36acf1",
"songs/all_of_me_acoustic.pages/playback-0052.png": "d64917e194675315569d598fe204286fe3925cb20eae7937e4a7d6532f2b8597",
"songs/all_of_me_acoustic.pages/playback-0053.png": "16958512a479d8f994193a2364ffad66f8c80a6b3e99fd22c90a4ef691421e23",
"songs/all_of_me_acoustic.pages/playback-0054.png": "ef2906bc9aefe132e5dc2295f49bef7d40513b8eda31f3a190e0f69650c39bfb",
"songs/all_of_me_acoustic.pages/playback-0055.png": "6167a172045169a8a17c302b8ff4fb0e88559a2bfd92805b4785af0e86200d23",
"songs/all_of_me_acoustic_improv.json": "75f4a689f6597000a4ebf64fdbc06ac482656a946e17eb30694eb3a52fa06663",
"songs/all_of_me_acoustic_improv.pages/0001.png": "c7c49c4a8bfb2121dfe20c4f2247bc9755fe9c32cfdd7604801d7f20138453b9",
"songs/all_of_me_acoustic_improv.pages/0002.png": "a17f7a1dd15222f91975e96b04db8e2637ba7179ec24ddbe84ee96a94691208e",
"songs/all_of_me_acoustic_improv.pages/0003.png": "964f31d3cc749bd4e1e4b97ad13e01fdb4b3d0e323c34a5c9702a723e33c29c6",
"songs/all_of_me_acoustic_improv.pages/0004.png": "0e176df36603fe9942f85912310e71aa5a4096cf66fd6cf605c5bea8d642c097",
"songs/all_of_me_acoustic_improv.pages/0005.png": "34eeb871dee2e999aeac440efe45cb22d57082bc072189927c027743d4638ff2",
"songs/all_of_me_acoustic_improv.pages/0006.png": "3c43857f7b81157a05fb56b379e734d6242fa2c089852ca2067e7cbb2de4e046",
"songs/all_of_me_acoustic_improv.pages/0007.png": "b33f37f12c71729e187a3ec136c855deacefbfba76b76958a69b69ed8ecbbf05",
"songs/all_of_me_acoustic_improv.pages/0008.png": "102e25d5120aa16d5d65d22fbfac6cc7de736d839f3170c82e169a45a554fda1",
"songs/all_of_me_acoustic_improv.pages/0009.png": "57aca2d015ab96464e6505c3dca2fe81e0089643fad02b83a56c48cc4f41b02d",
"songs/all_of_me_acoustic_improv.pages/0010.png": "1b1557405acdaa34af757b1fee11732444183171d618aef5bd16d27ed4ccb18d",
"songs/all_of_me_acoustic_improv.pages/0011.png": "ed1091121402a4a4969e77266ee1773b239dd6150a851f870131ec10c6b724ce",
"songs/all_of_me_acoustic_improv.pages/0012.png": "5334063c1cef8ec1174a15bd5674cff945b3c44a53d5affc99ca88c5c498db97",
"songs/all_of_me_acoustic_improv.pages/0013.png": "f7f4fda42b00536adc368dfeacbeefaaa91d12a5ca355d1eae11bae32820cd03",
"songs/all_of_me_acoustic_improv.pages/0014.png": "0663583f36229c054401b627b605718a311ba50feafcccc22e16fd2be45e8970",
"songs/all_of_me_acoustic_improv.pages/0015.png": "7436537b05d351d79c0f4d3d08a148f3308b2473dcbc6ede287070a31977f13e",
"songs/all_of_me_acoustic_improv.pages/0016.png": "3bf7576ba2c76e7b18a0c816ad9d8d4f1b1c526098ffe7b372764bf9e72f37a9",
"songs/all_of_me_acoustic_improv.pages/0017.png": "83fcd6e315ca2352d7a87b6f8568a2600c83e6a8dc5066552e246fab84aff4c7",
"songs/all_of_me_acoustic_improv.pages/0018.png": "73e241ab4f46390b1330c73ae5a9ee381424ebc90e6a6850a22a9a510a788cf9",
"songs/all_of_me_acoustic_improv.pages/0019.png": "7ca41c2f0cf291094903f9498ebcfd7be5b0dd6791eb5055b848eb8d824ae6f1",
"songs/all_of_me_acoustic_improv.pages/0020.png": "1f8e510e36d6e0c2f04ce8b645146508466e37f33fa67900c0075d4e6b91b953",
"songs/all_of_me_acoustic_improv.pages/0021.png": "9b916bd70b484d74d23e541c18c26edee7c6b22e863ce0476fd219fa70337711",
"songs/all_of_me_acoustic_improv.pages/0022.png": "15b2905bf32a8664145563814a35cd1e25b972258af627264473af59b4a630c4",
"songs/all_of_me_acoustic_improv.pages/0023.png": "1a06b5a190343bc34492751d759acd2ac1bfe4b1d3624eba27f502a0dc314f94",
"songs/all_of_me_acoustic_improv.pages/0024.png": "6f88afd2ab872dc5e63768b00e615391468fe8743a7d6cf026cf7c2098f8304d",
"songs/all_of_me_acoustic_improv.pages/0025.png": "3d07e915635f3b2379648c5f237260aaa79f0a52b04eb26866358f1ddc1c2977",
"songs/all_of_me_acoustic_improv.pages/0026.png": "783b05d3446fad225b0c0437769d3d97c75269ebe5c8cc44abb04cdeab886b7c",
"songs/all_of_me_acoustic_improv.pages/playback-0002.png": "f27560250db7468b7b84ac4807f9a1749cf4ed1f83d84ba38f872dae283f0ea0",
"songs/all_of_me_acoustic_improv.pages/playback-0003.png": "0c207781bfd393d5e6662a3b2bb41dab72d646df35f9c42ce25a877345e0f8d2",
"songs/all_of_me_acoustic_improv.pages/playback-0004.png": "3b7ea3048dfee3325a279c3870070d8a4cf67865e83dbe86b3fb94fc1c14850f",
"songs/all_of_me_acoustic_improv.pages/playback-0005.png": "5c1e1299f1a1c4cec7c6ff57ad3eb08ec542b4277beb7f74eb44b36ed580c8a2",
"songs/all_of_me_acoustic_improv.pages/playback-0006.png": "15cf982c4ce785cf8bb3cc55688e77aaa96ac36e974082687ba3a890adc0ad0e",
"songs/all_of_me_acoustic_improv.pages/playback-0007.png": "901da3d0710ce18ede6f86b5cf71210b5fc506030c16bf3f7688e78450c33d24",
"songs/all_of_me_acoustic_improv.pages/playback-0008.png": "faf91b35e258128a3950a6aa6c13673f92392c26a40d20b4d5b3d228f85a34b4",
"songs/all_of_me_acoustic_improv.pages/playback-0009.png": "bd1a9566c6b8ddcf1af70535b469641ab23fc3cb5b01c6123d3fef36656bdc84",
"songs/all_of_me_acoustic_improv.pages/playback-0010.png": "2e969b19d7d4f0d8fc3c59fa6120a06c7aec6d285563d6b5669fa81a6602b348",
"songs/all_of_me_acoustic_improv.pages/playback-0011.png": "12a5d0cdf4f95a3fd5fdf350f0778c818687ecc3de1f4d4f736ebe92f45e8e7b",
"songs/all_of_me_acoustic_improv.pages/playback-0012.png": "b0baba61fa2de21d458a028fa8c2cfecf1600f351a9b64d0b0466527ca5b09f4",
"songs/all_of_me_acoustic_improv.pages/playback-0013.png": "3caf610c9ddde72fa6a4b8c9e0bd579c725ff335f50936f2a0a93c981278edf1",
"songs/all_of_me_acoustic_improv.pages/playback-0014.png": "9199ee111c83c4c8b189148198343d1b60d7db7c1830741f57897a965dcb65a6",
"songs/all_of_me_acoustic_improv.pages/playback-0015.png": "a107b24904a78315d495fd468447adecfe155841f46d2d75ef652eb58992923c",
"songs/all_of_me_acoustic_improv.pages/playback-0016.png": "2dd3b1ab25a5f556e1514235b31be11d5bf0ab78a02353338c7c2e32cc9ad318",
"songs/all_of_me_acoustic_improv.pages/playback-0017.png": "26ba7c99fb7a33a9830cdd69396e2070b9d6b44ceca1e9ab373b24e3ccac5975",
"songs/all_of_me_acoustic_improv.pages/playback-0018.png": "c853af1449f47727ab075254e972e80f169ba91a8315b54b9acd151cced8d2aa",
"songs/all_of_me_acoustic_improv.pages/playback-0019.png": "2946ce5ee949fbfda621ecaf05bb85d86cce925c1523fe7bb9dd76e624e13e37",
"songs/all_of_me_acoustic_improv.pages/playback-0020.png": "cc373ffb93a9b7d2e18771636a6fe7937857b5c6e599be920447f0b4098408dc",
"songs/all_of_me_acoustic_improv.pages/playback-0021.png": "70644d156b969e9e6976d73a1ea19209b5d9ac68437df062156f1e3b85c2e985",
"songs/all_of_me_acoustic_improv.pages/playback-0022.png": "736e46edeab2ef667d3a0450719d1dd21ef68699b3fbd83bcfebfbe0dfede3a4",
"songs/all_of_me_acoustic_improv.pages/playback-0023.png": "b0cef1f6f70518ea6f05ea945a6a5f756647720595664009e2971bc6ebc8e9e9",
"songs/all_of_me_acoustic_improv.pages/playback-0024.png": "c345408406935c17f79be4f34ee1c68916d7d2047807a8b5f0c38889b84d6273",
"songs/all_of_me_acoustic_improv.pages/playback-0025.png": "1d009dec40021103bb3e0030908ab5c7ea14a660adf08939d8b8ce3bd8cd0a7f",
"songs/all_of_me_acoustic_improv.pages/playback-0026.png": "6e6dd0a31555f29496f7e4fc79b1f6b1d3ea107f493eacf7e4dd3e0090f22fbd",
"songs/all_of_me_acoustic_improv.pages/playback-0027.png": "39225282a6ffb530ae2a318d1112b906678d93ba9af7f8695c679267734090c4",
"songs/all_of_me_acoustic_improv.pages/playback-0028.png": "d50de4bce20b8cdeccdb9c694737c07cf4fe53874dce327f99dd717e54710453",
"songs/all_of_me_acoustic_improv.pages/playback-0029.png": "bb5d0f7b58046ee04ec14dfc127a3844b10322884fe8bb57c98e55e0b264ab21",
"songs/all_of_me_acoustic_improv.pages/playback-0030.png": "bbc16aaf034bf7743ebe6c4b8e7edd22ce1f7b4438513f94c3da653237f43545",
"songs/all_of_me_acoustic_improv.pages/playback-0031.png": "e7a3251349199da78744b72f51f044339ea0612fd569f19afe39b3dbc0c4832e",
"songs/all_of_me_acoustic_improv.pages/playback-0032.png": "ccbfe703cac72e634bab9d9be858df1579000e3aa03ee4aee3a894a463da7996",
"songs/all_of_me_acoustic_improv.pages/playback-0033.png": "513d82651223e0f5ca8027bc01a4a501aae14f10e178cef32f5512fce29d58d1",
"songs/all_of_me_acoustic_improv.pages/playback-0034.png": "bf0eb13dbf18b71a6bd0aaee8a2c227b6e607009dd3d630f7d7578a9206d2566",
"songs/all_of_me_acoustic_improv.pages/playback-0035.png": "d227f3fc1c6e10a65b577703d8c276e68305b04a8166b4d92b50299062043c9d",
"songs/all_of_me_acoustic_improv.pages/playback-0036.png": "19efab6757d036574e91cce3fc15030d3621e7aefffc6e9edf82eaff76443703",
"songs/all_of_me_acoustic_improv.pages/playback-0037.png": "773cfa95f23d05e3fe683a41af075bd1cc99ed139cf1f5ce691e678510563b28",
"songs/all_of_me_acoustic_improv.pages/playback-0038.png": "929c01e75c49f13dcf8857ba5509c8c0eac2f1d3b44ff2d7669d9028b54e7871",
"songs/all_of_me_acoustic_improv.pages/playback-0039.png": "8934ed0092867acdb7c08ff26eee743e05cb413e82b02f711443f8d44ed4d3bf",
"songs/all_of_me_acoustic_improv.pages/playback-0040.png": "f1d0e28048580ca2868eb49c6c5b217a358bb2679c7ab6c97d3883ff286c9659",
"songs/all_of_me_acoustic_improv.pages/playback-0041.png": "cc31eb3f579da316a3b78880dc820e06caf90945cc1f6b00889fc548d97d3bed",
"songs/all_of_me_acoustic_improv.pages/playback-0042.png": "25f0fc66d9a0386dffe3a293dd3f1fe11fd47d5dbb0f8039c650a376664f365b",
"songs/all_of_me_acoustic_improv.pages/playback-0043.png": "075014acd3f962a9b909076c813cdb9401dfcafca7d66024d9f5ca261df2370e",
"songs/all_of_me_acoustic_improv.pages/playback-0044.png": "04a74d576ea5a6b182829da6bf026dd5e1cb4bbdefcb6b5078a7e9839eccc4f9",
"songs/all_of_me_acoustic_improv.pages/playback-0045.png": "a625417a048e01fc861eb2077ff0af81e2298f8e3865a44ea0f75d8f7568c9cf",
"songs/all_of_me_acoustic_improv.pages/playback-0046.png": "b0065192d5536aab450561ca5a050646b3afef7f415750adede962d78721c4b7",
"songs/all_of_me_acoustic_improv.pages/playback-0047.png": "b584bc5df9b970429386ac9a4a23416eb4f9dd83559f033b406023ee7eb4c90d",
"songs/all_of_me_acoustic_improv.pages/playback-0048.png": "0b64db7e5b9841f7b5abd2974e6914e730e6a8a426f478d136085f472386d8f4",
"songs/all_of_me_acoustic_improv.pages/playback-0049.png": "c03651fb0bcc16b75576dcd45cc85c6658e893cc4058ab446a2532d227d3e4bd",
"songs/all_of_me_acoustic_improv.pages/playback-0050.png": "d24a1dc68cae5a26edadf42d74d620d70dd16952e939cf3328452802c8672e53",
"songs/all_of_me_acoustic_improv.pages/playback-0051.png": "127fa02816b447a5bdf521d7359259ab9859673aeb5dff61430e4253238a0cab",
"songs/all_of_me_acoustic_improv.pages/playback-0052.png": "a328cfae5ec1c913699de23712b198332c0744d80a77cb9bd6cbf679fd1e5e12",
"songs/all_of_me_electric.json": "89a7d561a036afd88cea9a01fe684e72ea5747d572c9fe6f25f4a82bcce642e4",
"songs/all_of_me_electric.pages/0001.png": "0ae7c59a905837a9fa374c381366e98933a1927238b99f0b21ca05f11e70671b",
"songs/all_of_me_electric.pages/0002.png": "96dbcc9e16014523b677921fa5d4996aac5dcb95cde220b6351fe2951ea28cc8",
"songs/all_of_me_electric.pages/0003.png": "7d5fb460c7ca8daeeb2a3456d60290c152d3579064cac25b61ad3a48c85626fb",
"songs/all_of_me_electric.pages/0004.png": "bcbfb4894d90fd9180706169bccebe2b03dea791c2d6c2b33609316163cb2dd5",
"songs/all_of_me_electric.pages/0005.png": "fb3bb43d1a9bd697b48a05358c29243399bbf2e5959567ca05e62bb9857631ec",
"songs/all_of_me_electric.pages/0006.png": "aecd14c4af630bdd6a222797737a85688257592c030d284b1bb22b182c3020e1",
"songs/all_of_me_electric.pages/0007.png": "f51dbe9fcc6c48944a01cb4cb3a7d39c0588d334486b5cf25e512118557af915",
"songs/all_of_me_electric.pages/0008.png": "7229055aa0b4d09e9d3a40ec8b1f74762f123a696136e5038a2511651e422166",
"songs/all_of_me_electric.pages/0009.png": "b7295f85e20ca762cd6dd6255574a09b7b8bb4c840c408c9782d8557cbf2df65",
"songs/all_of_me_electric.pages/0010.png": "c28b8d11c2bec34d7e7663c6ea2e69564d625e8d62d95ab5dc39d26d3228166a",
"songs/all_of_me_electric.pages/0011.png": "46f2e302beda292b2fd1dd90b21ee9b92ea49b470c85017cbc157e571657fa23",
"songs/all_of_me_electric.pages/0012.png": "2992e61b6e94042bf5417e520c96c6bb02311496a826126ef2d88d4da5e192a2",
"songs/all_of_me_electric.pages/0013.png": "168ade5a595abb0b75fe9046d24126772b4a901fd8ef5df1a1148dd4913166cb",
"songs/all_of_me_electric.pages/0014.png": "bb84c4eaf3e135693576e465533f4d0f01b8ed351fd81c07896045bc67e0e033",
"songs/all_of_me_electric.pages/0015.png": "3305bec3aa92cbb329e4014907fa8991d5007aaea1a80f5232ce8146628c593e",
"songs/all_of_me_electric.pages/0016.png": "e69f42716800aeb0155b26562898fa3c76454f2bca8a0b9353d845f8126e5c21",
"songs/all_of_me_electric.pages/0017.png": "9bf101895d2ee0137899fe8e8e925501b1a031007fda39cc0158f2abe170275c",
"songs/all_of_me_electric.pages/0018.png": "b203036635c6549522095b819e4c637de336620df966baab02b9e624b5982da1",
"songs/all_of_me_electric.pages/0019.png": "29d3ad6169b9f6f234cb9275602166678347f743f5f5b50f3990cd4bd8771bdf",
"songs/all_of_me_electric.pages/0020.png": "33923f139e31394d4e90c39362b8ff59193b975bd1f8196406dec8b1b3f57520",
"songs/all_of_me_electric.pages/0021.png": "cd1d09d884491b886b886f0af4e067397305258aae172f375cf366ad5d78133c",
"songs/all_of_me_electric.pages/0022.png": "7bb58dba686f58655bccba33162282f58043436e2d7945687d7345ce0a4d7288",
"songs/all_of_me_electric.pages/0023.png": "f14d7afa19d737b4c155640e27dfcae0da04fa6e7042668e11e8c35ed995c846",
"songs/all_of_me_electric.pages/playback-0002.png": "0571463f99b6828e503093c97de4475e8d07bc9445e591902355c8c17df9a642",
"songs/all_of_me_electric.pages/playback-0003.png": "cff0aac588d3f48c3990144c81137175ca3edcc1ba83c024b5da93ef9b9f3a3c",
"songs/all_of_me_electric.pages/playback-0004.png": "1b55b57f88aaf8bdd4ab37480b6b40f199298fc0b5a85bfab1a910c53aeabd1e",
"songs/all_of_me_electric.pages/playback-0005.png": "4d3da50a81fc1de48d13481ae046ecd7e4bb5fbae1f70729b9d09d35fd7e65fe",
"songs/all_of_me_electric.pages/playback-0006.png": "57da8bdc7dc21856527d9a050cc704969fa413b9eb9cd3f0229f6abe04d5c4d5",
"songs/all_of_me_electric.pages/playback-0007.png": "1af6916b5586c1efd197b33b79f5ee109074feb2939b2a7495e45a345c46c226",
"songs/all_of_me_electric.pages/playback-0008.png": "6f0c2f611e21592b90dd85d2ca7239ce48c2062a986d94859add9d3363f5de7a",
"songs/all_of_me_electric.pages/playback-0009.png": "2ceed3a3dd0c685c4cfdecd05e9b46d311fd371e10062b05101ffbf024a40621",
"songs/all_of_me_electric.pages/playback-0010.png": "eb8420fa5a47810931e5fea8ad8fd318bb4e5052802a4a2cdd82935c05154dc9",
"songs/all_of_me_electric.pages/playback-0011.png": "81c2e5e63db37e20e4fe6108831c62fd8b9d9261903d290abcca7042a86a2094",
"songs/all_of_me_electric.pages/playback-0012.png": "0f9e9e004de5224ac80ccd3eeff0196baabdc21d96ea58a6e3c453adaa46deac",
"songs/all_of_me_electric.pages/playback-0013.png": "1ed1bd390980f211f0b32a3a8803d66bf3d42ce60e7ac79241bb6b2ad2de0320",
"songs/all_of_me_electric.pages/playback-0014.png": "ea5db6c615f5bb477b5aaf3ab809103b43a4cd7f371664a47d79a53830fb134f",
"songs/all_of_me_electric.pages/playback-0015.png": "0486c9f8b6bf59da12b06854d7a6dc70b600fa4150370b540c20638e4ba4ca74",
"songs/all_of_me_electric.pages/playback-0016.png": "17665bacc2c021cac24da31525df4554c70005a6ff8b5f430917e2363b56605d",
"songs/all_of_me_electric.pages/playback-0017.png": "9854a78b18fc09b25d8e8218ce9b24eab9a227dbaeb82f48051bf9e39271a041",
"songs/all_of_me_electric.pages/playback-0018.png": "33c78c362b98e14b0c54caeac26a683ba8de28f39303476e1fd0a26443452277",
"songs/all_of_me_electric.pages/playback-0019.png": "529bedb15f3149d4e861d7f674b7155e7afaf11f6b4e430401da54015ef8bc49",
"songs/all_of_me_electric.pages/playback-0020.png": "c9499fb45efa55956bc60523efc44babac117ff7ab8aacb809d44ed2a947e5b9",
"songs/all_of_me_electric.pages/playback-0021.png": "0d0ca4378249adf58cc5afc4559713480e7eb633957126892f98a696edf4010f",
"songs/all_of_me_electric.pages/playback-0022.png": "14b63e52f24292bc4ccf99f446b15377aeb4bb0e54f092c3f5e8e6bf209b4cd0",
"songs/all_of_me_electric.pages/playback-0023.png": "9e2929dd2c9345c4fe73f18cda0eb8360e21e23ac687b6a07411922a32a2c5e9",
"songs/all_of_me_electric.pages/playback-0024.png": "cceb9cf59e79b1e773793da75036e315dbf1d675aef192537669f0db2250825d",
"songs/all_of_me_electric.pages/playback-0025.png": "28bb99dd21eba56d754f3d832d81213600e316a26c5ed51f09b98b119ddef4e5",
"songs/all_of_me_electric.pages/playback-0026.png": "51eb318f5a56b6b13d4c135abefb4c349124a09d3fd2ff5ba6878c76d989722b",
"songs/all_of_me_electric.pages/playback-0027.png": "c5e81c6df91e9d3ef2f088f2c0ece6bfb1aefa15a1a25463958f62778a2d7c54",
"songs/all_of_me_electric.pages/playback-0028.png": "1d3a113142e204567a87fc788da4b0467842e6ed8a3ceab763ca57dc0364cff9",
"songs/all_of_me_electric.pages/playback-0029.png": "3def7dcafe036b23443df159994db9329460ba4132c08533bd4b94abcaa4320b",
"songs/all_of_me_electric.pages/playback-0030.png": "e00305051391a58669a5c788e292371cf5d93bbdcde7dbbfdc1198eefbd8cba6",
"songs/all_of_me_electric.pages/playback-0031.png": "e0d4e72241ab0f3fd31633bc67627fa8637f54c33a213ca63823f508657b0005",
"songs/all_of_me_electric.pages/playback-0032.png": "a547016e4eff0898c224532490f4e83a4a84c87efb77e471c2b12e21a03a0809",
"songs/all_of_me_electric.pages/playback-0033.png": "707d0c281befeb8aa2a16e17575e1593bfd602ab723cf5ba3027bbb83d125653",
"songs/all_of_me_electric.pages/playback-0034.png": "ecbd44ae3f090dc915732d1706910612b5f8ccce10789eb7cc97465c6989a66d",
"songs/all_of_me_electric.pages/playback-0035.png": "dbc45491cb7c544273c38f427fa2a373ea27f067cc4395566685e1bdbac226d4",
"songs/all_of_me_electric.pages/playback-0036.png": "f239d52cbb9ebfa771cebe9adfa2a226f78910704294ed8dd6526c8af756410f",
"songs/all_of_me_electric.pages/playback-0037.png": "74677eb40b2953a482e4436d83d872b7f3c1e9d763a8f90b5aff63aa3f77ab98",
"songs/all_of_me_electric.pages/playback-0038.png": "08191dae0867e938afa09ade672bad6d6ad2f315974fa8fa31cc6047a9ade114",
"songs/all_of_me_electric.pages/playback-0039.png": "7f96060add92f5cc1def9eef2c024950309a33ab4c921edc196716698b7fb1b0",
"songs/all_of_me_electric.pages/playback-0040.png": "e9b6a19824218fd4beca0692079b418074377b325785e8a01e6716204f704f98",
"songs/all_of_me_electric.pages/playback-0041.png": "218b10759f29b917c541025802890025b2f301222c0d7c56555e1b1620f0d30d",
"songs/all_of_me_electric.pages/playback-0042.png": "d780c544f2131cc267120022657a7e7aa82666d508da28512869aa8d0997e2e3",
"songs/all_of_me_electric.pages/playback-0043.png": "b154b245a6143a9e803f7044d7bd8d0ff7728f50750f2bff97066067bcfada36",
"songs/all_of_me_electric.pages/playback-0044.png": "49609362f3f21c9777b8aefe8f8ad624069754fb88c804db038555fb95b7c384",
"songs/all_of_me_electric.pages/playback-0045.png": "de369edc2b4df96f39cb49f9441302bdbaea5e5dfac4dcbecc09fee437e81f8a",
"songs/all_of_me_electric_improv.json": "d3c571e1634e112179fefc23e2881c8d67b321357e48e3ffecfa74d844731edc",
"songs/all_of_me_electric_improv.pages/0001.png": "9ae7caf030d3f4694caab85bd7ae8eeff0ef72ea5aaad8f2cc183ab7b04d1bfe",
"songs/all_of_me_electric_improv.pages/0002.png": "1db713c064d04e69ae2721d8b22fb213707c31073c54de09a40a27bca5630797",
"songs/all_of_me_electric_improv.pages/0003.png": "2fed91a78a32d3c8510c8f4b3677d85094567b4e6d7824f11c8253697bfd3788",
"songs/all_of_me_electric_improv.pages/0004.png": "9e86cda45554b91d09356a82bc61194eca8e2e4bbab9b8f30d07d4813660ee23",
"songs/all_of_me_electric_improv.pages/0005.png": "8edeaf1afb9881cb6bb63703625ea8b140670ecf4adfe489df801719a36bc880",
"songs/all_of_me_electric_improv.pages/0006.png": "50f80d60a706fdf98e91c384535a5cbecf8ccf01911d81805863b82d5bb0a273",
"songs/all_of_me_electric_improv.pages/0007.png": "f1fb9c96a3ad22c61f83e0cc1fab090f0d92fc3925291be4d68625af96559d48",
"songs/all_of_me_electric_improv.pages/0008.png": "b0c51b473f67aa99ae4c52c94646537a48f66bff9973ae174672393e7f460be4",
"songs/all_of_me_electric_improv.pages/0009.png": "5af8c7d702f746467afc4631e1152ba5262100f6ddd433be4a3db68856d20913",
"songs/all_of_me_electric_improv.pages/0010.png": "4d0bf0b6aee6547752f7b900c7a85639720c3a3a7a36f1843d9b713304a2dc36",
"songs/all_of_me_electric_improv.pages/0011.png": "b3b4cf499dff0e50198a3561e84405f3cd96b3ec3c4583c44718edf7f2477ad4",
"songs/all_of_me_electric_improv.pages/0012.png": "c19ce7feb29ccb539d1714e4c9f3e9ced083f507c6e4963767be526512657e57",
"songs/all_of_me_electric_improv.pages/0013.png": "14fe1de03afb67a12e6c8952fea5f7298114f7859975e9371d64e9718d53f92c",
"songs/all_of_me_electric_improv.pages/0014.png": "96bd624b1460be30156ea0b6c38950fd790712c6da296ad873c987a11c9467c1",
"songs/all_of_me_electric_improv.pages/0015.png": "a2e04e9a32c05d036b1230131588f2888837f7eb972877d189c9acbdaa0568ae",
"songs/all_of_me_electric_improv.pages/0016.png": "12a521d04b7eed2173e1d0b4a1a302490e0b088c8c233854a73146c65008a21a",
"songs/all_of_me_electric_improv.pages/0017.png": "6d5c6b38ea5e0bf6c717ac041f2e0242010c0a4128838c125a243350422af44c",
"songs/all_of_me_electric_improv.pages/0018.png": "3c7113ee216704ab1294a0b1bcc6e2e2f781b7e2fa97211cad96bcf4128de0bc",
"songs/all_of_me_electric_improv.pages/0019.png": "078b008dc60f3b179a97967a67f811ab14a0b39d502c2ceab6473ecffd62776c",
"songs/all_of_me_electric_improv.pages/0020.png": "4704de6aabba302f204098fe952699d696419110fc12931fdcfd01581de1cb62",
"songs/all_of_me_electric_improv.pages/0021.png": "dce38beeffb026938a9fb97282a554bd43837a24ec0ae912458b504b18d96a98",
"songs/all_of_me_electric_improv.pages/playback-0002.png": "56cc0e04629e57b0ae89128b78cb55066f75f871575f08b3a6f04555fa31fb04",
"songs/all_of_me_electric_improv.pages/playback-0003.png": "264745b420fc459b1ef660a854b77bc201eadaaabae2260112e5826a4a2d1746",
"songs/all_of_me_electric_improv.pages/playback-0004.png": "6f3f5f4c4defdf42b4e159727217937668afe9b8c54d1834d633d77ba2bb78d1",
"songs/all_of_me_electric_improv.pages/playback-0005.png": "85a22f27df97fac5fe68ebbcb8eef3597b3fc4a6a3329da629b0355f7446359f",
"songs/all_of_me_electric_improv.pages/playback-0006.png": "a23a29e0fb69dc09671e05f47b5b915d2b8b48847059b4c48f4f971a8f2aaeb5",
"songs/all_of_me_electric_improv.pages/playback-0007.png": "fe9054ea77c6747e34a11022281ba2b2adc3989fbfe0fcd429c15738ac05502c",
"songs/all_of_me_electric_improv.pages/playback-0008.png": "db053bb59ccb5a4b301c68e008badbdbbd355c9d5d627e6b216a8f8b3bec1111",
"songs/all_of_me_electric_improv.pages/playback-0009.png": "b14fe42721dfd1db4959923b725b3af009d7a36e80aa285d427efd6d59478e18",
"songs/all_of_me_electric_improv.pages/playback-0010.png": "eaf5ee79cf71f5f94cf0a3f0caae0b77d079518ec53356a582e2a9e6f8bc34ce",
"songs/all_of_me_electric_improv.pages/playback-0011.png": "e84a47819a386df8e9649c88b35fc87d8505b466b354ec3aa93cebfda42e9ba2",
"songs/all_of_me_electric_improv.pages/playback-0012.png": "e0929ecf808e09dec70ecbcabc346050705b5ea024bcf43a0a04a297ebc4d5c7",
"songs/all_of_me_electric_improv.pages/playback-0013.png": "26f90ab441182907004f440a2c0e0a6c98b6fc4d59831aee67ddd72e57f1e83e",
"songs/all_of_me_electric_improv.pages/playback-0014.png": "9e3a85ec831d6e6c04c1587532454d600457f09df511bd6099c2760eacfb0947",
"songs/all_of_me_electric_improv.pages/playback-0015.png": "c9d2ae3d248cbf25a8677013e81c8e956a3dd6e0cd46428124a558345fa65a7e",
"songs/all_of_me_electric_improv.pages/playback-0016.png": "30d60c7a143742aa55ea0d6d6d9b2885fe66384f4b0f9b674fa1d08cacfdd51c",
"songs/all_of_me_electric_improv.pages/playback-0017.png": "669e85cc777fe281abe359e751eae6e51234a0a9cc84881bc161841bf9f2762d",
"songs/all_of_me_electric_improv.pages/playback-0018.png": "0528f5d62dc1c201b6c983a11ad4960e08daa3b36209f822813433412350bc69",
"songs/all_of_me_electric_improv.pages/playback-0019.png": "20410f0ea715f92f9463b9c9887330dd74185084e1fae21f79e4fe4e2c8720ca",
"songs/all_of_me_electric_improv.pages/playback-0020.png": "7e79616233f7b45237b9e4dfc378f764815b501d3c04e5df3925ff6db1299584",
"songs/all_of_me_electric_improv.pages/playback-0021.png": "309781a5de4cc2c964deb9dc5f4107fc36407e4d0174b94822bd92ebb3a8f214",
"songs/all_of_me_electric_improv.pages/playback-0022.png": "107f0253b24014d03a492be5c132e127a3679a8e2c0be884cd86a47d64921f61",
"songs/all_of_me_electric_improv.pages/playback-0023.png": "44159205003df9ea39dba9f53692f923cb92f74b36205aa2162cc1fde6d3caf7",
"songs/all_of_me_electric_improv.pages/playback-0024.png": "5675a342d78d7705a609dc53666c356fc829f4fc7d3598a84ba67dd586f8ea56",
"songs/all_of_me_electric_improv.pages/playback-0025.png": "bd3c1c8f123e1487568019ff17335c87fea6fb73e941469f4d13d5ee53aca9fd",
"songs/all_of_me_electric_improv.pages/playback-0026.png": "af3f08ee67aa2bf7afdfc06e98112997bf301b680ba00cf83ca0e2f9827442a8",
"songs/all_of_me_electric_improv.pages/playback-0027.png": "d4fef97de6a608516d46cf141cb35dfead1820270a83d62a76152f75117cb87b",
"songs/all_of_me_electric_improv.pages/playback-0028.png": "85ecb164aa2441c6b918a5e200e1a71ffaafa7ba1109176a2036509e685a175e",
"songs/all_of_me_electric_improv.pages/playback-0029.png": "06ca3710809f08c24584498768876458eb5b6259c9df40779c9172c2658a40ad",
"songs/all_of_me_electric_improv.pages/playback-0030.png": "437f429e6e44c20eb7831acb11e2965b67c306bfa340d83d1efbaadb17ab53c2",
"songs/all_of_me_electric_improv.pages/playback-0031.png": "8b042e7ae21ed38afbb5556cfaac8da266ab819a4e622a4fb078a463974338e8",
"songs/all_of_me_electric_improv.pages/playback-0032.png": "b81f08291112980a3d51560d5ae4dbc7550d0819271d48a2f623e59b80b6a85e",
"songs/all_of_me_electric_improv.pages/playback-0033.png": "6c64311516a7c70fd60dd91c9d59cd90c97de63d5fe78bd86d40b4dd45913b59",
"songs/all_of_me_electric_improv.pages/playback-0034.png": "e4009814e660f5c2baba72f887a0ede182abf57388a0ce5f0de077d72cac24dd",
"songs/all_of_me_electric_improv.pages/playback-0035.png": "14a7ec9942ee08e347284290b1a72655f346c1d4a140b3816867faade058374d",
"songs/all_of_me_electric_improv.pages/playback-0036.png": "5edaa8c587b4588c2609a5cd658de7a060f22a5fe9fcb3432bf0575daccdce78",
"songs/all_of_me_electric_improv.pages/playback-0037.png": "f2211592e1d074be423d4687c6589fe1d5dcbb8ea35d147aa091ebc1a732c993",
"songs/all_of_me_electric_improv.pages/playback-0038.png": "87039af6fca4f6be05a038a48d16ca416975a3165ca79049e36cadb76e42f302",
"songs/all_of_me_electric_improv.pages/playback-0039.png": "87cfdf7ddfc88f886d7fe52e9adb49f8eba011042da06a936294a7ef7828dad8",
"songs/all_of_me_electric_improv.pages/playback-0040.png": "ed59c8d9c4a3308bde22144de89ec6c572078d926681f24c96a30c020bf8d525",
"songs/all_of_me_electric_improv.pages/playback-0041.png": "4b7e52c00a843e7d597701928c8270d5c76f3ed5631691cae273fea606a27543",
"songs/all_of_me_electric_improv.pages/playback-0042.png": "a63fe816186fc5e118f96bd0bff5fd67be723e679e737ccb944ac94029970de4",
"songs/all_of_me_vocal.json": "589af69e505c0d1fe8341dde7daf36700408469f133d793aa051134ba668d8d7",
"songs/all_of_me_vocal.pages/0001.png": "5ff59ef10db0937c0dc132effc4f1ab761c6a4cdd9898aed1cbfc79c3ee126ad",
"songs/all_of_me_vocal.pages/0002.png": "8c737499c4e537b779160b86bf779de9b0a6771ece8f594af64ccd66e896f0d6",
"songs/all_of_me_vocal.pages/0003.png": "1ae152662e101117056704e7ccc92e7fadf546e4b0b68b11a463b8a778a2449e",
"songs/all_of_me_vocal.pages/0004.png": "d921899d08554455d72c71709d1110d808c5227de5cfc0c9aff68a168c7d4ecb",
"songs/all_of_me_vocal.pages/0005.png": "4c9fb6f70a887dceb7aca582122c7ba3d06a38431a37247b422e11a81f917e5e",
"songs/all_of_me_vocal.pages/0006.png": "a2792f1dc70d11d7f1b26f4c51686c8c6739844021e237c0d30f3604a2bc6306",
"songs/all_of_me_vocal.pages/0007.png": "ecdad2ac3c0a38bb0a553986b68fd64b6bce4dae7e2e654c5a152bc83abc61b9",
"songs/all_of_me_vocal.pages/0008.png": "0e619566374434cae278bd66344d94c80507e7477f678172da1f1cdf24bb65b9",
"songs/all_of_me_vocal.pages/0009.png": "8ef33bc47271fe389b3cc1c03be11e8689e8f5d1e3638a8af127adecbe90cde2",
"songs/all_of_me_vocal.pages/0010.png": "5f40610e4d3b143d3260b574c28c633b3a18e6e298fb3afe8adac95878bde3f7",
"songs/all_of_me_vocal.pages/0011.png": "32c857d8cdac61f34eb97031e27dce2f3b7d85f354e002c76c6947c07a49fb48",
"songs/all_of_me_vocal.pages/0012.png": "f6674afe2c6f4ead074491509ff12fc572656a73d894b170a7ef78ea0f83adce",
"songs/all_of_me_vocal.pages/0013.png": "886cee78fa1a4f5868a6adba5205d0843a6b9de0af42ea80e047c514b6ba0bc4",
"songs/all_of_me_vocal.pages/0014.png": "0e7d208b5da11cf6fd25b499ee138d865e63e85e2d9392ea9363623145b5677b",
"songs/all_of_me_vocal.pages/0015.png": "ba792e980325d694638ff90c7e9b87713de6b313c8ca2667e2889cd278581c42",
"songs/all_of_me_vocal.pages/playback-0002.png": "ad7fc6426e39e204109e3122bfa142d203abe60ba76a59b4df507e61745d923a",
"songs/all_of_me_vocal.pages/playback-0003.png": "4980352dee0600cad30f54ffba81577f4285248c7987df23aaa84f28544d02ed",
"songs/all_of_me_vocal.pages/playback-0004.png": "ad23b22d0fb931f098b88124fb6e48d2a1b03437f12944d8dbfbab9e5a6639e1",
"songs/all_of_me_vocal.pages/playback-0005.png": "065262ff6b758419107fd41f7b3956d996c325d6552a72f62281288c57ed29c1",
"songs/all_of_me_vocal.pages/playback-0006.png": "bd6cff39e52a41aab31473740a77357c47b2bb2b3dff42cfa794d3fe7888d7c1",
"songs/all_of_me_vocal.pages/playback-0007.png": "7cf0ebec216da49ab7385514a10e466656770d6668975840c8967f132414d2ce",
"songs/all_of_me_vocal.pages/playback-0008.png": "b4d59c19612d34d766cf2d76db71c6d6238d9afd6ce88f51dfebd117e6b1c5e1",
"songs/all_of_me_vocal.pages/playback-0009.png": "3d30c0180874fee2163821c4ef160cc5e134e5c5069f6e77ba542e40f5174bde",
"songs/all_of_me_vocal.pages/playback-0010.png": "5464485dc6c19973ac39dd3e573b9d7884cae22a6ef632f3c31e0e863635c7d6",
"songs/all_of_me_vocal.pages/playback-0011.png": "761aa1f8a8096046dabef1c1a30875205aec3309030cd60ae27938f51247f154",
"songs/all_of_me_vocal.pages/playback-0012.png": "0285ff0feffa0a61ec1a26b3eea54ca9156cba357847c74b1cfeac2084d454f4",
"songs/all_of_me_vocal.pages/playback-0013.png": "6177b132b398724081c814a65006ec205df52ea90403ed0c543e6ac9bdfdf2e8",
"songs/all_of_me_vocal.pages/playback-0014.png": "5fb997b60b54f808490b9fa0c6fedc396540f3b407c33b4562b54290daca4afe",
"songs/all_of_me_vocal.pages/playback-0015.png": "2a4a6345c63a9e6548519a3303d369bff76896eb1c4bfb40da42dc29fe08f710",
"songs/all_of_me_vocal.pages/playback-0016.png": "2ce1db668951fa36a075f119a423b1f50a1c4f346a29b1077cd55ecb31a5fa7b",
"songs/all_of_me_vocal.pages/playback-0017.png": "9f2677349e9d54f8de873e12399fb1f30a24d18e5f06c990aea2190cc41737e3",
"songs/all_of_me_vocal.pages/playback-0018.png": "25e7ab38426b3ce2c970c0c474aac7758f0f8c6a816fd0472a1a98ae4e37df9f",
"songs/all_of_me_vocal.pages/playback-0019.png": "f580eb1801c2ffad826c48a5a3c0b35c7513a8e4949723bba3f8f4522d03534e",
"songs/all_of_me_vocal.pages/playback-0020.png": "e6f23793d569cab0069560e88b1bc38e8fe44b1a11843d3a1a7639a33a6ab2fd",
"songs/all_of_me_vocal.pages/playback-0021.png": "a3cd07885f5ec333ba7ab3bf61807cb66263b7a4da4f1cc53e36717388a0cc13",
"songs/all_of_me_vocal.pages/playback-0022.png": "82529db7c06aa1ebe3bf5608287d2f4a6822337a5e1261d4687a6a9665478efc",
"songs/all_of_me_vocal.pages/playback-0023.png": "0b2c34c2524e5d437187d4bbf5cda395c55149081cc1478405a338d29af02ee3",
"songs/all_of_me_vocal.pages/playback-0024.png": "08d783cfb2d4bc09e83f3647a86455394f044dcce723ab9c5fa55063b222e844",
"songs/all_of_me_vocal.pages/playback-0025.png": "9c65d79d14f04bf05bee9de69c6c37a871e50aab635de797a91eb62fd81aac31",
"songs/all_of_me_vocal.pages/playback-0026.png": "79e87e2185d99c32aa753ac54068fabb698f81b16d6017ee7285f3b7c4d20054",
"songs/all_of_me_vocal.pages/playback-0027.png": "015cd105d6e5d2130393ced1268413b4929ff77231c30501b3a2748be6783b45",
"songs/all_of_me_vocal.pages/playback-0028.png": "7f3f16ced98698ef1034101976c05a1fb33b7c513057066b160b42eefacdbe64",
"songs/all_of_me_vocal.pages/playback-0029.png": "dfe0f2ea02945997653b0fac1b6d1355cd1c9a2cb5307f38ee59d51a54d4ec53",
"songs/all_of_me_vocal.pages/playback-0030.png": "98e2a6862eff212591ffc51d55c48ab65267e670bdb56d6c7ca6fb00ad750086",
"songs/autumn_leaves_acoustic.json": "424355c83269f205e784ac632d6dcedc3eb2c7ce784931f4176c12f63e48ef41",
"songs/autumn_leaves_acoustic.pages/0001.png": "754c7e2cd65dfe2b6a8d3ce3fc1612d12fe44dc86e38a857922a4a228b631d9c",
"songs/autumn_leaves_acoustic.pages/0002.png": "d29366df7962f098d633aae5ff729c0b6c72791929ced191f1faaed12177d361",
"songs/autumn_leaves_acoustic.pages/0003.png": "a8fb76be9e0d13e15798156a8995d71f86f7d700ac3f8e1ef38750ea23483ee3",
"songs/autumn_leaves_acoustic.pages/0004.png": "3fa3a9a415308448ad8036b2d50b45540dc6a5b5a083bf86342514077e9aecdf",
"songs/autumn_leaves_acoustic.pages/0005.png": "c374b7a4a99a1874e6265708e11677a99483f3fe65fb3ec6e27fbccde94e1416",
"songs/autumn_leaves_acoustic.pages/0006.png": "602365dadc0841c8afa7bcb61540cdaa74dfbfa41cce92c565feacea6b1a0708",
"songs/autumn_leaves_acoustic.pages/0007.png": "d060737953a4334f7e02774567e3329bf3c21638e84fc656366a00b28416ff43",
"songs/autumn_leaves_acoustic.pages/0008.png": "90467ef58fdd554143322b425cb16184f124451d0b4960300ae9560b11143072",
"songs/autumn_leaves_acoustic.pages/0009.png": "98d7404f052d8818f0aef807de2ab33f093de213f5b6d49cbbdd0e2323af77f0",
"songs/autumn_leaves_acoustic.pages/0010.png": "42fc2eda84a51df4bd7d6b718c9e1bf9ce6d0af15ff7da5c47ebc2bbe27a89a3",
"songs/autumn_leaves_acoustic.pages/0011.png": "613c1317b9c23e5e116ba540ab1100ba13c93b24967214b7391bd2f03c203a86",
"songs/autumn_leaves_acoustic.pages/0012.png": "41db70c7359e98f676755ecaa474056c10903ea95059e65baf472ac1eb9acdc4",
"songs/autumn_leaves_acoustic.pages/0013.png": "d96bc686639c9ee0426494e181b57380e5f2047625d11675ca6f92af160b297f",
"songs/autumn_leaves_acoustic.pages/0014.png": "c264b6642fd212d8adc626575f4654b749bdc7d3c1d1dd56334b38d123c1825f",
"songs/autumn_leaves_acoustic.pages/0015.png": "d2d4ed1be0e1e8727a70a39b0e399ed564cb035f77c7381fef804f0a0c6c158a",
"songs/autumn_leaves_acoustic.pages/0016.png": "cdc24eb58fc6b88043faf47196f7b73aeb79b2ac2d09a1a789616b6410d48500",
"songs/autumn_leaves_acoustic.pages/0017.png": "25bf2148154a3263a2b91d91bd7a57df7a0c043b56bedb220292e9151e28f411",
"songs/autumn_leaves_acoustic.pages/0018.png": "eca1c6d920f3a197aea1e6f132f0b8321b2fdad2d0f8b1a002f1ddca37a36e19",
"songs/autumn_leaves_acoustic.pages/0019.png": "ffeb3a3762731c8358e9c883dfaaac7b52c7f23dab70cd65f3cebc528073bd19",
"songs/autumn_leaves_acoustic.pages/0020.png": "fcc30ef29c1ec7ed77d7f09ed3ea80fd942d348d75c7e1f2e00dd053d936bd9d",
"songs/autumn_leaves_acoustic.pages/0021.png": "020fbb4263821a62d7071e753d3f0a169a9803056654044204bcbf354b787757",
"songs/autumn_leaves_acoustic.pages/0022.png": "dd384bc58ae72d4169b6c7705d62925292542411610f6d3419c183396da87183",
"songs/autumn_leaves_acoustic.pages/0023.png": "d7a90f05d1f6d24c9fdc1fe9e42b666eaafdc4d20252b24adb461e6f324450f2",
"songs/autumn_leaves_acoustic.pages/0024.png": "902970515962f0805fdfe17cc172808c82745aace0351397ad8936a5b1edefda",
"songs/autumn_leaves_acoustic.pages/0025.png": "f46b2b544d649b94367223a1a56d51312cd06870e7e5d14b76a141b30165da5f",
"songs/autumn_leaves_acoustic.pages/0026.png": "1a29bb232d414bcb77232fda368143a08a53178418f990704de4d7f3c8402967",
"songs/autumn_leaves_acoustic.pages/0027.png": "90cded4192545e2b8d9d022761838b81bd85c3ea46afc6b5ced5e52259e4de73",
"songs/autumn_leaves_acoustic.pages/0028.png": "91155a03c1040bc9965a23fb88aa53d278280c398e6912ea21d12cb491a0097a",
"songs/autumn_leaves_acoustic.pages/0029.png": "25d3344fec51974219e61433f1512e28fb1ccac1ba7cfcda07e302f6bae2f2de",
"songs/autumn_leaves_acoustic.pages/playback-0002.png": "bffdb1d0ca3ba782c4565f4ec972d53ab615960efbb978893a6f19b8b5c8753a",
"songs/autumn_leaves_acoustic.pages/playback-0003.png": "25f0f7fef9bff4d09130ba370f0dab0d96a74725a6af827804a38b6bf83d052e",
"songs/autumn_leaves_acoustic.pages/playback-0004.png": "09213305f712a25b2385e4809740d6c93dc3cf0516ce8f5613b097f6e384907b",
"songs/autumn_leaves_acoustic.pages/playback-0005.png": "da532299863e568041d9f4bce0454c5184e299d91faebe688279e2e957c8e70d",
"songs/autumn_leaves_acoustic.pages/playback-0006.png": "f7b73337b22763729001c9b14ae6b27040834a01467590d48eeeaae15f046a48",
"songs/autumn_leaves_acoustic.pages/playback-0007.png": "3e4292779a089c41cc74ed3f1470ac08c158e456be03a951f954ddbb4de6d2b7",
"songs/autumn_leaves_acoustic.pages/playback-0008.png": "03b2a528ed962672527b8fa298b66b76bfcdd0bf36c8b15fa515f8d12de61a08",
"songs/autumn_leaves_acoustic.pages/playback-0009.png": "de92a6cec2f58dfe1024388b6f4905e1f660af9019b780e58a8ca8642f1d0b0d",
"songs/autumn_leaves_acoustic.pages/playback-0010.png": "0e78d180cdc309e61b9e393d7522d40944cf0c5aeebf4e6bf6334b95b6962b13",
"songs/autumn_leaves_acoustic.pages/playback-0011.png": "df441f2d55c3c32616841bcf3995d97488a02cff602475c66ccaf370c604475a",
"songs/autumn_leaves_acoustic.pages/playback-0012.png": "9e343ff6b1d95923a3c4860aa32b98fe8a48be11b5fb21c4435a6435c5438932",
"songs/autumn_leaves_acoustic.pages/playback-0013.png": "c2b1b1c578f3fdae9175905b853633089bad0147dbfcc289cdef74e52e0b35f8",
"songs/autumn_leaves_acoustic.pages/playback-0014.png": "905c8ae0e609924cda4e78497ffe4a46fec0cb44363bb651de34b5aca16451ad",
"songs/autumn_leaves_acoustic.pages/playback-0015.png": "07fe45e2bdfec334026fee44f5821b3d69e1bb6a0e61ff7b166b12e0f5957e4d",
"songs/autumn_leaves_acoustic.pages/playback-0016.png": "28a1af1c818424a1ee32c00ab8c45561dce64eec59c63cd5a1eaf9a4fd55eb9a",
"songs/autumn_leaves_acoustic.pages/playback-0017.png": "0eca5f3fd5872c8980a1f1ac4098121ba3f2547bf9abef6f2535abf50107de08",
"songs/autumn_leaves_acoustic.pages/playback-0018.png": "459f07bfd907fd6362c3dca0659cdb95003df9dcea2295ddf9545c7c7721fc27",
"songs/autumn_leaves_acoustic.pages/playback-0019.png": "bfe63b5f93c18a6d6bb5a6f8ba86b370a98f56d4a6f6dd3dff6660eb31582234",
"songs/autumn_leaves_acoustic.pages/playback-0020.png": "37b035a6f150a55ee9f35a3b2010d67e46ef3a90a7671397c5a6bfab8253f224",
"songs/autumn_leaves_acoustic.pages/playback-0021.png": "88b954365fa56359cba4d730d6412d735001d430d036a4adb682195b207ac359",
"songs/autumn_leaves_acoustic.pages/playback-0022.png": "8d6052a868b6d54695e6b7fa9f6f85adc353aaca9cd2de925f2519d53fbbc62b",
"songs/autumn_leaves_acoustic.pages/playback-0023.png": "219749a6941a81728b7ce39077abc0c7b0794f739665548f82031636b2732894",
"songs/autumn_leaves_acoustic.pages/playback-0024.png": "9a7a71da600bf9b6f231d0d56dc80b7d0b15e9c4bbe5bb6ff8123753ef071a71",
"songs/autumn_leaves_acoustic.pages/playback-0025.png": "c0ad2a3df93c738a5cdce3fa28319cc4fd1135b51b376360b73ff2e9b2eaa0c2",
"songs/autumn_leaves_acoustic.pages/playback-0026.png": "6235f12598bd6436690668ee5d1a48e86efaf4c244d1365e0733def8d97310c4",
"songs/autumn_leaves_acoustic.pages/playback-0027.png": "2cdcb30b41d6434a84255fbf65d91e95221feb63c8eca1760a782153b4857493",
"songs/autumn_leaves_acoustic.pages/playback-0028.png": "ba0574a66af2bfcbcdaf4dec8c1db0838b5c02004924ed821ef79d46b49d7319",
"songs/autumn_leaves_acoustic.pages/playback-0029.png": "27df7f3ff5e63442c7b3e863234ca942ed543f25af8e63d57c46687159338407",
"songs/autumn_leaves_acoustic.pages/playback-0030.png": "e1b00c1bb79842378c75ca38c35a9649e5c6ad6d7c59634c599fe972646bdffe",
"songs/autumn_leaves_acoustic.pages/playback-0031.png": "2a3d6dc83778cbee4a030e8f31950601053e4e38374594fef99d217117af9eff",
"songs/autumn_leaves_acoustic.pages/playback-0032.png": "fc58891c4bcd5fba3f2779168f74f1b42ee00f398e70464439a854c81dcc2bb5",
"songs/autumn_leaves_acoustic.pages/playback-0033.png": "b39f14f4e578f5e1f70e33b08893c16c55e6135a8673a03b49d2a0d48036f796",
"songs/autumn_leaves_acoustic.pages/playback-0034.png": "e6de7b9f74dad8238677bf80b6feb79152cd7099fc1a3cdc5cb6ad18aca17a18",
"songs/autumn_leaves_acoustic.pages/playback-0035.png": "4d680115e003c1f185373219e2e2304f3a08b90580d08d4fba0b8fc2434b6015",
"songs/autumn_leaves_acoustic.pages/playback-0036.png": "89031463dac17a1e7fdbb441f0f38691fe92191972a9f703cd31354b5bcb1a5a",
"songs/autumn_leaves_acoustic.pages/playback-0037.png": "dd8daaba5115059a825716751244ba01a241875279c2869de547ac57abbf49ac",
"songs/autumn_leaves_acoustic.pages/playback-0038.png": "fc7d19006d9669516acc7ccc9031c0d04832606f83eeaf98e9af85646b208349",
"songs/autumn_leaves_acoustic.pages/playback-0039.png": "eebc63368ffbdb3260300afcb40a5168ee819717debd597bc495943307d0b7c8",
"songs/autumn_leaves_acoustic.pages/playback-0040.png": "c87d70fec0ac36ae8928a740463d5c8cac0d442195cee1f0d168781ece3d88ea",
"songs/autumn_leaves_acoustic.pages/playback-0041.png": "dce765fa661c3a54efd6862afa9c3c8283b8b2e736e10663af2a49883b73135f",
"songs/autumn_leaves_acoustic.pages/playback-0042.png": "9b401790ef6e565356cd46ce4aa1de9ab17718007e1e0c9a4541fbb49e8e20c1",
"songs/autumn_leaves_acoustic.pages/playback-0043.png": "6c5e6435f14f0834ddb2ae5be27dc61b7e7bd700c49cb106ac85c7bf7e880c1d",
"songs/autumn_leaves_acoustic.pages/playback-0044.png": "b1ce382ffc6fee9d00f3b4c67053e903410188383e33d7c917a7cbf3c90cd814",
"songs/autumn_leaves_acoustic.pages/playback-0045.png": "b0253732b05f2be0819dbd95bbcca9bff30ff20c33f1164b6a15eaf7ec7108b2",
"songs/autumn_leaves_acoustic.pages/playback-0046.png": "04ea04828174e1bc6c0455229dc93cf4c35f01557b81be1c9fc4e8645d6e407a",
"songs/autumn_leaves_acoustic.pages/playback-0047.png": "f355eda7e49bcc7732ea0858a0c08fe157dd3033cc2b6fe8471baf60928f6717",
"songs/autumn_leaves_acoustic.pages/playback-0048.png": "e4f847bbff2fa32a46613c9d3586aa0e3daca5712ed595239cc9113157d477c9",
"songs/autumn_leaves_acoustic.pages/playback-0049.png": "f63191d92ecf372174c08a00ea67f02ec5f6bf21d40671b917610155c37d55b5",
"songs/autumn_leaves_acoustic.pages/playback-0050.png": "da0b31851ba8c79a653f6a091f53037023b05d36042119770b9c90c0409916fc",
"songs/autumn_leaves_acoustic.pages/playback-0051.png": "4f4107df9c96c2af56d69feee9371bd53a802915c379b2bd1f4afcda389c8c27",
"songs/autumn_leaves_acoustic.pages/playback-0052.png": "f0e3d7865a03d32929334896ce4558ab82bc0911a20b4b567f18f90825c6d16e",
"songs/autumn_leaves_acoustic.pages/playback-0053.png": "30e05e50f63cecc3de67c8e351757549597af4b57947bd80bb13fa7e6ac376d1",
"songs/autumn_leaves_acoustic.pages/playback-0054.png": "e0dec601e352093703a8cbeac2be53c6f72cf5d74cabcb8b14c4f5e9a23b8d14",
"songs/autumn_leaves_acoustic.pages/playback-0055.png": "75bf2c21a0295babac403648fc78b14419ad099435fc25aaf06b74cf3383c4bd",
"songs/autumn_leaves_acoustic.pages/playback-0056.png": "817d04b52972c066cd648fc239f2bdd15d1fc0379b7c81b088e3e398e2490eb9",
"songs/autumn_leaves_acoustic.pages/playback-0057.png": "0a09863b96dddbaafa342e2a739fb990861e0cefba0feabc2bb5634a05207de5",
"songs/autumn_leaves_acoustic_improv.json": "31c28b9ae250efaa298951f6407d1df17bed03a9e2b9f198625ffdf33931914e",
"songs/autumn_leaves_acoustic_improv.pages/0001.png": "87b0b0d1d3ebdd0fac08bcf8ab0073d32fd0826015b0280d1de7a9902f32f84d",
"songs/autumn_leaves_acoustic_improv.pages/0002.png": "138de5c3a953813fdfb8b996f77a9a85019172c6c4c71c6227a0a3e87cf340fb",
"songs/autumn_leaves_acoustic_improv.pages/0003.png": "4c1a9bcecfdb9ac5fed64fb29158ddc186cf56b9a1ff90b7b4c705153c8e97a2",
"songs/autumn_leaves_acoustic_improv.pages/0004.png": "7d44cb1a80fa749d14c5ef26b8d90b77e6fc99ce4913daa854709a301b076bcb",
"songs/autumn_leaves_acoustic_improv.pages/0005.png": "3acc64066c2443fbeca185dbe52bc2c69331e215ed28ddeb78546a7ee085028b",
"songs/autumn_leaves_acoustic_improv.pages/0006.png": "c7f0b7eb425bc4f38651ee0c21191ed2842d7ff015344a14314a7e467648e108",
"songs/autumn_leaves_acoustic_improv.pages/0007.png": "221c35123f16f8aaf10ee9d447b8937a0a99b16dff621583de683aa96f1d5b76",
"songs/autumn_leaves_acoustic_improv.pages/0008.png": "bea591fcfe2814c213862a01ded8121d9d7ad4902cfd4ce54e46f52ef41bb09c",
"songs/autumn_leaves_acoustic_improv.pages/0009.png": "3f7bda3f88a779af96b69830a8f6c68ada047cf62d145afc7018f92b0c8f0f6b",
"songs/autumn_leaves_acoustic_improv.pages/0010.png": "59c00b13e3e9615e44d64f0f0b044e6108f30fc96a4bc9317a2a3d145cc8119e",
"songs/autumn_leaves_acoustic_improv.pages/0011.png": "0f5d4bfb0f879175c68160298cdc2da0aa2d9b3302f838c7d9af0a1629493d45",
"songs/autumn_leaves_acoustic_improv.pages/0012.png": "3f59448da5f395125bbd5e9b68d38351331cb92d03874ddc1cea2f3858167dac",
"songs/autumn_leaves_acoustic_improv.pages/0013.png": "a8cfbae920a6541da7fc7e2db812760f9d0cf9be35f74b2a97d3a5706b8526f9",
"songs/autumn_leaves_acoustic_improv.pages/0014.png": "4e908300033bdef7980f79f86feca3ec7ec0dfd541f4e4529a8431eaa97ffbeb",
"songs/autumn_leaves_acoustic_improv.pages/0015.png": "999f6d92b313664b691833235e0a7ab11eb6747edd183e4c6260b32574b7f9ed",
"songs/autumn_leaves_acoustic_improv.pages/0016.png": "cacfb981f78b5c4fa10b544f2dac065bd10186529d0317e8a5233799ebc7d37a",
"songs/autumn_leaves_acoustic_improv.pages/0017.png": "4602af131a8c816092044d9fb3a5ce7208097d2fe6e7ead754a449a74ff2bcdf",
"songs/autumn_leaves_acoustic_improv.pages/0018.png": "b8df0ba54c10fdb8a7e901ced58e07b11095474931572f5f3764e51cbe27abcf",
"songs/autumn_leaves_acoustic_improv.pages/0019.png": "0be07dec199fecae49ff19d87470cb7249f6f360bd94f85fde74517d7cd0c8da",
"songs/autumn_leaves_acoustic_improv.pages/0020.png": "65e988c5a73a25e1be2ed5d34f1658a69205afd9f6715eadd16cfb2e8457a792",
"songs/autumn_leaves_acoustic_improv.pages/0021.png": "d56a1fb42e862f9fa7ddf42be4e9ca67d48e50e13dafef5809c77555f00b4b9b",
"songs/autumn_leaves_acoustic_improv.pages/0022.png": "ec9905238977294f2d7cb34eabe733060f4aaf5c94c898d9152c8093ec2419c6",
"songs/autumn_leaves_acoustic_improv.pages/0023.png": "f8a61346c1fc3485a5171c228b16dc65cd2da26e7453c56e8fcfd85817058d87",
"songs/autumn_leaves_acoustic_improv.pages/0024.png": "1aef4ecd707a99e2c5d6fe9dc85408a6621e7533fe7062e8fc77b9001302fab3",
"songs/autumn_leaves_acoustic_improv.pages/0025.png": "8020c158485bc90479fbd5a82e3ef6b1ee26386f9e127d55926c3cf61d0a73ce",
"songs/autumn_leaves_acoustic_improv.pages/0026.png": "0ad46eee5f2d397ff9849aa4a45927b581ce3cf9f7645ee8d8a1739de4e95b0c",
"songs/autumn_leaves_acoustic_improv.pages/0027.png": "13abf4d226948667faef5090a7a306571e1537aaaca2e8b12bf12fc7b9cb1007",
"songs/autumn_leaves_acoustic_improv.pages/playback-0002.png": "ae4b38302388cbfe1d3fe73a13457dc713f2f02eb63fc07dd5965bf008823c22",
"songs/autumn_leaves_acoustic_improv.pages/playback-0003.png": "b634687a9603b43a6f63b136cb525e7f603d5757205a14498ae3065c00226b7c",
"songs/autumn_leaves_acoustic_improv.pages/playback-0004.png": "ea9f82f3f32eed034a3a322b95677e0a9d0de0ab659fce3744d147133595f2d0",
"songs/autumn_leaves_acoustic_improv.pages/playback-0005.png": "31c5c14ac8dd9e321ba8b555f4470284f51877bfad79dd1baa5f97f4ae881296",
"songs/autumn_leaves_acoustic_improv.pages/playback-0006.png": "d158fc52078ca1a0c96d86a608c53680eaf19a0ce75b0cc986a7c821323702d6",
"songs/autumn_leaves_acoustic_improv.pages/playback-0007.png": "b6ed13e25a8bad742d6ea3aa799f2a9d843e002c1ba30d2129e565b81191d969",
"songs/autumn_leaves_acoustic_improv.pages/playback-0008.png": "5d59ce11151b3438d9e6a4598dd6b741dbcfb25885946e4d8a4d566317d938a0",
"songs/autumn_leaves_acoustic_improv.pages/playback-0009.png": "d4a26acbda393efb01dbf4d689545aac0327f74b7045c10f4560f28192b0e0a5",
"songs/autumn_leaves_acoustic_improv.pages/playback-0010.png": "fe3ab8cc68e76cdc952b4c76dec90fbf5f718c1be3e29f34355e5e40f8ec5645",
"songs/autumn_leaves_acoustic_improv.pages/playback-0011.png": "bba0e55fa5ed0e57311efd1c32a86a52415865c1d64b6b48b12ead289b4dd49f",
"songs/autumn_leaves_acoustic_improv.pages/playback-0012.png": "a349f59498f04e3659a43879135f657cae09a97e76e6da31ff2f3cb5bd30088f",
"songs/autumn_leaves_acoustic_improv.pages/playback-0013.png": "df4b16903b5e39a9c96f1ce02610759b21ed26dfbda9efe768cf4d08d85a8c19",
"songs/autumn_leaves_acoustic_improv.pages/playback-0014.png": "4954ad48cc53b247c8ae0d96645eba44fc8512db2dd7fe0859fb1c4eb8cb2865",
"songs/autumn_leaves_acoustic_improv.pages/playback-0015.png": "55dcc02d878e22accec50bc0b0011d1c0f54e7a9007759c95140aa4a7f8fd94b",
"songs/autumn_leaves_acoustic_improv.pages/playback-0016.png": "bedb8963df24aa609b672012d49ea187ba91b5416a30d7b8f2c9ffe4751cefb6",
"songs/autumn_leaves_acoustic_improv.pages/playback-0017.png": "c1a351c54518b05ea17b03f389ab76193281ffcf1c9307cd2a451595803947e5",
"songs/autumn_leaves_acoustic_improv.pages/playback-0018.png": "a3720fc3021c82a8ee18fc29555512925334644e2c89d100ddb0d7b670c97aba",
"songs/autumn_leaves_acoustic_improv.pages/playback-0019.png": "806af0cf1e7ac6101d7f193227646614cff8017a1fc121e1aee111cfa04abd42",
"songs/autumn_leaves_acoustic_improv.pages/playback-0020.png": "991bf9c780b397ad91dc032238022dd33dca8e529f5ff949caf842a0d693f6d8",
"songs/autumn_leaves_acoustic_improv.pages/playback-0021.png": "9ce8190ee7543cdf340833757b216a23c35f8197ec55bdf557a27fa214fb26c8",
"songs/autumn_leaves_acoustic_improv.pages/playback-0022.png": "720ac8b8a074ffc2fdd143543594727eb87ce134a835536b53e2c2265cb3fccd",
"songs/autumn_leaves_acoustic_improv.pages/playback-0023.png": "c9fd1fbf2fa389db102a06c2fcf828980c80e0143113ec939e8cb5264aea92e4",
"songs/autumn_leaves_acoustic_improv.pages/playback-0024.png": "85300b820036636a5ac8d6e454fb5e2def0a44ef3762a6fdc0fbc2a56f50f9b0",
"songs/autumn_leaves_acoustic_improv.pages/playback-0025.png": "56383bd216899208b0b364e562bff71da7f29a6f5f44bae9a77b9a2e1dc80d50",
"songs/autumn_leaves_acoustic_improv.pages/playback-0026.png": "2913c4515047cb85bdd9a053284cadecef78aaf580c7bb61370cdb8f325e4c84",
"songs/autumn_leaves_acoustic_improv.pages/playback-0027.png": "b4a3d90a750326b6107caa99c83733f4a188994194d31b403f47b957c8597a6d",
"songs/autumn_leaves_acoustic_improv.pages/playback-0028.png": "173ca5ce02aea70520a2e3fb88f5feaeed8fd13b0e4063ef0b94ea2ff31281ac",
"songs/autumn_leaves_acoustic_improv.pages/playback-0029.png": "89e9e2e171fdce100d153d6bfb89336397231386ef9a603c7f7d9d4fb4a2fb59",
"songs/autumn_leaves_acoustic_improv.pages/playback-0030.png": "983388a18b4663a29a21b47e3f27fa0c15510273e2ca214bbb7509f9de084c10",
"songs/autumn_leaves_acoustic_improv.pages/playback-0031.png": "8d0a21f5a13eea2781e7a56506943a286ff0b759380dad6e213dc1478e02e038",
"songs/autumn_leaves_acoustic_improv.pages/playback-0032.png": "5eeb34fc520619934cf733c4dfc66ada4418cc7b134077fc03ac8379a0adbf12",
"songs/autumn_leaves_acoustic_improv.pages/playback-0033.png": "f17d82f411572e4f82468194551eba137ef131fd62848c996fe3fcd3a17c89f6",
"songs/autumn_leaves_acoustic_improv.pages/playback-0034.png": "f2057312a52f4ad6329beb7a4b3609ebba0a3beb3f85f7afaf164313a667ce73",
"songs/autumn_leaves_acoustic_improv.pages/playback-0035.png": "73767b8da428fa4cb553e67d62d87dcc6dbc59ced022731dd259879b774a0757",
"songs/autumn_leaves_acoustic_improv.pages/playback-0036.png": "f9a0f96a824c8c4cc6fd9182c119c3a13815b123254edfae52f4c63a678745c1",
"songs/autumn_leaves_acoustic_improv.pages/playback-0037.png": "176ea351ff4c6f4fcd970e4a2aafd3c2132427dc191907961635b98e15ceee04",
"songs/autumn_leaves_acoustic_improv.pages/playback-0038.png": "c0d9110a9a00f98011d92893424019b4e578a5c37d471c2b653e3f28305ff514",
"songs/autumn_leaves_acoustic_improv.pages/playback-0039.png": "9c64d547101a1091165d051444e6b0312a0f74f011854a9cc5983d7be7a7bdc9",
"songs/autumn_leaves_acoustic_improv.pages/playback-0040.png": "4eb92187e8db1b2008d410f0cc74db08bbe5aa4293c6c20124e2f15aeee32457",
"songs/autumn_leaves_acoustic_improv.pages/playback-0041.png": "6da52f2d0987c971a2b7b695ce1bc7f9d5f31c35538480d35ea82efdb78edb9d",
"songs/autumn_leaves_acoustic_improv.pages/playback-0042.png": "6a8592aa10076cb6c56262bc5ec487fd5904a047ebfa4bf7ff3e00ac11e35bb4",
"songs/autumn_leaves_acoustic_improv.pages/playback-0043.png": "3ff7c1bb46fff73cb387698fcfe741e10a1e1c8489689cca0f2c134b36882acf",
"songs/autumn_leaves_acoustic_improv.pages/playback-0044.png": "5e4afcf151d85ac4aeb89b3aac5ac0cc82f5e04435e29042b7ce9c0c76787cec",
"songs/autumn_leaves_acoustic_improv.pages/playback-0045.png": "6675bada6afd62a38101215c5067c30534b8fb02990e2015da286e1a49eaa8f4",
"songs/autumn_leaves_acoustic_improv.pages/playback-0046.png": "6ed3a55eb4d36f45826b27d12119b306418d7cffa6581e50e02124a9fec02c82",
"songs/autumn_leaves_acoustic_improv.pages/playback-0047.png": "e723e467aab30080d23f1150ac97b04a9596b00c8a97dd50103d24128c902cdd",
"songs/autumn_leaves_acoustic_improv.pages/playback-0048.png": "b39123e53afa05c92854c9326ec3b2aab4ae5757ff316138ee01dc0f9d750e1b",
"songs/autumn_leaves_acoustic_improv.pages/playback-0049.png": "7de3be69940d820c61ef27594376a5387661153af01dfd1681a2680ef22d93d0",
"songs/autumn_leaves_acoustic_improv.pages/playback-0050.png": "f9e3a19122d992a107ef910c03f766272b289a24e52892f0d969432297387120",
"songs/autumn_leaves_acoustic_improv.pages/playback-0051.png": "10f7479b7b50c0511ba0e4a4c499afe5a2a10f5ab9e4417f5becfa1e21ad3f55",
"songs/autumn_leaves_acoustic_improv.pages/playback-0052.png": "dae45537d30d61232815b270d1085c4f4eb5d3b1c7560e0652fd813eea276f10",
"songs/autumn_leaves_acoustic_improv.pages/playback-0053.png": "5e1bafa880130f2170fa5604ad579b3fdc27ddf07dd875857221d4c9a45d4f13",
"songs/autumn_leaves_acoustic_improv.pages/playback-0054.png": "09bb49370c8dab41b78d62ca7c687ac89f2aa4bbcec748ef2162ce4a7da05c18",
"songs/autumn_leaves_electric.json": "4e7c6ce71981ad46b63ef3908c9ef1d89454d4ef9e2c3abfcdf0017e71e162e7",
"songs/autumn_leaves_electric.pages/0001.png": "fef5ff5b73c0e03116b280182755a8133e3ca6e647af81dca984b71d33ed772c",
"songs/autumn_leaves_electric.pages/0002.png": "637ca3009beeaa5eadb587039bcec08cfe66442dba683e3b18443415a1d34491",
"songs/autumn_leaves_electric.pages/0003.png": "26e73ccda608f5baebec6e9c1beceb5586b13b5d138f0d29d4c13f58a6924715",
"songs/autumn_leaves_electric.pages/0004.png": "d7d47739c2c32a676198d091d546e027e218530dbe76147a71ad7156dad96f8c",
"songs/autumn_leaves_electric.pages/0005.png": "bfdba8e3bd988d7c71769254b779ad58b9b2641e1fb4a0990346616b90df11ca",
"songs/autumn_leaves_electric.pages/0006.png": "08f6c8007bf814d9e3e113eaa34064a9448b9831bf810a05f45a7bda57a166d2",
"songs/autumn_leaves_electric.pages/0007.png": "342b85bd00874966710187e93020d89edb570d259db2c13e95343c020d11ac76",
"songs/autumn_leaves_electric.pages/0008.png": "818ee9b542eab4811bbad3e3f3ae0316e9d4bbe24c83ebd6abf492df5c9ff919",
"songs/autumn_leaves_electric.pages/0009.png": "880bb9261e311a307b9f78f4c65a8c622357f640310b7a62ba2e6bc75bc09162",
"songs/autumn_leaves_electric.pages/0010.png": "4b70d68d3018504acbf891cb450b21da1878d7b78b9def1a157f1c5ab5cbf313",
"songs/autumn_leaves_electric.pages/0011.png": "ceafe100023db75a8d34ea08e8c66155ba76aa12e8a24c9b83294d2a01779ca9",
"songs/autumn_leaves_electric.pages/0012.png": "26ba3b04b7e14ceb4a2420f9cdac5aa7c4be2a1134726ffd291efea72c701a77",
"songs/autumn_leaves_electric.pages/0013.png": "f15aeb9cae1d24acedd8bcf34bf03dcfd51aa1d06cfb9f2d6bebc7513d1b8b7e",
"songs/autumn_leaves_electric.pages/0014.png": "7f04cd38a79073c0d3ccbeabecb0118acb60c1584d63bb700df5d4a9c0b920a5",
"songs/autumn_leaves_electric.pages/0015.png": "51d51b7f44cbd817f8c4e99dcbefb975d50232743cd2f2aa2039a39721da503b",
"songs/autumn_leaves_electric.pages/0016.png": "a39b11be87dc80d21838e4b2ba7b9e9a35672e67e089d8744238587ed8a3762c",
"songs/autumn_leaves_electric.pages/0017.png": "28fd47c4a918eb62f3a94e13c4e036f5abf66635c7e9f2e40f6cec17fa3840b7",
"songs/autumn_leaves_electric.pages/0018.png": "576b94e72e221b89e12d9383ffa554101cb2e5ed4e7b00204fc0654eb7912427",
"songs/autumn_leaves_electric.pages/0019.png": "71672fc8613539914aa4069a4668751363e0be3d2e9822cf078755fa6b9116f3",
"songs/autumn_leaves_electric.pages/0020.png": "86747ada8e9ff0b1c05824d1a1ec9328f01cf33a65c3ae13c64a1e075c0a52ba",
"songs/autumn_leaves_electric.pages/0021.png": "c981fe628c1621c6f5add8635e33aaacae112fe954b2b43f15b3f02604c6c9e9",
"songs/autumn_leaves_electric.pages/playback-0002.png": "3c96277900a9810bb5e42c261b4a7576affea141d6976babe13c16309b22f54f",
"songs/autumn_leaves_electric.pages/playback-0003.png": "49f47d61b78f7a9301a9cdc5a108a28d28440388865d8fdcba884c3ad69c3ee2",
"songs/autumn_leaves_electric.pages/playback-0004.png": "221682c6ce84ae99c33fd8dcffc1356965e2b9fa6b068f02570335231d881278",
"songs/autumn_leaves_electric.pages/playback-0005.png": "568f242912b71a2a0e6b438fabaeaf043a62087d1b3018d61838093e6812c392",
"songs/autumn_leaves_electric.pages/playback-0006.png": "dc5b754b3d11d136a89c82b3160b3cb631572065505b2770f529c312c8beb0cc",
"songs/autumn_leaves_electric.pages/playback-0007.png": "13d877cc54210a860f0e08006c5e386a6a3e5c339e2d334df11ad37afd8b8fec",
"songs/autumn_leaves_electric.pages/playback-0008.png": "e453d7c206320f7bd7020d6d53a912a4e4c47ad4909d5c5a0848acfce06f6081",
"songs/autumn_leaves_electric.pages/playback-0009.png": "2929de6efff1ddccfd9a5a173310e78b16fdd22e0d646d798b10df29b7798f39",
"songs/autumn_leaves_electric.pages/playback-0010.png": "07d5c2b2ae31ebd88d4fb4708caefac36aca5d436048c1ffad55feffa6d87925",
"songs/autumn_leaves_electric.pages/playback-0011.png": "02cb49878815115e99a0343bb99e9874e018cd763e2b362d1a87815d54eb441b",
"songs/autumn_leaves_electric.pages/playback-0012.png": "5493a523d68e125a46317b9b225abaf1c2b327057a40db8b5ae56f289a71de81",
"songs/autumn_leaves_electric.pages/playback-0013.png": "bcbcf06bc8587542974e53309ec1221b4a74ff060d5c5690313400a689f6945e",
"songs/autumn_leaves_electric.pages/playback-0014.png": "ff2886e25c24329eebf526cd9b10dd56266e3a5ec78c18d2e63ae98e107c4761",
"songs/autumn_leaves_electric.pages/playback-0015.png": "2a2684b1c7b0c0ca5cac6461c2c1178bce0303150884fa21b29517086ef6642f",
"songs/autumn_leaves_electric.pages/playback-0016.png": "bcd67894d53d043526686e56cc4b2058944c1f9a1f99eb14074e2e90dda7937c",
"songs/autumn_leaves_electric.pages/playback-0017.png": "6356a7db80fda5ed10256ca3a4e37bb7a0115c339d405ffeb48854b2e49eb96b",
"songs/autumn_leaves_electric.pages/playback-0018.png": "18ec2f04c2d552ec6fe341ef796d785fd7a86a9762f6827f8457712510cf99f9",
"songs/autumn_leaves_electric.pages/playback-0019.png": "640adf4f8be4957d984d393aeb62f953625b5a165769ba41830b1e9900694aa7",
"songs/autumn_leaves_electric.pages/playback-0020.png": "95a7d3e90b7a7cf435ce87c1d83366822f38f53857d993cb9c242afce3f1ac2a",
"songs/autumn_leaves_electric.pages/playback-0021.png": "f983e3bccc183efa8fbbe9f83a7629b056820d15129bc84108f02934a4b52ae3",
"songs/autumn_leaves_electric.pages/playback-0022.png": "614a51979fa8c9229503018645533118f05f496ffee4be4003e18a2281015844",
"songs/autumn_leaves_electric.pages/playback-0023.png": "62a9183db3b0b22143e914bb282bd51dd6c2ae93ea314251df8812e8915fce6f",
"songs/autumn_leaves_electric.pages/playback-0024.png": "0817b0426ac6535d814c03c73c55524ea2fdeb7df2f792e0f946e8fb7ec74415",
"songs/autumn_leaves_electric.pages/playback-0025.png": "1f662d387e317ba06d7b66a684425cf97550c2272f6c720e9390e5151dff0afc",
"songs/autumn_leaves_electric.pages/playback-0026.png": "c47f0ef9f4b336e0c22f5df2070d6bcdfbf17011318917d68df676506a3ecec9",
"songs/autumn_leaves_electric.pages/playback-0027.png": "a4f09eb130425c83f6c8454b330afc060d1eaed310c4a2e3b313891f53282f68",
"songs/autumn_leaves_electric.pages/playback-0028.png": "0fab01c2efe841ef6751a19b2e792ae11aeaa15638cbb41072eef8a9ccf17a92",
"songs/autumn_leaves_electric.pages/playback-0029.png": "29d124f64604bdcc7415ec262be7efc09038f733b75c3c075170f3a4a1638f56",
"songs/autumn_leaves_electric.pages/playback-0030.png": "ac453524be3748a357b873761512b07ca370661ac23196e57333108bcc2fbba9",
"songs/autumn_leaves_electric.pages/playback-0031.png": "3890e566a3b136f86ef84aac7dafa4505c6a455111cee4faf1f3f82aa372ea08",
"songs/autumn_leaves_electric.pages/playback-0032.png": "403e51bac8d0c1ffffebd8c0253c62dd2ee3e354cffdd36c846b9fab88507e93",
"songs/autumn_leaves_electric.pages/playback-0033.png": "a2a8f2a5dec60d1fd539ee2c9fb8b310789c3ef68c0fce928319fb1a800f8808",
"songs/autumn_leaves_electric.pages/playback-0034.png": "4d3c0283b624fae38ec67128596f33d0cffa573c99fc4b31d0e31f4a38fd2dbc",
"songs/autumn_leaves_electric.pages/playback-0035.png": "b39b815b867647c3997c80a88397de12b66b218d1b2be4dc240b0beda9052685",
"songs/autumn_leaves_electric.pages/playback-0036.png": "814c805dc6aa0e6e4dae791b9af5743ad4dd71207ae00f8d5442715d787b4d82",
"songs/autumn_leaves_electric.pages/playback-0037.png": "d3e999968b05cb703fba44bcb1f3b8cc1b0934ca7513f9e952db41a27d9dbccd",
"songs/autumn_leaves_electric.pages/playback-0038.png": "43773db6f940cdd5457053e9d1cebb1f715d7a9d069fef8f29dd280bc664383f",
"songs/autumn_leaves_electric.pages/playback-0039.png": "da683c3e3d6198a49464d6e9463f9bed2ad9595c6c69ac09adaeeeeddb626003",
"songs/autumn_leaves_electric.pages/playback-0040.png": "1e1fe40450357ed40ab4a688906e62c69306dc706ec53e4c23de94d7228dffc3",
"songs/autumn_leaves_electric.pages/playback-0041.png": "f7c3ab577b12be529b9c73b44521852db930681e6dba1410aae569e526fc4a29",
"songs/autumn_leaves_electric.pages/playback-0042.png": "a827c32cf60d5bafb3b042d36f14883bee389e677091bfc5033771356c164254",
"songs/autumn_leaves_electric_improv.json": "e71fa13f0178fa8b7df0260efbe42189ca72457d439d6a71ed8a6df3f2ccfbf7",
"songs/autumn_leaves_electric_improv.pages/0001.png": "ea87300c5d8e0bcb706f2475c884678e850531b7ddf453b8566ba45c612b889e",
"songs/autumn_leaves_electric_improv.pages/0002.png": "051112d56df6754e84ed3417dfb9549a9351c217ae31d34bfa459b6fbc8e08aa",
"songs/autumn_leaves_electric_improv.pages/0003.png": "f5c72081b94bdd88934c10e9ae56738d5b461f761985693e96e72113e98e7679",
"songs/autumn_leaves_electric_improv.pages/0004.png": "ebc3e3861e883ffda6868aa55900dbfa4eac5d3b495c5ac8dff5fec312445102",
"songs/autumn_leaves_electric_improv.pages/0005.png": "680eff0386feb5cf91f662987610a8edb6fbbee9db67bb1701cfa108ca223c00",
"songs/autumn_leaves_electric_improv.pages/0006.png": "309224e6d3147cdd43b22256550cb3935a4dc1ed282052c78518be3c3fefb695",
"songs/autumn_leaves_electric_improv.pages/0007.png": "550d260e0c0e18e32459e0f9be85ba4f123b225ef79ef7813f4ce9f3d50fac7f",
"songs/autumn_leaves_electric_improv.pages/0008.png": "783442fd6a94f595709170e35431f7ad39454ed5a526eaab58617b11bdd9bed1",
"songs/autumn_leaves_electric_improv.pages/0009.png": "a937b80c08fcf163021a15013a317f797f1fbb4fc4c4b2959752a3703de0938e",
"songs/autumn_leaves_electric_improv.pages/0010.png": "e9d3d3a55e2629e5c529901c3fc22c120e809966d721a84a285418ed312575f3",
"songs/autumn_leaves_electric_improv.pages/0011.png": "ab9d4498690ff12d47a9b0b73301eebf481e87215173a7744bb9073a5169abbc",
"songs/autumn_leaves_electric_improv.pages/0012.png": "3b2c3d1db73b73bb9b07fae7eea73702b0308c5d2e21e340546ed0267fa7f1f3",
"songs/autumn_leaves_electric_improv.pages/0013.png": "43a4714dfd26490fa7d839529e5e53f3183ecc82a2a7e60c72851e032d91a53d",
"songs/autumn_leaves_electric_improv.pages/0014.png": "ea9dd92ddfc7f152f9bbe84390fa4b68029e7ddb5a5aabfccd19da3a70eeb876",
"songs/autumn_leaves_electric_improv.pages/0015.png": "425675e1e9c470b3d404fa439f4aeb3015f69db438c8a0fd1c1340959f50c20b",
"songs/autumn_leaves_electric_improv.pages/0016.png": "ab3dfc09ae234286915f85112ff393706490ead8513045c004267894f4993837",
"songs/autumn_leaves_electric_improv.pages/0017.png": "a934f1c8b8b0b1c2ef5e8491efc1395e7097353a48e11b2ae0d43d848cfd2672",
"songs/autumn_leaves_electric_improv.pages/0018.png": "7d4397525fd07c9646277059870e12b323cc39482ad148bf3f780eeb6168df65",
"songs/autumn_leaves_electric_improv.pages/0019.png": "167db0cc5ae709ae31bf51e25e8873010bcdd2e03859944400ec66096102e7ac",
"songs/autumn_leaves_electric_improv.pages/0020.png": "e0a3fcd34364177ba8fe68c2f5112193a2994af4fe7b8b6c624d804b27e37ff7",
"songs/autumn_leaves_electric_improv.pages/playback-0002.png": "073c0218f2e1a43f5d01eafe623a637f990f59ea74d8b3b07dd09d53ca21912a",
"songs/autumn_leaves_electric_improv.pages/playback-0003.png": "bfc2642b4e266165bd160fa2010d50f86e4c31c85373be691336a6dd9cbfb0ec",
"songs/autumn_leaves_electric_improv.pages/playback-0004.png": "86bfdce07b4da9f5a17a2ef5adcf9c54f15b9c40bff14b45921cf048a5b002df",
"songs/autumn_leaves_electric_improv.pages/playback-0005.png": "a62f8e15f45311ba8cf8e8082e3aa783e4ce198adba7e57b95f676b4857f922c",
"songs/autumn_leaves_electric_improv.pages/playback-0006.png": "81fe69c2e45c03affe092750cb098ed2a2054c39fe0d31135a478592f8db53e0",
"songs/autumn_leaves_electric_improv.pages/playback-0007.png": "fc9d82afdb05db20b055d6d019c74d5a3850dff823de16f3eb6fa50ea3c6f126",
"songs/autumn_leaves_electric_improv.pages/playback-0008.png": "dcd7808b47ead0f16a51a08b21781e79d1c5dc0e7b0465f88ebb46f2b57d37db",
"songs/autumn_leaves_electric_improv.pages/playback-0009.png": "aa8a820c75c3f9c1c0a679c9ae85fb1cde3f8c85559afd24c91bb6de460af7f2",
"songs/autumn_leaves_electric_improv.pages/playback-0010.png": "96b113c3bfdc9fe04c5c22eac967fb12f4cc1be0bbb9c689673cd3d146ab1e20",
"songs/autumn_leaves_electric_improv.pages/playback-0011.png": "0f4d547396506cbdcf1ab83bfcf586f04edcc991607f13636f719b6405db9bea",
"songs/autumn_leaves_electric_improv.pages/playback-0012.png": "be7a617464ba40a46194b1b1cd78c5c18ed6cc6ddb48a796406ee9d0c969ae00",
"songs/autumn_leaves_electric_improv.pages/playback-0013.png": "78f06a0ef42d36174f766646de81e2cb810e7a4c88a8302254cbee8790c634d0",
"songs/autumn_leaves_electric_improv.pages/playback-0014.png": "842b748a992f221f8d5836f2e4fc90d547b3d91421c29318298070c8f432263c",
"songs/autumn_leaves_electric_improv.pages/playback-0015.png": "8840485be64bd1411da40aa26f89521b8b0f017c226410196025851980f09a9e",
"songs/autumn_leaves_electric_improv.pages/playback-0016.png": "6c3b974dcb16be0539551469da6a8e616756a7438fa7389b54e2a09a1098695e",
"songs/autumn_leaves_electric_improv.pages/playback-0017.png": "bf04cc2321a764a6ee755b49f4dc59ab5adb7ab0625f036d367123bfa6bf44fe",
"songs/autumn_leaves_electric_improv.pages/playback-0018.png": "16b4faf44c794adf34158c999c8d10eec7bbd05393a802f005365ce2403b7455",
"songs/autumn_leaves_electric_improv.pages/playback-0019.png": "3806622991cf8eba1f4b74b287866252af9fd3aa87e7360ce4edab50edff0ca3",
"songs/autumn_leaves_electric_improv.pages/playback-0020.png": "eddf1ce73b2367c5a00d0429977f0a5bb4b38048aaca3627f0d0ac5d559eec13",
"songs/autumn_leaves_electric_improv.pages/playback-0021.png": "74416b6187127c07b7f8f0fdb16f98ffb235e61a8d661e4fba294d294346f0b8",
"songs/autumn_leaves_electric_improv.pages/playback-0022.png": "21dc73ac8e46538fc3d1df1b1fd7691f30395934460b043c51ee64a63e3d1cf6",
"songs/autumn_leaves_electric_improv.pages/playback-0023.png": "e16a4a547541b41597108297951790fc642a5e91028028b6e32ce18e03b5d0d7",
"songs/autumn_leaves_electric_improv.pages/playback-0024.png": "ccb1e63b301882d5c2eed9a8ce1e4978e25ad790a32ffd56c433c1d8964cbc44",
"songs/autumn_leaves_electric_improv.pages/playback-0025.png": "23aba3a66b1631d92275fdc3124c456504917ba9da239c81c000abb9d7af090a",
"songs/autumn_leaves_electric_improv.pages/playback-0026.png": "7bc2cf14428c6d9a137840bf423de648b2f0b5505ce1c7a8b61791e167d66d56",
"songs/autumn_leaves_electric_improv.pages/playback-0027.png": "e0ab8c074bd0286744106a5e6fff11b9b24a4aae4a4822414ae38bcb84b0f845",
"songs/autumn_leaves_electric_improv.pages/playback-0028.png": "1099b56128019d5b637f23e04336553c9a0af6b686bf9c8a41244b81891cd01c",
"songs/autumn_leaves_electric_improv.pages/playback-0029.png": "a574680a3659a3a0f2a461f6d296a5d4e138579ac9cedc3f2423426519da75b5",
"songs/autumn_leaves_electric_improv.pages/playback-0030.png": "36df93cd562a2452f1035c1243eaecdadd8853318ee5694d31780900564243a5",
"songs/autumn_leaves_electric_improv.pages/playback-0031.png": "bfe81e7c69459d19bf5da1b44ca270a9f284e58250d3a7a440daaf9b145e5bfd",
"songs/autumn_leaves_electric_improv.pages/playback-0032.png": "ea49ab07e94cc0477ef29b804048458532e1a4f42c545f862cf2b9ade40fd098",
"songs/autumn_leaves_electric_improv.pages/playback-0033.png": "766abf245d2c92659df00fbb17e3e2392fbfa4d7064bdbc1ca5d0c71073bbff4",
"songs/autumn_leaves_electric_improv.pages/playback-0034.png": "f2e90f61126a6e1ae61d834aa8bd4b0463fb4981ffe2ac3fc214b8638417d36f",
"songs/autumn_leaves_electric_improv.pages/playback-0035.png": "78f87a74619a50bd40c7bad4fa2522cb74d815fe44a9c7e2987e790284fa8631",
"songs/autumn_leaves_electric_improv.pages/playback-0036.png": "6a0edfc9448247de68b9700f20889f75cbf3f0ca553a06d975e672679fe59dca",
"songs/autumn_leaves_electric_improv.pages/playback-0037.png": "855d996c7fb4616ca240698c1ab9f90c02971bf26279af38f2ff594e7d2ddf40",
"songs/autumn_leaves_electric_improv.pages/playback-0038.png": "c01d3874dbb703e33e3f1e4ca8d5edb01e08c53314499813d9e04ba16054c74e",
"songs/autumn_leaves_electric_improv.pages/playback-0039.png": "158c0ca1c6df28d4e0842a63b51258b351935a0a5e0bfd7eb201b4791b1e1f80",
"songs/autumn_leaves_electric_improv.pages/playback-0040.png": "3b4331d2b0d31583b800405506e188695a2e14aaf8a1dd2409e0eeb2b2651d91",
"songs/autumn_leaves_vocal.json": "b0e22bf88d75521bdc4bc8acbbd31440aae79e38b6d84c4048dd729fce82ed5f",
"songs/autumn_leaves_vocal.pages/0001.png": "4b9402563b8ae88a34f25482d5db3d5279643bed60731c7baac69a030b3ce2d9",
"songs/autumn_leaves_vocal.pages/0002.png": "b961fb05e5539ce4335b561df9fc9558b81574872a35956da0beb192a8db258e",
"songs/autumn_leaves_vocal.pages/0003.png": "a3e5423f083d8159e52dd4f1fa1532b982a4290dc3db75921a120fa3befb5c7d",
"songs/autumn_leaves_vocal.pages/0004.png": "9aecc0d1c84bdebdf214c99469ef2fbc7a8e625471b8b06e26c3267dea1dfc42",
"songs/autumn_leaves_vocal.pages/0005.png": "80f3956a196ef56b01647c7daa0d58989c12f04b2ddd8c166cedaf846c1d0f18",
"songs/autumn_leaves_vocal.pages/0006.png": "56e0fcb5faf8c5bd514efd6568284d6548708b4fed7d470c138d9478db34eb77",
"songs/autumn_leaves_vocal.pages/0007.png": "81b80d0a70883a69e10b8f06fd2c2f904670dc3a1cae13b980d239ae4a882e46",
"songs/autumn_leaves_vocal.pages/0008.png": "d55633751f78440bd94f1dbbed846c151cf79bebc5fa4b0f338add0c4b6d2e99",
"songs/autumn_leaves_vocal.pages/0009.png": "2da18b1db70f1cff719f697c39ecda329dbc60d3fe0d605351fcae8583e6901a",
"songs/autumn_leaves_vocal.pages/0010.png": "321d18c54e138248b31a00df6e3a95b9af62588a227a83e56db7475acb923d7a",
"songs/autumn_leaves_vocal.pages/0011.png": "c02c41a2ff2b14ec5bde44f22bec03fd71edf2d9e272d2ef0a8434b843a26b6b",
"songs/autumn_leaves_vocal.pages/0012.png": "ac4bf6573e196d5afbb0049bcc54836a7acac6a1e9e8cce48dedad203f4b43e0",
"songs/autumn_leaves_vocal.pages/0013.png": "6c22d2dde54e4e7d6cd4cef815ff4e4a9738cd48707f344e90e75737939f68ec",
"songs/autumn_leaves_vocal.pages/0014.png": "3b602afdbb2705281dc2dc5120427105649c5df1692155540c9ad9adae3621c8",
"songs/autumn_leaves_vocal.pages/0015.png": "59339718670a3c8d97b6efb7acc3e7234cb26b11e135da9f502689c77824be8a",
"songs/autumn_leaves_vocal.pages/playback-0002.png": "c95138bff07d8dae52535a96bb33cc3a31c6509d7da49c60c35a55f2a1072c4c",
"songs/autumn_leaves_vocal.pages/playback-0003.png": "fb030bc5b0aa831b534223b63b07cbadd7ab76ce9376c3bde8965f09e73d41f8",
"songs/autumn_leaves_vocal.pages/playback-0004.png": "250262570aac9adaff71ddde21a61c65550afb46849016dcd5162cfcedb522da",
"songs/autumn_leaves_vocal.pages/playback-0005.png": "4832b81482f73003ec7e2990f1558ac8d4cc62883ad1c01d8e78837a37a6de6c",
"songs/autumn_leaves_vocal.pages/playback-0006.png": "0b753c25706437aa8b716f9a254e5dfc03c0c441dd2dfc4f038c3fba7528dd19",
"songs/autumn_leaves_vocal.pages/playback-0007.png": "9f9cfa20a8dfa15cd5ac9e0c47f5d6c0632177702229d5f5c7566c315aa99459",
"songs/autumn_leaves_vocal.pages/playback-0008.png": "d525a0af7688927b7cb5f14302ab7151b9e2d0dd83d04d4b53ac7414f8c928e4",
"songs/autumn_leaves_vocal.pages/playback-0009.png": "f6dbfeca5e20dcf475f8da0285632b317759e1d2d4d69a54a4232d853db68004",
"songs/autumn_leaves_vocal.pages/playback-0010.png": "b54d909532c99f359dded5fc2cb11f93309bd8a158b500ee3be524338e471f48",
"songs/autumn_leaves_vocal.pages/playback-0011.png": "619b4621c5ade46fd29e5e70f08c8d421e1916e0578fa2979bcb4a8204dd99d7",
"songs/autumn_leaves_vocal.pages/playback-0012.png": "4472606d66ca6d1a6d490e89f127327e121331eba14c89b1f20e108ed63cb2af",
"songs/autumn_leaves_vocal.pages/playback-0013.png": "525be592c83a6a119c1b2bc8f0eba24de0bac7ac66c56899f10921e959ae7290",
"songs/autumn_leaves_vocal.pages/playback-0014.png": "8f792dd41bad096867edf9e51fcbe5e6773db1256e849cc32b9402aed59ca991",
"songs/autumn_leaves_vocal.pages/playback-0015.png": "2767f2d9979040258f3a619274e6f11fc8e750b7dc3f0d34adbf373455c08200",
"songs/autumn_leaves_vocal.pages/playback-0016.png": "8a61095e966c67c35df99da5fe32d0bb710c9e0443f135585593100a3b76a8bd",
"songs/autumn_leaves_vocal.pages/playback-0017.png": "234f9045d2cc31fc73f1c11bed69641acc5887ac794d051760ba041df5279b8f",
"songs/autumn_leaves_vocal.pages/playback-0018.png": "6d3156bc58fbcd88abc9c5b18e41ab62a7fece8996655c6723a52501869a60a3",
"songs/autumn_leaves_vocal.pages/playback-0019.png": "9851262495f7b0916982a8f46421948068d4208af9ec1d7ff22fd38a80860d24",
"songs/autumn_leaves_vocal.pages/playback-0020.png": "03026a3ab967ac2c963336c475f9ecb3033c799ae28d9e832a2e9d3ac5367c99",
"songs/autumn_leaves_vocal.pages/playback-0021.png": "d72cd7ed7c58cd4fd44372f6dfcef7e91b84b3c74f747bf1fc84a2c81c44da36",
"songs/autumn_leaves_vocal.pages/playback-0022.png": "46ff7fd7202c1378a9598982379d4d7322f5de934280a78eb5cd76a14f6fad35",
"songs/autumn_leaves_vocal.pages/playback-0023.png": "406830c4e11ecc52774bf67351a2d6c3410f2606df206c43cafa44c5beed42cf",
"songs/autumn_leaves_vocal.pages/playback-0024.png": "072dda94b8a251c775663f81b4b264edac9bdb64c67d115fd87ae469eb7b812f",
"songs/autumn_leaves_vocal.pages/playback-0025.png": "b98a8b5879620dfe0bccd063f8d6122fc6826b86b11d07da3aa7abb8a07f265d",
"songs/autumn_leaves_vocal.pages/playback-0026.png": "476255d5814bba2f838f9addc852f080408c24fa3d1c2b549c93da3d59bc11bb",
"songs/autumn_leaves_vocal.pages/playback-0027.png": "0678a2cf026519a06e62c8ef3599a429290092968785e71431584634bba26375",
"songs/autumn_leaves_vocal.pages/playback-0028.png": "d89db0cd8a2435a978a2e11b070c7aaacb3f791542aed8da4b3e17af888ceee5",
"songs/autumn_leaves_vocal.pages/playback-0029.png": "b8ae37ad031080e1a70f8113123e6706455798e51e8dae87913381f846661e08",
"songs/autumn_leaves_vocal.pages/playback-0030.png": "c04d59f0f791b9d813ba659fdb4bd616b649afca3a79b9ed437781f2301f04d8",
"sounds/beat1.wav": "634e73055b4ae05857de54c0cff0bee2ac4476dcde874b474b192512ba113a39",
"sounds/beat2.wav": "9bc510822228479fe4d4fd85be0d3b2f9eac009449f7fd6f916dd54661124c34"
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 67 KiB

After

Width:  |  Height:  |  Size: 67 KiB

File diff suppressed because it is too large Load Diff
+16725
View File
File diff suppressed because it is too large Load Diff
+37
View File
@@ -0,0 +1,37 @@
"""Independent exhaustive oracle for small grip/hand placement examples."""
import itertools
def regions(shape):
return tuple(h for h in range(1, 13) if all(h <= p.fret <= h + 3 for p in shape)) if shape else tuple([0])
def movement(a, b, ha, hb, acoustic=False):
if not a or not b:
return 0, 0
if len(a) == len(b) == 1:
pairs, unmatched = [(a[0], b[0])], 0
else:
def voices(shape):
return {('bass' if acoustic and p.string_number in (5, 6) else p.string_number): p for p in shape}
x, y = voices(a), voices(b)
pairs = [(x[s], y[s]) for s in x.keys() & y.keys()]
unmatched = len(x.keys() ^ y.keys())
return abs(ha - hb), unmatched + sum(abs((p.fret - ha) - (q.fret - hb)) + abs(p.string_number - q.string_number) for p, q in pairs)
def cost(path, costs, indices, *, acoustic=False, left=(), right=(), close=False, hands=None, left_hand=None, right_hand=None):
travel, peak, effort = indices
base = [sum(costs[i][v][j] for i, v in enumerate(path)) for j in range(len(costs[0][path[0]]))]
results = []
for positions in [hands] if hands is not None else itertools.product(*(regions(v) for v in path)):
for lh in [left_hand] if left_hand is not None else regions(left):
for rh in [positions[0]] if close else [right_hand] if right_hand is not None else regions(right):
points = [(left, lh), *zip(path, positions), (path[0] if close else right, rh)]
total = base.copy()
total[peak] = max(h for _, h in points)
for (a, ha), (b, hb) in zip(points, points[1:]):
shift, ergonomics = movement(a, b, ha, hb, acoustic)
total[travel] += shift
total[effort] += ergonomics
results.append(tuple(total))
return min(results)
+2 -3
View File
@@ -11,7 +11,6 @@ import generator.harmonic_time
import generator.solo.types
import generator.solo.placement
import generator.solo.profiles
import generator.solo.decoder
import generator.solo.learned
import generator.solo.harmonic
import dataclasses
@@ -45,6 +44,6 @@ def install(test):
test.enterContext(unittest.mock.patch('generator.production.generate_tree', side_effect=serial))
test.enterContext(unittest.mock.patch('generator.vocabulary.load', return_value=resources))
test.enterContext(unittest.mock.patch('generator.solo.authored.lookup', return_value=None))
test.enterContext(unittest.mock.patch('generator.production._solo_model', return_value=predictor))
test.enterContext(unittest.mock.patch('generator.production._resource_key', return_value={'model': 'synthetic infrastructure fixture'}))
test.enterContext(unittest.mock.patch('generator.composition._solo_model', return_value=predictor))
test.enterContext(unittest.mock.patch('generator.composition._resource_key', return_value={'model': 'synthetic infrastructure fixture'}))
test.enterContext(unittest.mock.patch('generator.solo.composer.compose', side_effect=compose))
-225
View File
@@ -1,225 +0,0 @@
"""Read optional reference MusicXML literally, without repairing it or composing."""
from __future__ import annotations
import argparse, collections, html, os
import hashlib
import json
import pathlib
import fractions
import xml.etree.ElementTree
import generator.training_io
import generator.fretboard
import generator.solo.placement
import generator.solo.types
def events(review):
offset = fractions.Fraction(review['alignment']['encoded_offset'] or 0)
return [dict(start=str(fractions.Fraction(n['start']) - offset), end=str(fractions.Fraction(n['end']) - offset),
pitch=n['sounding_midi'], spelling=n['pitch'], measure=n['measure']) for n in review['sounding_events']]
def rests(review):
offset = fractions.Fraction(review['alignment']['encoded_offset'] or 0)
cursor = -offset
result = []
for n in sorted(events(review), key=lambda n: fractions.Fraction(n['start'])):
start, end = fractions.Fraction(n['start']), fractions.Fraction(n['end'])
if start > cursor:
result.append((str(cursor), str(start)))
cursor = max(cursor, end)
finish = max((fractions.Fraction(m['start']) + fractions.Fraction(m['duration']) for m in review['measures']), default=fractions.Fraction()) - offset
if cursor < finish:
result.append((str(cursor), str(finish)))
return result
def playability(review, tempo=fractions.Fraction(120)):
notes = []
conflicts = []
for i, n in enumerate(review['sounding_events']):
p = n['pitch']
shift = fractions.Fraction(n['sounding_midi']) - fractions.Fraction(n['encoded_midi'])
if shift % 12:
raise ValueError('Guitar comparison expects octave-only transposition')
pitch = generator.solo.types.Pitch(p['step'].lower(), fractions.Fraction(p['alter']), p['octave'] + int(shift / 12))
note = generator.solo.types.Note(fractions.Fraction(n['start']), fractions.Fraction(n['end']), pitch, event_id=str(i))
notes.append(note)
if not generator.fretboard.single_positions_for_pitch(fractions.Fraction(pitch.number())):
conflicts.append({'measure': n['measure'], 'written': p, 'sounding_midi': pitch.number(),
'constraint': 'No standard-tuning position on strings 1–6, frets 1–12, without open strings.'})
overlaps = [{'first': a.event_id, 'second': b.event_id} for a, b in zip(notes, notes[1:]) if a.end > b.start]
placed = generator.solo.placement.place(tuple(notes), tempo) if notes and not conflicts and not overlaps else None
return {'conflicts': conflicts, 'overlaps': overlaps, 'complete_path_found': placed is not None,
'range': [min(n.pitch.number() for n in notes), max(n.pitch.number() for n in notes)] if notes else [],
'positions': [list(n.position[:2]) for n in placed[1]] if placed else [],
'limitation': 'Legal placement only. Shift cost is a preference, not a verified human speed limit.'}
def musical_summary(review):
ns = events(review)
durations = collections.Counter(str(fractions.Fraction(n['end']) - fractions.Fraction(n['start'])) for n in ns)
intervals = collections.Counter(str(fractions.Fraction(b['pitch']) - fractions.Fraction(a['pitch'])) for a, b in zip(ns, ns[1:]))
holds = []
for event, n in zip(review['sounding_events'], ns):
if fractions.Fraction(n['end']) - fractions.Fraction(n['start']) < 2:
continue
spans = [s for i in event['notation_events'] for s in review['notes'][i]['harmonic_spans']]
holds.append({**n, 'harmonic_spans': spans})
return {'attacks': len(ns), 'duration_counts': dict(durations), 'interval_counts': dict(intervals),
'rests': rests(review), 'sustained_events': holds,
'annotations': review['annotations'], 'interpretation': 'Post-generation diagnostics; does not train or reselect music.'}
def compare(generated, reference):
a, b = events(generated), events(reference)
def grouped(ns):
result = collections.defaultdict(list)
for n in ns:
result[n['start']].append(n)
return result
left, right = grouped(a), grouped(b)
differences = []
spelling = []
equal = 0
for start in sorted(left.keys() | right.keys(), key=fractions.Fraction):
x, y = left[start], right[start]
def sounded(ns):
return sorted((n['pitch'], n['end']) for n in ns)
if sounded(x) != sounded(y):
differences.append({'time': start, 'generated': x, 'reference': y,
'context': 'reference lead-in before form' if fractions.Fraction(start) < 0 else 'aligned form'})
else:
equal += len(x)
if [n['spelling'] for n in x] != [n['spelling'] for n in y]:
spelling.append({'time': start, 'generated': x, 'reference': y})
rest_difference = rests(generated) != rests(reference)
return {'exact_musical_match': not differences and not rest_difference, 'exact_matching_attacks': equal,
'relationships': relationships(a, b),
'differences': differences, 'spelling_differences': spelling, 'rest_difference': rest_difference,
'generated': musical_summary(generated), 'reference': musical_summary(reference),
'reference_playability': playability(reference), 'reference_original': reference}
def relationships(a, b):
"""Read-only comparisons on the aligned clock; no fitted aggregate loss."""
def distance(left, right):
row = list(range(len(right) + 1))
for i, x in enumerate(left, 1):
next_row = [i]
for j, y in enumerate(right, 1):
next_row.append(min(next_row[-1] + 1, row[j] + 1, row[j - 1] + (x != y)))
row = next_row
return row[-1]
ns = [[dict(start=fractions.Fraction(n['start']), end=fractions.Fraction(n['end']), pitch=fractions.Fraction(n['pitch'])) for n in notes] for notes in (a, b)]
points = sorted({n[k] for notes in ns for n in notes for k in ('start', 'end')})
occupied = equal = classes = fractions.Fraction()
for start, end in zip(points, points[1:]):
pitches = [{n['pitch'] for n in notes if n['start'] <= start < n['end']} for notes in ns]
if any(pitches):
occupied += end - start
if pitches[0] == pitches[1]:
equal += end - start
if {p % 12 for p in pitches[0]} == {p % 12 for p in pitches[1]}:
classes += end - start
pitches = [[n['pitch'] for n in notes] for notes in ns]
rhythms = [[(n['start'], n['end'] - n['start']) for n in notes] for notes in ns]
return {'pitch_sequence_edit_distance': distance(*pitches),
'timed_attack_edit_distance': distance(*rhythms),
'normalization_attacks': max(len(a), len(b)),
'same_sounding_pitch_beats': str(equal), 'same_pitch_class_beats': str(classes),
'either_sounding_beats': str(occupied),
'interpretation': 'Separate descriptive comparisons, not a quality score. Pitch distance ignores timing; timing distance ignores pitch. Held overlap uses the original aligned register and includes lead-ins.'}
def run(generated_dir, reference_paths, starts, pitch_convention, output, baseline_dir=None):
generated_dir, output = pathlib.Path(generated_dir), pathlib.Path(output)
manifest = json.loads((generated_dir / 'manifest.solo').read_text())
output.mkdir(parents=True, exist_ok=True)
baseline_manifest = json.loads((pathlib.Path(baseline_dir) / 'manifest.solo').read_text()) if baseline_dir else None
result = {'comparison_only': True, 'feeds_generation': False, 'solos': {}}
for role, path in sorted(reference_paths.items()):
item = manifest['solos'][role]
actual = generator.training_io.read(generated_dir / item['file'], role, item['form_start_measure'])
expected = generator.training_io.read(path, role, starts.get(role), pitch_convention)
review = compare(actual, expected)
baseline = None
if baseline_manifest:
old = baseline_manifest['solos'][role]
baseline = generator.training_io.read(pathlib.Path(baseline_dir) / old['file'], role, old['form_start_measure'])
review['baseline'] = musical_summary(baseline)
review['baseline_relationships'] = relationships(events(baseline), events(expected))
review['production_trace'] = item['trace']
review['production_phrases'] = item.get('phrase_report', {})
candidates = review['production_phrases'].get('selection_trace', {}).get('opening_candidates', [])
# Preserve the real role cutoff; reference material beyond it is not trimmed.
phrases = review['production_phrases'].get('phrases', [])
if phrases:
cutoff = max(fractions.Fraction(p['end']) for p in phrases)
review['production_end'] = str(cutoff)
review['reference_events_after_production_end'] = [n for n in events(expected) if fractions.Fraction(n['end']) > cutoff]
result['solos'][role] = review
output.mkdir(parents=True, exist_ok=True)
(output / 'comparison.json').write_text(json.dumps(result, indent=2) + '\n')
rows = ['<!doctype html><meta charset="utf-8"><title>Solo comparison</title>',
'<style>body{font:16px system-ui;max-width:1100px;margin:2rem auto}td,th{padding:.5rem;text-align:left}pre{white-space:pre-wrap}</style>',
'<h1>Completed solos and reference scores</h1><p>Differences are diagnostic. This comparison is read-only; registered authored scores are explicit repertoire inputs, and pooled examples supply training evidence. No listening verdict is claimed.</p>',
'<p><a href="comparison.json">Exact timing, notes, harmony, annotations, placement, and phrase reports</a></p>']
for role, r in result['solos'].items():
actual_path = generated_dir / manifest['solos'][role]['file']
reference_path = pathlib.Path(reference_paths[role])
rows += ['<h2>' + html.escape(role) + '</h2>', f'<p>Exact event match: <strong>{"yes" if r["exact_musical_match"] else "no"}</strong>. {r["exact_matching_attacks"]} exactly matching attacks; {len(r["differences"])} differing onset positions. This is not a musical-quality score.</p>',
'<p><a href="' + html.escape(os.path.relpath(actual_path, output)) + '">Generated MusicXML</a> · <a href="' + html.escape(os.path.relpath(reference_path, output)) + '">Untouched reference MusicXML</a></p>']
if baseline_manifest:
baseline_path = pathlib.Path(baseline_dir) / baseline_manifest['solos'][role]['file']
rows.append('<p><a href="' + html.escape(os.path.relpath(baseline_path, output)) + '">Previous generated MusicXML</a></p>')
rows.append('<table><tr><th>Diagnostic against reference</th><th>Current</th><th>Baseline</th></tr>')
for key in ('pitch_sequence_edit_distance', 'timed_attack_edit_distance', 'same_sounding_pitch_beats', 'same_pitch_class_beats', 'either_sounding_beats'):
rows.append('<tr><td>' + key.replace('_', ' ') + '</td><td>' + str(r['relationships'][key]) + '</td><td>' + str(r.get('baseline_relationships', {}).get(key, '—')) + '</td></tr>')
rows.append('</table><p>Lower edit distance means fewer insertions, deletions or substitutions on that axis. Sounding agreement is measured in quarter-note beats, without octave shifting or fitted alignment. These do not measure musical quality.</p>')
selected = collections.Counter(c['kind'] for c in r['production_phrases'].get('expressions', []))
rows.append('<p>Validated production treatments: ' + html.escape(str(dict(selected))) + '. Registered authored music is preserved; harmonic relationships are recognized from notes and chords without requiring explanatory annotations.</p>')
if r.get('reference_events_after_production_end'):
rows.append('<p>Reference material extends beyond this exported production allocation: ' + str(len(r['reference_events_after_production_end'])) + ' events. The reference and source timing remain unchanged.</p>')
funnel = r['production_phrases'].get('selection_trace', {}).get('operation_coverage', {})
if funnel:
stages = tuple(dict.fromkeys(k for counts in funnel.values() for k in counts))
rows.append('<details><summary>Construction coverage (not similarity scoring)</summary><table><tr><th>Purpose</th>' + ''.join('<th>' + k.replace('_', ' ') + '</th>' for k in stages) + '</tr>')
for purpose, counts in sorted(funnel.items()):
rows.append('<tr><td>' + html.escape(purpose) + '</td>' + ''.join('<td>' + str(counts.get(k, 0)) + '</td>' for k in stages) + '</tr>')
rows.append('</table></details>')
candidates = r['production_phrases'].get('selection_trace', {}).get('opening_candidates', [])
if candidates:
rows.append('<details open><summary>Completed source-only opening candidates</summary><p>All candidates were composed without the references. Selection accounts for later phrases; the final choice need not have the cheapest opening alone.</p><table><tr><th>Candidate</th><th>Final choice</th><th>Purpose</th><th>Score contributions</th></tr>')
for index, c in enumerate(candidates, 1):
rows.append('<tr>' + ''.join('<td>' + html.escape(str(v)) + '</td>' for v in (index, c['selected_in_final_solo'], c['purpose'], c['evaluation']['contributions'])) + '</tr>')
rows.append('</table></details>')
rows.append('<details><summary>Exact note differences</summary><table><tr><th>Beat relative to form</th><th>Generated</th><th>Reference</th></tr>')
for d in r['differences']:
def describe(ns): return '; '.join(f'MIDI {n["pitch"]}, until {n["end"]}' for n in ns) or 'No attack'
rows.append('<tr>' + ''.join('<td>' + html.escape(v) + '</td>' for v in (d['time'], describe(d['generated']), describe(d['reference']))) + '</tr>')
rows.append('</table></details>')
(output / 'index.html').write_text('\n'.join(rows))
return result
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--generated-dir', type=pathlib.Path, required=True)
parser.add_argument('--reference', action='append', default=[], metavar='SONG/ROLE=PATH')
parser.add_argument('--form-start', action='append', default=[], metavar='SONG/ROLE=MEASURE')
parser.add_argument('--reference-pitch', choices=('encoded', 'guitar-written'), default='encoded')
parser.add_argument('--output', type=pathlib.Path, required=True)
parser.add_argument('--baseline-dir', type=pathlib.Path, help='Optional previous completed solo exports; never generation inputs.')
parser.add_argument('--require-exact', action='store_true', help='Fail unless every requested reference has identical complete sounding events and rests.')
args = parser.parse_args()
if args.require_exact and not args.reference:
parser.error('--require-exact requires at least one explicit --reference')
result = run(args.generated_dir, dict(x.split('=', 1) for x in args.reference),
{k: int(v) for k, v in (x.split('=', 1) for x in args.form_start)}, args.reference_pitch, args.output, args.baseline_dir)
for role, review in result['solos'].items():
print(f'{role}: exact={review["exact_musical_match"]}; matching attacks={review["exact_matching_attacks"]}; differing onsets={len(review["differences"])}; rests differ={review["rest_difference"]}')
return 1 if args.require_exact and any(not r['exact_musical_match'] for r in result['solos'].values()) else 0
if __name__ == '__main__':
raise SystemExit(main())
+2 -2
View File
@@ -1,6 +1,6 @@
import copy, fractions
import generator.model, generator.parts, generator.harmony
import generator.solo.analysis, generator.solo.composer, generator.solo.types
import generator.source, generator.solo.composer, generator.solo.types
import tests.test_musicxml
import generator.harmonic_time
@@ -20,7 +20,7 @@ def song(meter=4, count=6, chords=('Dm7', 'G7', 'CM7')):
return generator.parts.prepare_document(document)
def compose(document, part='acoustic', cutoff=None):
analysis = generator.solo.analysis.analyze(document)
analysis = generator.source.analyze(document)
measures = document['staves'][0]['measures']
end = sum(generator.model.fraction(m['duration']) for m in measures) if cutoff is None else cutoff
return generator.solo.composer.compose(analysis, measures, part, end)
+11 -5
View File
@@ -1,3 +1,4 @@
#include <vamp_zero/menu.hpp>
#include <test.hpp>
#include "catalog_fixture.hpp"
@@ -157,7 +158,12 @@ BOOST_AUTO_TEST_CASE(settings_menu_toggles_audio_settings_and_edits_tempo) {
BOOST_TEST(state.audio.metronome_enabled);
BOOST_TEST(static_cast<std::int32_t>(state.mode) == static_cast<std::int32_t>(vamp_zero::app_mode::SETTINGS_MENU));
state = vamp_zero::apply_app_command(std::move(state), vamp_protocol::page_command::NEXT);
BOOST_TEST(state.selected_settings_index == 3U);
BOOST_TEST(state.selected_settings_index == vamp_zero::settings_row::solos);
BOOST_TEST(state.solos_enabled);
state = vamp_zero::apply_app_command(std::move(state), vamp_protocol::page_command::SELECT);
BOOST_TEST(!state.solos_enabled);
state = vamp_zero::apply_app_command(std::move(state), vamp_protocol::page_command::NEXT);
BOOST_TEST(state.selected_settings_index == vamp_zero::settings_row::tempo);
state = vamp_zero::apply_app_command(std::move(state), vamp_protocol::page_command::SELECT);
BOOST_TEST(state.audio.tempo_editing);
state = vamp_zero::apply_app_command(std::move(state), vamp_protocol::page_command::NEXT);
@@ -179,7 +185,7 @@ BOOST_AUTO_TEST_CASE(settings_menu_toggles_audio_settings_and_edits_tempo) {
BOOST_AUTO_TEST_CASE(remote_display_reports_settings_without_a_catalog_dump) {
auto state = navigation_state();
state.mode = vamp_zero::app_mode::SETTINGS_MENU;
state.selected_settings_index = 3U;
state.selected_settings_index = vamp_zero::settings_row::tempo;
state.audio.backing_enabled = true;
state.audio.metronome_enabled = true;
state.audio.tempo_bpm = 110;
@@ -245,7 +251,7 @@ BOOST_AUTO_TEST_CASE(empty_catalog_navigation_and_main_menu_wrap) {
BOOST_AUTO_TEST_CASE(song_part_navigation_preserves_selection_and_remote_display) {
auto parts = std::vector<vamp_zero::library_part>{};
for (auto name : {"Acoustic", "Electric", "Vocal"}) {
parts.push_back({.id = name, .title = "Song", .composer = "Composer", .part = name, .total_pages = 3});
parts.push_back({.id = name, .title = "Song", .composer = "Composer", .part = name, .total_pages = 3, .playback_pages = 5});
}
auto state = vamp_zero::app_state{
.catalog = std::make_shared<vamp_zero::catalog const>(vamp_zero::group_ordered_parts(std::move(parts))),
@@ -264,7 +270,7 @@ BOOST_AUTO_TEST_CASE(song_part_navigation_preserves_selection_and_remote_display
BOOST_REQUIRE(vamp_pico::parse_remote_display_body(vamp_zero::remote_display_text(state), remote));
BOOST_TEST(remote.active);
BOOST_TEST(std::string{remote.part} == name);
BOOST_TEST(remote.pages == 3U);
BOOST_TEST(remote.pages == 5U);
for (auto index = std::uint32_t{}; index < 4U; ++index) {
state = vamp_zero::apply_app_command(std::move(state), vamp_protocol::page_command::NEXT);
}
@@ -291,7 +297,7 @@ BOOST_AUTO_TEST_CASE(database_reload_preserves_all_generated_song_parts) {
auto expected = std::size_t{};
for (auto const &entry : std::filesystem::directory_iterator{std::filesystem::path{VAMP_TEST_SOURCE_DIR} / "data/songs"}) {
if (entry.is_regular_file() && entry.path().extension() == ".xml") {
expected += 3U;
expected += 5U;
}
}
BOOST_REQUIRE(expected > 0U);
+5 -5
View File
@@ -1,10 +1,10 @@
import generator.validation
import copy
import fractions
import pathlib
import unittest
import unittest.mock
import generator.accompaniment
import generator.acoustic
import generator.arrange.generate
import generator.engraving.fonts
@@ -41,19 +41,19 @@ def acoustic_document(bars):
for note in notes:
note.update(voice=lane, stem='down' if lane == 'bass' else 'up')
measure['voices'].append({'id': lane, 'notes': notes})
generator.model.validate_document(document)
generator.validation.validate_document(document)
return document
class AcousticTests(unittest.TestCase):
def combine(self, document):
generator.acoustic.prepare(document)
generator.model.validate_document(document)
generator.validation.validate_document(document)
prepared = copy.deepcopy(document)
generator.acoustic.prepare(document)
self.assertEqual(document, prepared)
before = sounding(document)
generator.acoustic.combine(document)
generator.model.validate_document(document)
generator.validation.validate_document(document)
self.assertEqual(sounding(document), before)
self.assertTrue(all(len(m['voices']) == 1 for m in document['staves'][0]['measures']))
for measure in document['staves'][0]['measures']:
@@ -130,7 +130,7 @@ class AcousticTests(unittest.TestCase):
separate = builder(source, 'acoustic')
combined = builder(source, 'acoustic')
self.assertEqual(sounding(separate), sounding(combined))
generator.model.validate_document(combined)
generator.validation.validate_document(combined)
for measure in combined['staves'][0]['measures']:
self.assertIn(len(measure['voices']), (1, 2))
if len(measure['voices']) == 2:

Some files were not shown because too many files have changed in this diff Show More