Loading…
Loading…
Rule
Gradus GE-214 · cite this code — it is permanent. Rule id pitch-based-stem-fallback-treble-threshold-and-chord-extremum-bug
Two independent conventions govern stem direction when a voice is NOT role-forced (a lone voice on its own stave — open score, stacked, grand-staff, or the odd voice in a 3-voice SATB texture — falls back to this path per `resolveVoices`'s `stem: null`). First: single-note stem direction switches exactly at the staff's middle line — notes AT or ABOVE the middle line stem down, notes BELOW stem up. The middle line is B4 in treble clef (`pitchToDiatonic('B4') = 34`) and D3 in bass clef (`pitchToDiatonic('D3') = 22`). Second: for a CHORD, stem direction is decided by whichever notehead is FARTHEST from the middle line (the extreme that would need the longer stem), not simply the chord's highest note — a chord with a note just above the line and another note far below it stems by the far note, not the near one.
Gould, Behind Bars, ch. on stems: the middle-line switch point, and the 'note farthest from the middle line governs a chord's stem direction' rule, are both stated directly and are also how VexFlow's own single-voice default (`StaveNote.getStemDirection`) and Dorico's stem engine behave. This rule is a code-correctness finding, not a citation dispute — Gradus's OWN pitch-based branch (used specifically as the fallback for voices resolveVoices leaves unforced) does not implement either convention correctly.
This rule can be decided from pitches, durations and voices — no layout required. A validator can check it before anything is drawn.
Gradus GE-214 — The pitch-based (unforced) stem-direction fallback has TWO confirmed bugs: the treble middle-line threshold is a third too low, and chord stem direction uses only the highest note instead of whichever extreme is farthest from the middle line. Gradus Engraving Rulebook v1.0. https://gradusmusic.com/engraving/rule/pitch-based-stem-fallback-treble-threshold-and-chord-extremum-bug
Rulebook v1.0 · text licensed CC-BY-4.0 · machine-readable at /api/v1/engraving/rules/pitch-based-stem-fallback-treble-threshold-and-chord-extremum-bug