SPB Git

Repository Public

score.md 3.8 KB

# Score

The Score space shows the compiled composition as staff notation and exports it. It is a faithful transcription, not professional engraving: every note the compiler produced is written with the duration notated in the source, but spacing and collisions are not optimised the way an engraver would.

# What you see

  • One staff per instrument track, grouped in systems that are broken to the page width and justified; pages in US Letter or A4.
  • Clef per part: bass when the mean written pitch is below G3, alto for a track or instrument named viola, percussion (notes on the middle line) for kick, snare and hihat, treble otherwise.
  • Key signature of the composition's key (modes use the signature of their relative major), time signatures at every change, tempo marks at each tempo point.
  • The measure under the playhead is tinted while playing; the view follows it page by page.
  • Click a note to select it; double-click to jump to the statement that produced it.

# Rules applied (the same for the screen, the PDF and MusicXML)

They are implemented once, in crates/sonata-interop/src/score.rs (engrave), and tested there.

Rule Behaviour
Durations Split into dotted values, largest first; a note crossing a bar line is tied.
Tuplets Triplets, quintuplets and septuplets are recognised from the exact rational duration. Anything else is quantised to a 128th and reported.
Rests A rest starting off the beat is split at the next beat (dotted-quarter beat in 6/8, 9/8, 12/8). A silent voice is not drawn when another voice of the staff plays.
Accidentals Printed when the alteration differs from the key signature or from an earlier note of the same measure on the same line (all voices of the staff together). The second note of a tie repeats nothing.
Beams Consecutive notes shorter than a quarter inside one beat.
Stems With several sounding voices: first voice up, second down. Otherwise by the note farthest from the middle line; one direction per beam.
Transposing parts The written pitch is the sounding pitch plus the part's transposition; MusicXML carries <transpose>.
Microtones Quarter tones are drawn as half sharps and half flats; other deviations as the nearest accidental with an arrow.

Approximations are never silent: the toolbar shows a warning with the list (quantised durations, voices beyond four per staff, microtonal spelling).

# Not handled

Slurs, dynamics, hairpins, lyrics, chord symbols, repeats and voltas; a grand staff for keyboards (each track is one staff); clef changes inside a part; cross-staff and cross-measure beams, beams over rests; collision avoidance between voices; nested tuplets; tempo ramps (only the tempo points are printed) and swing notation; mid-piece key changes; courtesy accidentals; multi-measure rests; part extraction; visual editing of the score (edit the code, or the notes in the Studio's piano roll).

# Export

Format How Checked by
PDF Vector drawing through Core Graphics, one PDF page per score page; text stays text. Reopened with PDFKit in the tests (page count, page size, title text).
MusicXML 4.0 score-partwise, with voices, ties, tuplets, accidentals, stems and beams. Every example is validated with xmllint and each measure's durations are summed.
MIDI Format 1, 960 ticks per quarter note. Microtones are rounded to the semitone and reported. Parsed back; note counts compared with the program.

The same exports exist on the command line: sonata export piece.sonata --output piece.musicxml.

The clef signs are glyphs of the system font Apple Symbols; every other shape (noteheads, stems, flags, beams, rests, accidentals, ties, brackets) is a path drawn by the application.

Files main
Menu

Theme