Skip to content

feat(engraving): add configurable rest position settings#2693

Open
roscopeeco wants to merge 2 commits intoCoderLine:developfrom
roscopeeco:feature/rest-position-setting
Open

feat(engraving): add configurable rest position settings#2693
roscopeeco wants to merge 2 commits intoCoderLine:developfrom
roscopeeco:feature/rest-position-setting

Conversation

@roscopeeco
Copy link
Copy Markdown

@roscopeeco roscopeeco commented May 5, 2026

Issues

#2572

Fixes #

Proposed changes

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.

These changes are purely to the typescript source code.

Checklist

  • [x ] I consent that this change becomes part of alphaTab under it's current or any future open source license
  • Changes are implemented
  • New tests were added
    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

  • This is a breaking change
  • [ X] This change will require update of the documentation/website

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>
@roscopeeco
Copy link
Copy Markdown
Author

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>
@roscopeeco
Copy link
Copy Markdown
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant