feat(engraving): add configurable rest position settings#2693
feat(engraving): add configurable rest position settings#2693roscopeeco wants to merge 2 commits into
Conversation
Adds `restPositionMain` and `restPositionSecondary` properties to `EngravingSettings`, allowing the vertical position of rests to be overridden per-voice via the `RestPosition` enum. The `RestPosition` enum provides named staff-line positions (Line1-Line5 and the spaces between) calibrated to a 5-line staff. Positions are adjusted automatically for staves with fewer than 5 lines using the formula `override - (5 - lineCount) * 2`. When either property is null (the default), rest positioning falls back to the existing auto-calculated behaviour so there is no change to existing scores. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
I'm thinking we could make this more granular and add per track settings for restPositionMain and restPositionSecondary. This would be done on a per track basis in the score...something like track.settings.restPositionMain etc. |
Adds RestPosition.test.ts with 21 visual tests covering: - Default rendering (single voice and multi-voice) with no settings applied - All RestPosition enum values for restPositionMain - All rest durations with an override applied - Multi-voice scenarios (both set, main only, secondary only) - Staff line counts 1-5 to verify the line count adjustment formula Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Just added a set of tests. There is one pre-existing issue that the second test shows. The image rest-position-default-multi-voice.png highlights the issue. The test doesn't apply any settings but in the image the secondary voice rest on bars 3 & 6 is above the staff |
|
I had a look at the code and the base already looks quite good. The biggest design contradiction currently is in where to configure rest positions. Looking at MusicXML the position of rests can be overridden for every rest individually via
Having a "primary/secondary" displacement like you propose it, is still possible via a rewrite pass in the Importer wise we should then support:
You can try to make an overall implementation if you like. Otherwise if you take care of the base (model + rendering) I can take over the importer support. |
|
ok thanks for the response. I've got some questions for you:
i'm ok doing the model and rendering and can add the alphaTex beat metadata tags...i assume they are mimicking the musicXML naming? and then the imports handling are left to you? |
For alphaTex it likely makes sense to just have one tag which accepts a pitch value like |
|
Is there an existing staff property that indicates the starting octave for the staff? So the calculation would use this property as the baseline when using restDisplayTone and restDisplayOctave to determine the rendered rest position? |
|
|
Okay, my only query is the naming of restDisplayTone. In English, this doesn't sound correct. To me, it would be restDisplay Pitch? A, B, C, D, E, F, G are pitches not tones? |
|
Naming can indeed be tricky but I think my proposal is in-line to what we have and what a theoretically correct terminology. The pitch of a note is the perceived frequency. In music notation and most file formats this is represented with up to 3 parts:
e.g. In alphaTab we have adopted the Guitar Pro taxonomy (Octave+Tone+Accidental). MusicXML expresses a pitch as step, octave and "alter" triple. "rest display tone" and "rest display octave" together make the "rest display pitch". it was a fairly straight forward combination of https://www.w3.org/2021/06/musicxml40/musicxml-reference/elements/rest/
Side note: we also have the term "tuning" in alphaTab, mainly used for actual string tuning representation, but its a useful helper used at other places. |
|
Fair enough regarding your last comment. I've created a new PR.#2721 with the new requirements. This is based on a separate fork. So you should be able to make your XML importer changes on top of this. |
Issues
#2572
Fixes #
Proposed changes
Adds
restPositionMainandrestPositionSecondaryproperties toEngravingSettings, allowing the vertical position of rests to be overridden per-voice via theRestPositionenum.The
RestPositionenum provides named staff-line positions (Line1-Line5 and the spaces between) calibrated to a 5-line staff. Positions are adjusted automatically for staves with fewer than 5 lines using the formulaoverride - (5 - lineCount) * 2.When either property is null (the default), rest positioning falls back to the existing auto-calculated behaviour so there is no change to existing scores.
These changes are purely to the typescript source code.
Checklist
I've tested it using creating a restPositionMain setting in the playground/demo/control app (this was not included in the pr). The test just dealt with a 5 line staff case. If you are happy with the content of the changes but need test i can investigate your test suite to see how they should be applied.
Further details