-
Notifications
You must be signed in to change notification settings - Fork 262
feat(rendering): add per-beat rest display position via beat.restDisplayTone, beat.restDisplayOctave #2721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
roscopeeco
wants to merge
1
commit into
CoderLine:develop
Choose a base branch
from
roscopeeco:feature/rest-position-v2
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat(rendering): add per-beat rest display position via beat.restDisplayTone, beat.restDisplayOctave #2721
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+28.6 KB
...est-data/visual-tests/rest-position/alto/rest-position-multi-voice-both-set.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+24.4 KB
...test-data/visual-tests/rest-position/alto/rest-position-multi-voice-default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+27.3 KB
...ual-tests/rest-position/alto/rest-position-multi-voice-main-only-D4-space-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+25.9 KB
...tests/rest-position/alto/rest-position-multi-voice-secondary-only-F3-line-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+21 KB
...tab/test-data/visual-tests/rest-position/alto/rest-position-pitch-A3-line-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+21.1 KB
...ab/test-data/visual-tests/rest-position/alto/rest-position-pitch-A4-space-5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+21.1 KB
...ab/test-data/visual-tests/rest-position/alto/rest-position-pitch-B3-space-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+21.1 KB
...tab/test-data/visual-tests/rest-position/alto/rest-position-pitch-C4-line-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+21.2 KB
...ab/test-data/visual-tests/rest-position/alto/rest-position-pitch-D4-space-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+21.1 KB
...tab/test-data/visual-tests/rest-position/alto/rest-position-pitch-E4-line-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+20.8 KB
...tab/test-data/visual-tests/rest-position/alto/rest-position-pitch-F3-line-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+21.2 KB
...ab/test-data/visual-tests/rest-position/alto/rest-position-pitch-F4-space-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+21 KB
...ab/test-data/visual-tests/rest-position/alto/rest-position-pitch-G3-space-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+20.9 KB
...tab/test-data/visual-tests/rest-position/alto/rest-position-pitch-G4-line-5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.84 KB
...ab/test-data/visual-tests/rest-position/alto/rest-position-staff-lines-1-F3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.68 KB
...ab/test-data/visual-tests/rest-position/alto/rest-position-staff-lines-2-F3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.58 KB
...ab/test-data/visual-tests/rest-position/alto/rest-position-staff-lines-3-F3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.46 KB
...ab/test-data/visual-tests/rest-position/alto/rest-position-staff-lines-4-F3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.44 KB
...ab/test-data/visual-tests/rest-position/alto/rest-position-staff-lines-5-F3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+27.8 KB
...est-data/visual-tests/rest-position/bass/rest-position-multi-voice-both-set.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+23.6 KB
...test-data/visual-tests/rest-position/bass/rest-position-multi-voice-default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+26.5 KB
...ual-tests/rest-position/bass/rest-position-multi-voice-main-only-E3-space-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+25.2 KB
...tests/rest-position/bass/rest-position-multi-voice-secondary-only-G2-line-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+20.3 KB
...ab/test-data/visual-tests/rest-position/bass/rest-position-pitch-A2-space-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+20.2 KB
...tab/test-data/visual-tests/rest-position/bass/rest-position-pitch-A3-line-5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+20.3 KB
...tab/test-data/visual-tests/rest-position/bass/rest-position-pitch-B2-line-2.png
Oops, something went wrong.
Binary file added
BIN
+20.4 KB
...ab/test-data/visual-tests/rest-position/bass/rest-position-pitch-B3-space-5.png
Oops, something went wrong.
Binary file added
BIN
+20.4 KB
...ab/test-data/visual-tests/rest-position/bass/rest-position-pitch-C3-space-2.png
Oops, something went wrong.
Binary file added
BIN
+20.4 KB
...tab/test-data/visual-tests/rest-position/bass/rest-position-pitch-D3-line-3.png
Oops, something went wrong.
Binary file added
BIN
+20.4 KB
...ab/test-data/visual-tests/rest-position/bass/rest-position-pitch-E3-space-3.png
Oops, something went wrong.
Binary file added
BIN
+20.3 KB
...tab/test-data/visual-tests/rest-position/bass/rest-position-pitch-F3-line-4.png
Oops, something went wrong.
Binary file added
BIN
+20.1 KB
...tab/test-data/visual-tests/rest-position/bass/rest-position-pitch-G2-line-1.png
Oops, something went wrong.
Binary file added
BIN
+20.4 KB
...ab/test-data/visual-tests/rest-position/bass/rest-position-pitch-G3-space-4.png
Oops, something went wrong.
Binary file added
BIN
+7.59 KB
...ab/test-data/visual-tests/rest-position/bass/rest-position-staff-lines-1-G2.png
Oops, something went wrong.
Binary file added
BIN
+7.4 KB
...ab/test-data/visual-tests/rest-position/bass/rest-position-staff-lines-2-G2.png
Oops, something went wrong.
Binary file added
BIN
+7.3 KB
...ab/test-data/visual-tests/rest-position/bass/rest-position-staff-lines-3-G2.png
Oops, something went wrong.
Binary file added
BIN
+7.16 KB
...ab/test-data/visual-tests/rest-position/bass/rest-position-staff-lines-4-G2.png
Oops, something went wrong.
Binary file added
BIN
+7.04 KB
...ab/test-data/visual-tests/rest-position/bass/rest-position-staff-lines-5-G2.png
Oops, something went wrong.
Binary file added
BIN
+20.8 KB
packages/alphatab/test-data/visual-tests/rest-position/rest-position-default.png
Oops, something went wrong.
Binary file added
BIN
+28.6 KB
...st-data/visual-tests/rest-position/tenor/rest-position-multi-voice-both-set.png
Oops, something went wrong.
Binary file added
BIN
+24.3 KB
...est-data/visual-tests/rest-position/tenor/rest-position-multi-voice-default.png
Oops, something went wrong.
Binary file added
BIN
+27.2 KB
...al-tests/rest-position/tenor/rest-position-multi-voice-main-only-B3-space-3.png
Oops, something went wrong.
Binary file added
BIN
+25.9 KB
...ests/rest-position/tenor/rest-position-multi-voice-secondary-only-D3-line-1.png
Oops, something went wrong.
Binary file added
BIN
+21.1 KB
...ab/test-data/visual-tests/rest-position/tenor/rest-position-pitch-A3-line-3.png
Oops, something went wrong.
Binary file added
BIN
+21.2 KB
...b/test-data/visual-tests/rest-position/tenor/rest-position-pitch-B3-space-3.png
Oops, something went wrong.
Binary file added
BIN
+21.1 KB
...ab/test-data/visual-tests/rest-position/tenor/rest-position-pitch-C4-line-4.png
Oops, something went wrong.
Binary file added
BIN
+20.8 KB
...ab/test-data/visual-tests/rest-position/tenor/rest-position-pitch-D3-line-1.png
Oops, something went wrong.
Binary file added
BIN
+21.2 KB
...b/test-data/visual-tests/rest-position/tenor/rest-position-pitch-D4-space-4.png
Oops, something went wrong.
Binary file added
BIN
+20.9 KB
...b/test-data/visual-tests/rest-position/tenor/rest-position-pitch-E3-space-1.png
Oops, something went wrong.
Binary file added
BIN
+21 KB
...ab/test-data/visual-tests/rest-position/tenor/rest-position-pitch-E4-line-5.png
Oops, something went wrong.
Binary file added
BIN
+21 KB
...ab/test-data/visual-tests/rest-position/tenor/rest-position-pitch-F3-line-2.png
Oops, something went wrong.
Binary file added
BIN
+21.1 KB
...b/test-data/visual-tests/rest-position/tenor/rest-position-pitch-F4-space-5.png
Oops, something went wrong.
Binary file added
BIN
+21 KB
...b/test-data/visual-tests/rest-position/tenor/rest-position-pitch-G3-space-2.png
Oops, something went wrong.
Binary file added
BIN
+7.87 KB
...b/test-data/visual-tests/rest-position/tenor/rest-position-staff-lines-1-D3.png
Oops, something went wrong.
Binary file added
BIN
+7.66 KB
...b/test-data/visual-tests/rest-position/tenor/rest-position-staff-lines-2-D3.png
Oops, something went wrong.
Binary file added
BIN
+7.59 KB
...b/test-data/visual-tests/rest-position/tenor/rest-position-staff-lines-3-D3.png
Oops, something went wrong.
Binary file added
BIN
+7.51 KB
...b/test-data/visual-tests/rest-position/tenor/rest-position-staff-lines-4-D3.png
Oops, something went wrong.
Binary file added
BIN
+7.37 KB
...b/test-data/visual-tests/rest-position/tenor/rest-position-staff-lines-5-D3.png
Oops, something went wrong.
Binary file added
BIN
+30.5 KB
...t-data/visual-tests/rest-position/treble/rest-position-multi-voice-both-set.png
Oops, something went wrong.
Binary file added
BIN
+26.4 KB
...st-data/visual-tests/rest-position/treble/rest-position-multi-voice-default.png
Oops, something went wrong.
Binary file added
BIN
+29.3 KB
...l-tests/rest-position/treble/rest-position-multi-voice-main-only-C5-space-3.png
Oops, something went wrong.
Binary file added
BIN
+27.9 KB
...sts/rest-position/treble/rest-position-multi-voice-secondary-only-E4-line-1.png
Oops, something went wrong.
Binary file added
BIN
+22 KB
.../test-data/visual-tests/rest-position/treble/rest-position-pitch-A4-space-2.png
Oops, something went wrong.
Binary file added
BIN
+21.9 KB
...b/test-data/visual-tests/rest-position/treble/rest-position-pitch-B4-line-3.png
Oops, something went wrong.
Binary file added
BIN
+22 KB
.../test-data/visual-tests/rest-position/treble/rest-position-pitch-C5-space-3.png
Oops, something went wrong.
Binary file added
BIN
+21.9 KB
...b/test-data/visual-tests/rest-position/treble/rest-position-pitch-D5-line-4.png
Oops, something went wrong.
Binary file added
BIN
+21.6 KB
...b/test-data/visual-tests/rest-position/treble/rest-position-pitch-E4-line-1.png
Oops, something went wrong.
Binary file added
BIN
+22 KB
.../test-data/visual-tests/rest-position/treble/rest-position-pitch-E5-space-4.png
Oops, something went wrong.
Binary file added
BIN
+21.8 KB
.../test-data/visual-tests/rest-position/treble/rest-position-pitch-F4-space-1.png
Oops, something went wrong.
Binary file added
BIN
+21.8 KB
...b/test-data/visual-tests/rest-position/treble/rest-position-pitch-F5-line-5.png
Oops, something went wrong.
Binary file added
BIN
+21.9 KB
...b/test-data/visual-tests/rest-position/treble/rest-position-pitch-G4-line-2.png
Oops, something went wrong.
Binary file added
BIN
+21.9 KB
.../test-data/visual-tests/rest-position/treble/rest-position-pitch-G5-space-5.png
Oops, something went wrong.
Binary file added
BIN
+8.26 KB
.../test-data/visual-tests/rest-position/treble/rest-position-staff-lines-1-E4.png
Oops, something went wrong.
Binary file added
BIN
+8.06 KB
.../test-data/visual-tests/rest-position/treble/rest-position-staff-lines-2-E4.png
Oops, something went wrong.
Binary file added
BIN
+7.92 KB
.../test-data/visual-tests/rest-position/treble/rest-position-staff-lines-3-E4.png
Oops, something went wrong.
Binary file added
BIN
+7.82 KB
.../test-data/visual-tests/rest-position/treble/rest-position-staff-lines-4-E4.png
Oops, something went wrong.
Binary file added
BIN
+7.82 KB
.../test-data/visual-tests/rest-position/treble/rest-position-staff-lines-5-E4.png
Oops, something went wrong.
197 changes: 197 additions & 0 deletions
197
packages/alphatab/test/visualTests/features/RestPosition.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,197 @@ | ||
| import { describe, it } from 'vitest'; | ||
| import { VisualTestHelper } from 'test/visualTests/VisualTestHelper'; | ||
|
|
||
| interface PitchPosition { | ||
| pitch: string; | ||
| label: string; | ||
| } | ||
|
|
||
| interface ClefData { | ||
| clef: string; | ||
| tex: string; | ||
| filler: string; | ||
| primaryFiller: string; | ||
| secondaryFiller: string; | ||
| multiVoicePrimary: PitchPosition; | ||
| multiVoiceSecondary: PitchPosition; | ||
| positions: PitchPosition[]; | ||
| } | ||
|
|
||
| // Staff positions from bottom to top for each clef | ||
| const clefs: ClefData[] = [ | ||
| { | ||
| clef: 'treble', | ||
| tex: '', | ||
| filler: 'b4', | ||
| positions: [ | ||
| { pitch: 'E4', label: 'Line 1' }, | ||
| { pitch: 'F4', label: 'Space 1' }, | ||
| { pitch: 'G4', label: 'Line 2' }, | ||
| { pitch: 'A4', label: 'Space 2' }, | ||
| { pitch: 'B4', label: 'Line 3' }, | ||
| { pitch: 'C5', label: 'Space 3' }, | ||
| { pitch: 'D5', label: 'Line 4' }, | ||
| { pitch: 'E5', label: 'Space 4' }, | ||
| { pitch: 'F5', label: 'Line 5' }, | ||
| { pitch: 'G5', label: 'Space 5' } | ||
| ], | ||
| primaryFiller: 'e5', | ||
| secondaryFiller: 'e4', | ||
| multiVoicePrimary: { pitch: 'C5', label: 'Space 3' }, | ||
| multiVoiceSecondary: { pitch: 'E4', label: 'Line 1' } | ||
| }, | ||
| { | ||
| clef: 'bass', | ||
| tex: '\\clef bass', | ||
| filler: 'd3', | ||
| positions: [ | ||
| { pitch: 'G2', label: 'Line 1' }, | ||
| { pitch: 'A2', label: 'Space 1' }, | ||
| { pitch: 'B2', label: 'Line 2' }, | ||
| { pitch: 'C3', label: 'Space 2' }, | ||
| { pitch: 'D3', label: 'Line 3' }, | ||
| { pitch: 'E3', label: 'Space 3' }, | ||
| { pitch: 'F3', label: 'Line 4' }, | ||
| { pitch: 'G3', label: 'Space 4' }, | ||
| { pitch: 'A3', label: 'Line 5' }, | ||
| { pitch: 'B3', label: 'Space 5' } | ||
| ], | ||
| primaryFiller: 'a3', | ||
| secondaryFiller: 'g2', | ||
| multiVoicePrimary: { pitch: 'E3', label: 'Space 3' }, | ||
| multiVoiceSecondary: { pitch: 'G2', label: 'Line 1' } | ||
| }, | ||
| { | ||
| clef: 'alto', | ||
| tex: '\\clef alto', | ||
| filler: 'c4', | ||
| positions: [ | ||
| { pitch: 'F3', label: 'Line 1' }, | ||
| { pitch: 'G3', label: 'Space 1' }, | ||
| { pitch: 'A3', label: 'Line 2' }, | ||
| { pitch: 'B3', label: 'Space 2' }, | ||
| { pitch: 'C4', label: 'Line 3' }, | ||
| { pitch: 'D4', label: 'Space 3' }, | ||
| { pitch: 'E4', label: 'Line 4' }, | ||
| { pitch: 'F4', label: 'Space 4' }, | ||
| { pitch: 'G4', label: 'Line 5' }, | ||
| { pitch: 'A4', label: 'Space 5' } | ||
| ], | ||
| primaryFiller: 'g4', | ||
| secondaryFiller: 'f3', | ||
| multiVoicePrimary: { pitch: 'D4', label: 'Space 3' }, | ||
| multiVoiceSecondary: { pitch: 'F3', label: 'Line 1' } | ||
| }, | ||
| { | ||
| clef: 'tenor', | ||
| tex: '\\clef tenor', | ||
| filler: 'a3', | ||
| positions: [ | ||
| { pitch: 'D3', label: 'Line 1' }, | ||
| { pitch: 'E3', label: 'Space 1' }, | ||
| { pitch: 'F3', label: 'Line 2' }, | ||
| { pitch: 'G3', label: 'Space 2' }, | ||
| { pitch: 'A3', label: 'Line 3' }, | ||
| { pitch: 'B3', label: 'Space 3' }, | ||
| { pitch: 'C4', label: 'Line 4' }, | ||
| { pitch: 'D4', label: 'Space 4' }, | ||
| { pitch: 'E4', label: 'Line 5' }, | ||
| { pitch: 'F4', label: 'Space 5' } | ||
| ], | ||
| primaryFiller: 'e4', | ||
| secondaryFiller: 'd3', | ||
| multiVoicePrimary: { pitch: 'B3', label: 'Space 3' }, | ||
| multiVoiceSecondary: { pitch: 'D3', label: 'Line 1' } | ||
| } | ||
| ]; | ||
|
|
||
| function restBeat(pitch: string, label: string, duration: string, showLabel: boolean = true): string { | ||
| if (showLabel) { | ||
| return `r.${duration}{restDisplayPitch ${pitch} txt "${label}"}`; | ||
| } | ||
| return `r.${duration}{restDisplayPitch ${pitch}}`; | ||
| } | ||
|
|
||
| function clefPrimaryDurations(tex: string, filler: string, pitch: string, label: string): string { | ||
| const prefix = tex ? `${tex} ` : ''; | ||
| return `${prefix}${restBeat(pitch, label, '1')} | ${restBeat(pitch, label, '2')} ${filler}.2 | ${restBeat(pitch, label, '4')} ${filler}.4 *3 | ${restBeat(pitch, label, '8')} ${filler}.8 *7 | ${restBeat(pitch, label, '16')} ${filler}.16 *15 | ${restBeat(pitch, label, '32')} ${filler}.32 *31`; | ||
| } | ||
|
|
||
| function voicePrimaryDurations(filler: string, pitch: string, label: string): string { | ||
| return `${restBeat(pitch, label, '1')} | ${restBeat(pitch, label, '2')} ${filler}.2 | ${restBeat(pitch, label, '4')} ${filler}.4 *3 | ${restBeat(pitch, label, '8')} ${filler}.8 *7 | ${restBeat(pitch, label, '16')} ${filler}.16 *15 | ${restBeat(pitch, label, '32')} ${filler}.32 *31`; | ||
| } | ||
|
|
||
| function voiceSecondaryDurations(filler: string, pitch: string, label: string): string { | ||
| return `${filler}.1 | ${filler}.2 ${restBeat(pitch, label, '2')} | ${filler}.4 *3 ${restBeat(pitch, label, '4')} | ${filler}.8 *7 ${restBeat(pitch, label, '8')} | ${filler}.16 *15 ${restBeat(pitch, label, '16')} | ${filler}.32 *31 ${restBeat(pitch, label, '32')}`; | ||
| } | ||
|
|
||
| function voiceDefaultPrimary(filler: string): string { | ||
| return `r.1 | r.2 ${filler}.2 | r.4 ${filler}.4 *3 | r.8 ${filler}.8 *7 | r.16 ${filler}.16 *15 | r.32 ${filler}.32 *31`; | ||
| } | ||
|
|
||
| function voiceDefaultSecondary(filler: string): string { | ||
| return `${filler}.1 | ${filler}.2 r.2 | ${filler}.4 *3 r.4 | ${filler}.8 *7 r.8 | ${filler}.16 *15 r.16 | ${filler}.32 *31 r.32`; | ||
| } | ||
|
|
||
| describe('RestPositionTests', () => { | ||
| it('rest-position-default', async () => { | ||
| await VisualTestHelper.runVisualTestTex( | ||
| `r.1 | r.2 e5.2 | r.4 e5.4 *3 | r.8 e5.8 *7 | r.16 e5.16 *15 | r.32 e5.32 *31`, | ||
| 'test-data/visual-tests/rest-position/rest-position-default.png' | ||
| ); | ||
| }); | ||
|
|
||
| for (const clefData of clefs) { | ||
| describe(`rest-position-${clefData.clef}`, () => { | ||
| const prefix = clefData.tex ? `${clefData.tex} ` : ''; | ||
|
|
||
| for (const pos of clefData.positions) { | ||
| it(`position-${pos.pitch} - ${pos.label}`, async () => { | ||
| await VisualTestHelper.runVisualTestTex( | ||
| clefPrimaryDurations(clefData.tex, clefData.filler, pos.pitch, pos.label), | ||
| `test-data/visual-tests/rest-position/${clefData.clef}/rest-position-pitch-${pos.pitch}-${pos.label.toLowerCase().replace(' ', '-')}.png` | ||
| ); | ||
| }); | ||
| } | ||
|
|
||
| it('multi-voice-default', async () => { | ||
| await VisualTestHelper.runVisualTestTex( | ||
| `${prefix}\\voice ${voiceDefaultPrimary(clefData.primaryFiller)} \\voice ${voiceDefaultSecondary(clefData.secondaryFiller)}`, | ||
| `test-data/visual-tests/rest-position/${clefData.clef}/rest-position-multi-voice-default.png` | ||
| ); | ||
| }); | ||
|
|
||
| it('multi-voice-both-set', async () => { | ||
| await VisualTestHelper.runVisualTestTex( | ||
| `${prefix}\\voice ${voicePrimaryDurations(clefData.primaryFiller, clefData.multiVoicePrimary.pitch, clefData.multiVoicePrimary.label)} \\voice ${voiceSecondaryDurations(clefData.secondaryFiller, clefData.multiVoiceSecondary.pitch, clefData.multiVoiceSecondary.label)}`, | ||
| `test-data/visual-tests/rest-position/${clefData.clef}/rest-position-multi-voice-both-set.png` | ||
| ); | ||
| }); | ||
|
|
||
| it('multi-voice-main-only', async () => { | ||
| await VisualTestHelper.runVisualTestTex( | ||
| `${prefix}\\voice ${voicePrimaryDurations(clefData.primaryFiller, clefData.multiVoicePrimary.pitch, clefData.multiVoicePrimary.label)} \\voice ${voiceDefaultSecondary(clefData.secondaryFiller)}`, | ||
| `test-data/visual-tests/rest-position/${clefData.clef}/rest-position-multi-voice-main-only-${clefData.multiVoicePrimary.pitch}-${clefData.multiVoicePrimary.label.toLowerCase().replace(' ', '-')}.png` | ||
| ); | ||
| }); | ||
|
|
||
| it('multi-voice-secondary-only', async () => { | ||
| await VisualTestHelper.runVisualTestTex( | ||
| `${prefix}\\voice ${voiceDefaultPrimary(clefData.primaryFiller)} \\voice ${voiceSecondaryDurations(clefData.secondaryFiller, clefData.multiVoiceSecondary.pitch, clefData.multiVoiceSecondary.label)}`, | ||
| `test-data/visual-tests/rest-position/${clefData.clef}/rest-position-multi-voice-secondary-only-${clefData.multiVoiceSecondary.pitch}-${clefData.multiVoiceSecondary.label.toLowerCase().replace(' ', '-')}.png` | ||
| ); | ||
| }); | ||
|
|
||
| describe('staff-lines', () => { | ||
| for (const lineCount of [1, 2, 3, 4, 5]) { | ||
| it(`linecount-${lineCount}`, async () => { | ||
| await VisualTestHelper.runVisualTestTex( | ||
| `${prefix}\\staff { score ${lineCount} } ${restBeat(clefData.multiVoiceSecondary.pitch, clefData.multiVoiceSecondary.label, '1', false)} | ${restBeat(clefData.multiVoiceSecondary.pitch, clefData.multiVoiceSecondary.label, '2', false)} ${clefData.secondaryFiller}.2 | ${restBeat(clefData.multiVoiceSecondary.pitch, clefData.multiVoiceSecondary.label, '4', false)} ${clefData.secondaryFiller}.4 *3`, | ||
| `test-data/visual-tests/rest-position/${clefData.clef}/rest-position-staff-lines-${lineCount}-${clefData.multiVoiceSecondary.pitch}.png` | ||
| ); | ||
| }); | ||
| } | ||
| }); | ||
| }); | ||
| } | ||
| }); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+ 0.5seems like a workaround indicating to a problem elsewhere. Can we eliminate or move this to the actual place where things where the need for the workaround gets clear?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue of adding 0.5 is needed because the glyph baseline data contained in bravura_metadata.json varies per glyph.
For example, the black note head is perfectly centred vertically [0.5, -0.5] , but the rest glyphs all have different off-centre base lines.
The 0.5 is used to calculate the perfect positioning of the half note rest, so everything is adjusted by 0.5,
but visually the 0.5 aligns the half note perfectly.
Do we want all rests, quarter note, eighth note, 16th note, 32nd etc. notes to be aligned perfectly centred visually on the Y axis,either on the line or in the space, or is it just the half note that needs to be visually perfect?
If all rests need to be visually perfectly centered, then we'd need to include the Bravura metadata coordinates in the
calculation. Creating a helper function to do this.
We could call this after calling calculateRestDisplaySteps and add the result, the return value, to replace the 0.5 hard coded value.