Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,10 @@ A note is read as fact by a player, so it is written like one:
mainstream teaching, not a personal reading.
- **Check every bar against the file**, not against a recording or another
edition: links use the numbers the file gives its bars (a pickup is often
0), and what the text says happens there must be what that file has.
0), and what the text says happens there must be what that file has. A
link from the first full bar is drawn from the pickup before it, so a
theme is heard from its upbeat without naming bar 0 (`drawExcerpt` in
`public/js/scoreExcerpt.js`).
`test/js/about.test.js` fails on a bar the score does not have or gives the
same number to twice (the Gnossienne numbers all its bars 0), on a link one
language has and the other lacks, and on a tab past its length cap. The
Expand Down
3 changes: 2 additions & 1 deletion public/js/about.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
// carries on over indented lines), **bold**, *italic*, and bar links.
// A bar link — [m. 21–27](#m21-27) — names bars as the score's file numbers
// them, which is what the sheet prints. Tapped, it unfolds those bars drawn
// under its sentence (scoreExcerpt.js).
// under its sentence (scoreExcerpt.js), from the pickup when they start at the
// first full bar.
//
// test/js/about.test.js holds every note to the files naming it: both
// languages, the same bars linked in each, only bars the score has.
Expand Down
6 changes: 5 additions & 1 deletion public/js/scoreExcerpt.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,14 @@ export async function toggleBarExcerpt(link, xml) {
// than through OSMD's drawFromMeasureNumber, which guesses at a pickup bar
// from durations; a bar split in two (barCounter in fingeringKeys.js) carries
// its number on both halves, and both are drawn.
//
// A passage from the first full bar starts on the pickup before it, which
// is where its tune starts: "the theme, bars 1–4" is heard from its upbeat.
async function drawExcerpt(container, xml, { from, to }) {
const osmd = await loadSheet(container, xml, { drawCredits: false })
const bars = osmd.Sheet.SourceMeasures
osmd.rules.MinMeasureToDrawIndex = bars.findIndex((bar) => bar.MeasureNumberXML === from)
const first = bars.findIndex((bar) => bar.MeasureNumberXML === from)
osmd.rules.MinMeasureToDrawIndex = first === 1 && bars[0].ImplicitMeasure ? 0 : first
osmd.rules.MaxMeasureToDrawIndex = bars.findLastIndex((bar) => bar.MeasureNumberXML === to)
osmd.zoom = EXCERPT_ZOOM
placeChordFingerings(bars)
Expand Down
13 changes: 13 additions & 0 deletions test/about_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,19 @@ def test_a_link_from_the_pickup_bar_draws_it
end
end

# A theme starts on its upbeat: a link from the first full bar draws the
# pickup before it too, the Nocturne's B♭ ahead of bar 1.
def test_a_link_from_the_first_full_bar_draws_its_pickup
visit '/score.html?url=scores/Chopin_-_Nocturne_Op_9_No_2_E_Flat_Major.mxl'
wait_for_score_render

find('button.pt-about-button').click
within('#aboutModal') do
click_button 'm. 1–4'
assert_selector '.pt-bar-excerpt svg .vf-measure', count: 10
end
end

def test_a_score_without_a_note_has_no_about_button
visit '/score.html?url=scores/Swan_Lake.mxl'
wait_for_score_render
Expand Down
Loading