smoosic 2.0.2 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/smoosic.js +546 -125
- package/changes.md +85 -0
- package/package.json +23 -2
- package/release/smoosic.js +549 -128
- package/release/styles/menus.css +26 -0
- package/specs/022-text-reposition-on-resize/spec.md +1 -0
- package/specs/027-fix-bottom-modifier-lookup/checklists/requirements.md +38 -0
- package/specs/027-fix-bottom-modifier-lookup/contracts/division-lookup-contract.md +51 -0
- package/specs/027-fix-bottom-modifier-lookup/data-model.md +43 -0
- package/specs/027-fix-bottom-modifier-lookup/plan.md +77 -0
- package/specs/027-fix-bottom-modifier-lookup/quickstart.md +36 -0
- package/specs/027-fix-bottom-modifier-lookup/research.md +58 -0
- package/specs/027-fix-bottom-modifier-lookup/spec.md +105 -0
- package/specs/027-fix-bottom-modifier-lookup/tasks.md +167 -0
- package/specs/028-unsaved-changes-indicator/checklists/requirements.md +39 -0
- package/specs/028-unsaved-changes-indicator/contracts/score-change-contract.md +44 -0
- package/specs/028-unsaved-changes-indicator/data-model.md +64 -0
- package/specs/028-unsaved-changes-indicator/plan.md +96 -0
- package/specs/028-unsaved-changes-indicator/quickstart.md +54 -0
- package/specs/028-unsaved-changes-indicator/research.md +68 -0
- package/specs/028-unsaved-changes-indicator/spec.md +135 -0
- package/specs/028-unsaved-changes-indicator/tasks.md +173 -0
- package/specs/029-remove-promise-helpers/checklists/requirements.md +39 -0
- package/specs/029-remove-promise-helpers/contracts/public-api-contract.md +32 -0
- package/specs/029-remove-promise-helpers/data-model.md +45 -0
- package/specs/029-remove-promise-helpers/plan.md +86 -0
- package/specs/029-remove-promise-helpers/quickstart.md +53 -0
- package/specs/029-remove-promise-helpers/research.md +71 -0
- package/specs/029-remove-promise-helpers/spec.md +107 -0
- package/specs/029-remove-promise-helpers/tasks.md +164 -0
- package/specs/030-copy-paste-voices/checklists/requirements.md +39 -0
- package/specs/030-copy-paste-voices/contracts/voice-copy-paste-contract.md +47 -0
- package/specs/030-copy-paste-voices/data-model.md +63 -0
- package/specs/030-copy-paste-voices/plan.md +80 -0
- package/specs/030-copy-paste-voices/quickstart.md +50 -0
- package/specs/030-copy-paste-voices/research.md +80 -0
- package/specs/030-copy-paste-voices/spec.md +124 -0
- package/specs/030-copy-paste-voices/tasks.md +183 -0
- package/specs/031-select-voice/checklists/requirements.md +39 -0
- package/specs/031-select-voice/contracts/select-voice-contract.md +43 -0
- package/specs/031-select-voice/data-model.md +47 -0
- package/specs/031-select-voice/plan.md +79 -0
- package/specs/031-select-voice/quickstart.md +43 -0
- package/specs/031-select-voice/research.md +55 -0
- package/specs/031-select-voice/spec.md +113 -0
- package/specs/031-select-voice/tasks.md +171 -0
- package/specs/032-split-multimeasure-rests/checklists/requirements.md +40 -0
- package/specs/032-split-multimeasure-rests/contracts/grouping-contract.md +53 -0
- package/specs/032-split-multimeasure-rests/data-model.md +70 -0
- package/specs/032-split-multimeasure-rests/plan.md +81 -0
- package/specs/032-split-multimeasure-rests/quickstart.md +46 -0
- package/specs/032-split-multimeasure-rests/research.md +63 -0
- package/specs/032-split-multimeasure-rests/spec.md +127 -0
- package/specs/032-split-multimeasure-rests/tasks.md +174 -0
- package/specs/033-key-distance-transposition/checklists/requirements.md +35 -0
- package/specs/033-key-distance-transposition/contracts/spelling-api.md +36 -0
- package/specs/033-key-distance-transposition/data-model.md +49 -0
- package/specs/033-key-distance-transposition/plan.md +87 -0
- package/specs/033-key-distance-transposition/quickstart.md +40 -0
- package/specs/033-key-distance-transposition/research.md +82 -0
- package/specs/033-key-distance-transposition/spec.md +132 -0
- package/specs/033-key-distance-transposition/tasks.md +139 -0
- package/specs/034-smz-compressed-scores/checklists/requirements.md +35 -0
- package/specs/034-smz-compressed-scores/contracts/archive-api.md +30 -0
- package/specs/034-smz-compressed-scores/data-model.md +48 -0
- package/specs/034-smz-compressed-scores/plan.md +89 -0
- package/specs/034-smz-compressed-scores/quickstart.md +44 -0
- package/specs/034-smz-compressed-scores/research.md +86 -0
- package/specs/034-smz-compressed-scores/spec.md +137 -0
- package/specs/034-smz-compressed-scores/tasks.md +148 -0
- package/specs/035-paste-special/checklists/requirements.md +35 -0
- package/specs/035-paste-special/contracts/paste-special-api.md +50 -0
- package/specs/035-paste-special/data-model.md +47 -0
- package/specs/035-paste-special/plan.md +83 -0
- package/specs/035-paste-special/quickstart.md +51 -0
- package/specs/035-paste-special/research.md +97 -0
- package/specs/035-paste-special/spec.md +170 -0
- package/specs/035-paste-special/tasks.md +149 -0
- package/specs/036-autosave-recovery/checklists/requirements.md +36 -0
- package/specs/036-autosave-recovery/contracts/autosave-api.md +111 -0
- package/specs/036-autosave-recovery/data-model.md +70 -0
- package/specs/036-autosave-recovery/plan.md +87 -0
- package/specs/036-autosave-recovery/quickstart.md +65 -0
- package/specs/036-autosave-recovery/research.md +105 -0
- package/specs/036-autosave-recovery/spec.md +143 -0
- package/specs/036-autosave-recovery/tasks.md +165 -0
- package/specs/037-fix-new-part-dialog/checklists/requirements.md +38 -0
- package/specs/037-fix-new-part-dialog/contracts/create-part-api.md +84 -0
- package/specs/037-fix-new-part-dialog/data-model.md +68 -0
- package/specs/037-fix-new-part-dialog/plan.md +83 -0
- package/specs/037-fix-new-part-dialog/quickstart.md +58 -0
- package/specs/037-fix-new-part-dialog/research.md +86 -0
- package/specs/037-fix-new-part-dialog/spec.md +144 -0
- package/specs/037-fix-new-part-dialog/tasks.md +174 -0
- package/specs/038-per-measure-beam-groups/checklists/requirements.md +36 -0
- package/specs/038-per-measure-beam-groups/contracts/beam-groups-api.md +74 -0
- package/specs/038-per-measure-beam-groups/data-model.md +75 -0
- package/specs/038-per-measure-beam-groups/plan.md +84 -0
- package/specs/038-per-measure-beam-groups/quickstart.md +53 -0
- package/specs/038-per-measure-beam-groups/research.md +72 -0
- package/specs/038-per-measure-beam-groups/spec.md +146 -0
- package/specs/038-per-measure-beam-groups/tasks.md +132 -0
- package/specs/039-measure-fill-submenu/checklists/requirements.md +35 -0
- package/specs/039-measure-fill-submenu/contracts/measure-fill-api.md +56 -0
- package/specs/039-measure-fill-submenu/data-model.md +79 -0
- package/specs/039-measure-fill-submenu/plan.md +81 -0
- package/specs/039-measure-fill-submenu/quickstart.md +62 -0
- package/specs/039-measure-fill-submenu/research.md +68 -0
- package/specs/039-measure-fill-submenu/spec.md +153 -0
- package/specs/039-measure-fill-submenu/tasks.md +121 -0
- package/specs/040-dynamics-dialog-cleanup/checklists/requirements.md +36 -0
- package/specs/040-dynamics-dialog-cleanup/contracts/dynamics-dialog.md +52 -0
- package/specs/040-dynamics-dialog-cleanup/data-model.md +48 -0
- package/specs/040-dynamics-dialog-cleanup/plan.md +89 -0
- package/specs/040-dynamics-dialog-cleanup/quickstart.md +69 -0
- package/specs/040-dynamics-dialog-cleanup/research.md +80 -0
- package/specs/040-dynamics-dialog-cleanup/spec.md +120 -0
- package/specs/040-dynamics-dialog-cleanup/tasks.md +114 -0
- package/specs/041-delete-special/checklists/requirements.md +35 -0
- package/specs/041-delete-special/contracts/delete-special-api.md +41 -0
- package/specs/041-delete-special/data-model.md +40 -0
- package/specs/041-delete-special/plan.md +93 -0
- package/specs/041-delete-special/quickstart.md +41 -0
- package/specs/041-delete-special/research.md +75 -0
- package/specs/041-delete-special/spec.md +136 -0
- package/specs/041-delete-special/tasks.md +106 -0
- package/src/application/application.ts +475 -459
- package/src/application/exports.ts +401 -395
- package/src/application/generateVexTests.ts +2 -2
- package/src/common/promiseHelpers.ts +2 -2
- package/src/render/audio/samples.ts +117 -118
- package/src/render/sui/NoteEntryCaret.ts +117 -16
- package/src/render/sui/autosave.ts +265 -0
- package/src/render/sui/formatter.ts +12 -2
- package/src/render/sui/pageDivisions.ts +58 -0
- package/src/render/sui/renderState.ts +469 -464
- package/src/render/sui/scoreChangeState.ts +67 -0
- package/src/render/sui/scoreView.ts +77 -2
- package/src/render/sui/scoreViewOperations.ts +363 -37
- package/src/render/sui/staffLineGeometry.ts +82 -0
- package/src/render/sui/svgPageMap.ts +16 -17
- package/src/render/sui/textEdit.ts +310 -311
- package/src/render/sui/tracker.ts +40 -0
- package/src/render/vex/vxMeasure.ts +22 -8
- package/src/render/vex/vxNote.ts +5 -5
- package/src/smo/data/measure.ts +58 -1
- package/src/smo/data/measureModifiers.ts +81 -1
- package/src/smo/data/music.ts +169 -359
- package/src/smo/data/note.ts +1 -1
- package/src/smo/data/noteModifiers.ts +12 -0
- package/src/smo/data/score.ts +167 -2
- package/src/smo/data/scoreModifiers.ts +46 -1
- package/src/smo/data/systemStaff.ts +43 -0
- package/src/smo/xform/beamers.ts +80 -6
- package/src/smo/xform/copypaste.ts +511 -51
- package/src/smo/xform/measureFill.ts +89 -0
- package/src/smo/xform/operations.ts +403 -61
- package/src/smo/xform/selections.ts +75 -0
- package/src/smo/xform/undo.ts +9 -0
- package/src/styles/menus.css +26 -0
- package/src/ui/buttons/ribbon.ts +3 -1
- package/src/ui/components/buttons/sidebar.vue +15 -6
- package/src/ui/components/dialogs/beamGroups.vue +106 -0
- package/src/ui/components/dialogs/deleteSpecial.vue +38 -0
- package/src/ui/components/dialogs/dynamics.vue +16 -3
- package/src/ui/components/dialogs/fileUpload.vue +2 -2
- package/src/ui/components/dialogs/hairpin.vue +3 -3
- package/src/ui/components/dialogs/library.vue +3 -1
- package/src/ui/components/dialogs/newPart.vue +148 -184
- package/src/ui/components/dialogs/pasteSpecial.vue +49 -0
- package/src/ui/components/dialogs/recovery.vue +66 -0
- package/src/ui/components/dialogs/save.vue +11 -4
- package/src/ui/components/dialogs/scorePreferences.vue +23 -1
- package/src/ui/components/dialogs/slur.vue +6 -6
- package/src/ui/components/dialogs/tempo.vue +11 -3
- package/src/ui/components/dialogs/timeSignature.vue +5 -0
- package/src/ui/components/dialogs/unsavedChanges.vue +44 -0
- package/src/ui/components/dialogs/volta.vue +3 -3
- package/src/ui/dialogs/adapter.ts +181 -183
- package/src/ui/dialogs/addMeasure.ts +97 -97
- package/src/ui/dialogs/annotationVue.ts +56 -56
- package/src/ui/dialogs/audioSettings.ts +121 -123
- package/src/ui/dialogs/beamGroupsVue.ts +69 -0
- package/src/ui/dialogs/chordChangeVue.ts +46 -46
- package/src/ui/dialogs/clefChange.ts +53 -53
- package/src/ui/dialogs/createPartHelpers.ts +68 -0
- package/src/ui/dialogs/customTuplets.ts +95 -96
- package/src/ui/dialogs/customTupletsVue.ts +47 -47
- package/src/ui/dialogs/deleteSpecial.ts +57 -0
- package/src/ui/dialogs/dialog.ts +627 -620
- package/src/ui/dialogs/durations.ts +34 -34
- package/src/ui/dialogs/dynamicsVue.ts +87 -60
- package/src/ui/dialogs/factory.ts +196 -198
- package/src/ui/dialogs/fileDialogs.ts +286 -179
- package/src/ui/dialogs/fonts.ts +93 -93
- package/src/ui/dialogs/globalLayout.ts +40 -40
- package/src/ui/dialogs/gracenote.ts +31 -31
- package/src/ui/dialogs/hairpin.ts +108 -110
- package/src/ui/dialogs/hairpinVue.ts +51 -51
- package/src/ui/dialogs/instrument.ts +119 -112
- package/src/ui/dialogs/keySignature.ts +175 -176
- package/src/ui/dialogs/keySignatureVue.ts +47 -47
- package/src/ui/dialogs/library.ts +207 -207
- package/src/ui/dialogs/libraryVue.ts +62 -48
- package/src/ui/dialogs/lyricVue.ts +46 -46
- package/src/ui/dialogs/measureFormat.ts +78 -78
- package/src/ui/dialogs/microtones.ts +147 -147
- package/src/ui/dialogs/noteHead.ts +319 -319
- package/src/ui/dialogs/pageLayout.ts +61 -61
- package/src/ui/dialogs/partInfo.ts +60 -60
- package/src/ui/dialogs/pasteSpecial.ts +59 -0
- package/src/ui/dialogs/pedalMarking.ts +117 -117
- package/src/ui/dialogs/pedalMarkingVue.ts +73 -73
- package/src/ui/dialogs/pitch.ts +352 -352
- package/src/ui/dialogs/preferences.ts +1 -0
- package/src/ui/dialogs/recovery.ts +49 -0
- package/src/ui/dialogs/rehearsalMark.ts +64 -64
- package/src/ui/dialogs/rehearsalMarkVue.ts +57 -57
- package/src/ui/dialogs/scoreId.ts +35 -36
- package/src/ui/dialogs/scoreView.ts +42 -42
- package/src/ui/dialogs/slur.ts +308 -310
- package/src/ui/dialogs/slurVue.ts +91 -91
- package/src/ui/dialogs/staffGroup.ts +112 -112
- package/src/ui/dialogs/tabNote.ts +84 -84
- package/src/ui/dialogs/tabStave.ts +182 -182
- package/src/ui/dialogs/tempo.ts +261 -263
- package/src/ui/dialogs/tempoVue.ts +73 -73
- package/src/ui/dialogs/textBlockVue.ts +127 -127
- package/src/ui/dialogs/textBracket.ts +114 -116
- package/src/ui/dialogs/textBracketVue.ts +56 -56
- package/src/ui/dialogs/tie.ts +140 -142
- package/src/ui/dialogs/timeSignature.ts +65 -66
- package/src/ui/dialogs/transposeScore.ts +39 -39
- package/src/ui/dialogs/unsavedChanges.ts +43 -0
- package/src/ui/dialogs/volta.ts +120 -122
- package/src/ui/dialogs/voltaVue.ts +51 -51
- package/src/ui/fileio/fileInput.ts +12 -3
- package/src/ui/fileio/library.ts +110 -111
- package/src/ui/fileio/scoreArchive.ts +151 -0
- package/src/ui/fileio/xhrLoader.ts +26 -0
- package/src/ui/i18n/language.ts +1 -1
- package/src/ui/menus/beams.ts +181 -112
- package/src/ui/menus/edit.ts +143 -6
- package/src/ui/menus/file.ts +40 -4
- package/src/ui/menus/measure.ts +40 -1
- package/tests/autosave.ts +332 -0
- package/tests/beamDotted.ts +56 -0
- package/tests/beamGroups.ts +338 -0
- package/tests/createPart.ts +292 -0
- package/tests/deleteSpecial.ts +350 -0
- package/tests/dynamicsFontSize.ts +132 -0
- package/tests/keyDistanceTransposition.ts +351 -0
- package/tests/measureFill.ts +295 -0
- package/tests/movePart.ts +94 -0
- package/tests/multimeasureRest.ts +338 -0
- package/tests/pageDivisions.ts +156 -0
- package/tests/pasteIntoMeasure.ts +103 -0
- package/tests/pasteSpecial.ts +541 -0
- package/tests/promiseHelpersUsage.ts +142 -0
- package/tests/quickBeam.ts +126 -0
- package/tests/scoreArchive.ts +218 -0
- package/tests/scoreChangeState.ts +104 -0
- package/tests/selectVoice.ts +189 -0
- package/tests/staffLineGeometry.ts +179 -0
- package/tests/timeSignatureDisplay.ts +58 -0
- package/tests/voiceCopyPaste.ts +417 -0
- package/tools/smoosic-schema.json +37 -0
- package/typedoc.ts +1 -1
- package/types/src/application/exports.d.ts +453 -447
- package/types/src/common/promiseHelpers.d.ts +30 -30
- package/types/src/common/vex.d.ts +224 -224
- package/types/src/render/sui/NoteEntryCaret.d.ts +107 -107
- package/types/src/render/sui/autosave.d.ts +99 -0
- package/types/src/render/sui/scoreView.d.ts +23 -0
- package/types/src/render/sui/scoreViewOperations.d.ts +759 -639
- package/types/src/render/sui/svgHelpers.d.ts +88 -88
- package/types/src/render/sui/svgPageMap.d.ts +344 -344
- package/types/src/render/sui/textEdit.d.ts +96 -96
- package/types/src/render/sui/textRender.d.ts +199 -199
- package/types/src/render/vex/smoAdapter.d.ts +47 -47
- package/types/src/render/vex/vxMeasure.d.ts +97 -97
- package/types/src/render/vex/vxNote.d.ts +56 -56
- package/types/src/render/vex/vxSystem.d.ts +71 -71
- package/types/src/smo/data/measure.d.ts +30 -0
- package/types/src/smo/data/measureModifiers.d.ts +568 -513
- package/types/src/smo/data/music.d.ts +74 -32
- package/types/src/smo/data/note.d.ts +498 -498
- package/types/src/smo/data/noteModifiers.d.ts +615 -606
- package/types/src/smo/data/score.d.ts +476 -421
- package/types/src/smo/data/scoreModifiers.d.ts +30 -0
- package/types/src/smo/data/scoreText.d.ts +334 -334
- package/types/src/smo/data/systemStaff.d.ts +14 -0
- package/types/src/smo/xform/beamers.d.ts +23 -1
- package/types/src/smo/xform/copypaste.d.ts +138 -2
- package/types/src/smo/xform/measureFill.d.ts +21 -0
- package/types/src/smo/xform/operations.d.ts +245 -129
- package/types/src/smo/xform/selections.d.ts +154 -154
- package/types/src/smo/xform/undo.d.ts +142 -142
- package/types/src/ui/buttons/button.d.ts +100 -100
- package/types/src/ui/buttons/ribbon.d.ts +70 -70
- package/types/src/ui/common.d.ts +76 -76
- package/types/src/ui/components/dialogs/chordText.d.ts +28 -28
- package/types/src/ui/components/dialogs/textBlockAtomNode.d.ts +20 -20
- package/types/src/ui/components/dialogs/textGroupHtml.d.ts +29 -29
- package/types/src/ui/composable/draggable.d.ts +15 -15
- package/types/src/ui/dialogs/adapter.d.ts +120 -120
- package/types/src/ui/dialogs/annotationVue.d.ts +9 -9
- package/types/src/ui/dialogs/audioSettings.d.ts +32 -32
- package/types/src/ui/dialogs/beamGroupsVue.d.ts +20 -0
- package/types/src/ui/dialogs/chordChangeVue.d.ts +8 -8
- package/types/src/ui/dialogs/createPartHelpers.d.ts +29 -0
- package/types/src/ui/dialogs/customTupletsVue.d.ts +9 -9
- package/types/src/ui/dialogs/deleteSpecial.d.ts +8 -0
- package/types/src/ui/dialogs/dialog.d.ts +203 -203
- package/types/src/ui/dialogs/dynamicsVue.d.ts +10 -10
- package/types/src/ui/dialogs/factory.d.ts +15 -15
- package/types/src/ui/dialogs/fileDialogs.d.ts +4 -4
- package/types/src/ui/dialogs/hairpin.d.ts +35 -35
- package/types/src/ui/dialogs/hairpinVue.d.ts +7 -7
- package/types/src/ui/dialogs/instrument.d.ts +3 -3
- package/types/src/ui/dialogs/keySignatureVue.d.ts +7 -7
- package/types/src/ui/dialogs/libraryVue.d.ts +15 -15
- package/types/src/ui/dialogs/lyricVue.d.ts +8 -8
- package/types/src/ui/dialogs/pasteSpecial.d.ts +8 -0
- package/types/src/ui/dialogs/pedalMarkingVue.d.ts +7 -7
- package/types/src/ui/dialogs/recovery.d.ts +8 -0
- package/types/src/ui/dialogs/rehearsalMark.d.ts +25 -25
- package/types/src/ui/dialogs/rehearsalMarkVue.d.ts +7 -7
- package/types/src/ui/dialogs/slur.d.ts +57 -57
- package/types/src/ui/dialogs/slurVue.d.ts +7 -7
- package/types/src/ui/dialogs/tempo.d.ts +50 -50
- package/types/src/ui/dialogs/tempoVue.d.ts +10 -10
- package/types/src/ui/dialogs/textBlockVue.d.ts +8 -8
- package/types/src/ui/dialogs/textBracket.d.ts +35 -35
- package/types/src/ui/dialogs/textBracketVue.d.ts +7 -7
- package/types/src/ui/dialogs/tie.d.ts +41 -41
- package/types/src/ui/dialogs/volta.d.ts +40 -40
- package/types/src/ui/dialogs/voltaVue.d.ts +7 -7
- package/types/src/ui/fileio/fileInput.d.ts +7 -1
- package/types/src/ui/fileio/library.d.ts +40 -40
- package/types/src/ui/fileio/scoreArchive.d.ts +55 -0
- package/types/src/ui/fileio/xhrLoader.d.ts +7 -0
- package/types/src/ui/menus/file.d.ts +8 -8
- package/types/src/ui/menus/language.d.ts +7 -7
- package/types/src/ui/menus/manager.d.ts +58 -58
- package/types/src/ui/menus/menu.d.ts +159 -159
- package/types/src/ui/menus/partSelection.d.ts +14 -14
- package/types/src/ui/menus/score.d.ts +8 -8
- package/types/src/ui/menus/staffModifier.d.ts +17 -17
- package/types/typedoc.d.ts +147 -147
- package/src/ui/dialogs/dynamics.ts +0 -143
- package/types/src/ui/dialogs/dynamics.d.ts +0 -37
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Headless checks for moving parts up and down: a 2-staff part moves as a unit.
|
|
3
|
+
*
|
|
4
|
+
* Run with: npm run test:move-part
|
|
5
|
+
*/
|
|
6
|
+
import { SmoScore } from '../src/smo/data/score';
|
|
7
|
+
import { SmoSystemStaff } from '../src/smo/data/systemStaff';
|
|
8
|
+
import { SmoInstrument, staffModifierDynamicCtorInit } from '../src/smo/data/staffModifiers';
|
|
9
|
+
import { scoreModifierDynamicCtorInit } from '../src/smo/data/scoreModifiers';
|
|
10
|
+
import { noteModifierDynamicCtorInit } from '../src/smo/data/noteModifiers';
|
|
11
|
+
import { measureModifierDynamicCtorInit } from '../src/smo/data/measureModifiers';
|
|
12
|
+
import { SmoSelector, SmoSelection } from '../src/smo/xform/selections';
|
|
13
|
+
import { SmoOperation } from '../src/smo/xform/operations';
|
|
14
|
+
|
|
15
|
+
noteModifierDynamicCtorInit();
|
|
16
|
+
measureModifierDynamicCtorInit();
|
|
17
|
+
staffModifierDynamicCtorInit();
|
|
18
|
+
scoreModifierDynamicCtorInit();
|
|
19
|
+
|
|
20
|
+
let failures = 0;
|
|
21
|
+
const check = (name: string, condition: boolean, detail?: string) => {
|
|
22
|
+
if (condition) {
|
|
23
|
+
console.log(`PASS ${name}`);
|
|
24
|
+
} else {
|
|
25
|
+
failures += 1;
|
|
26
|
+
console.log(`FAIL ${name}${detail ? ' -- ' + detail : ''}`);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/** A score with a staff for each name; a name ending in '1' is the first staff of a 2-staff part, '2' the second */
|
|
31
|
+
const buildScore = (names: string[]): SmoScore => {
|
|
32
|
+
const score = SmoScore.getDefaultScore(SmoScore.defaults, null);
|
|
33
|
+
for (let ii = 1; ii < names.length; ++ii) {
|
|
34
|
+
const params = SmoSystemStaff.defaults;
|
|
35
|
+
params.staffId = ii;
|
|
36
|
+
params.measureInstrumentMap[0] = new SmoInstrument(SmoInstrument.defaults);
|
|
37
|
+
score.addStaff(params);
|
|
38
|
+
}
|
|
39
|
+
names.forEach((name, ix) => {
|
|
40
|
+
const info = score.staves[ix].partInfo;
|
|
41
|
+
info.partName = name;
|
|
42
|
+
if (name.endsWith('1')) {
|
|
43
|
+
info.stavesAfter = 1;
|
|
44
|
+
} else if (name.endsWith('2')) {
|
|
45
|
+
info.stavesBefore = 1;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
return score;
|
|
49
|
+
};
|
|
50
|
+
const order = (score: SmoScore): string => score.staves.map((staff) => staff.partInfo.partName).join(',');
|
|
51
|
+
const move = (score: SmoScore, staff: number, dir: number) => {
|
|
52
|
+
const selector = SmoSelector.default;
|
|
53
|
+
selector.staff = staff;
|
|
54
|
+
SmoOperation.moveStaffUpDown(score, { selector } as SmoSelection, dir);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
let score = buildScore(['A', 'B1', 'B2']);
|
|
58
|
+
move(score, 1, -1);
|
|
59
|
+
check('2-staff part up passes single staff', order(score) === 'B1,B2,A', order(score));
|
|
60
|
+
move(score, 0, 1);
|
|
61
|
+
check('2-staff part down passes single staff', order(score) === 'A,B1,B2', order(score));
|
|
62
|
+
|
|
63
|
+
score = buildScore(['A', 'B1', 'B2']);
|
|
64
|
+
move(score, 0, 1);
|
|
65
|
+
check('single staff down passes whole 2-staff part', order(score) === 'B1,B2,A', order(score));
|
|
66
|
+
move(score, 2, -1);
|
|
67
|
+
check('single staff up passes whole 2-staff part', order(score) === 'A,B1,B2', order(score));
|
|
68
|
+
|
|
69
|
+
score = buildScore(['A', 'B1', 'B2']);
|
|
70
|
+
move(score, 2, -1);
|
|
71
|
+
check('selecting second staff of a part moves the part', order(score) === 'B1,B2,A', order(score));
|
|
72
|
+
|
|
73
|
+
score = buildScore(['A', 'B1', 'B2', 'C1', 'C2']);
|
|
74
|
+
move(score, 3, -1);
|
|
75
|
+
check('2-staff part up passes 2-staff part', order(score) === 'A,C1,C2,B1,B2', order(score));
|
|
76
|
+
|
|
77
|
+
score = buildScore(['A', 'B', 'C1', 'C2']);
|
|
78
|
+
move(score, 2, 1);
|
|
79
|
+
check('last part down wraps to first', order(score) === 'C1,C2,A,B', order(score));
|
|
80
|
+
move(score, 0, -1);
|
|
81
|
+
check('first part up wraps to last', order(score) === 'A,B,C1,C2', order(score));
|
|
82
|
+
|
|
83
|
+
score = buildScore(['A1', 'A2', 'B', 'C']);
|
|
84
|
+
move(score, 0, -1);
|
|
85
|
+
check('first 2-staff part up wraps to last', order(score) === 'B,C,A1,A2', order(score));
|
|
86
|
+
check('part links are kept', score.staves[2].partInfo.stavesAfter === 1 && score.staves[3].partInfo.stavesBefore === 1);
|
|
87
|
+
check('staves are numbered', score.staves.every((staff, ix) => staff.staffId === ix));
|
|
88
|
+
|
|
89
|
+
if (failures > 0) {
|
|
90
|
+
console.log(`${failures} check(s) failed`);
|
|
91
|
+
process.exitCode = 1;
|
|
92
|
+
} else {
|
|
93
|
+
console.log('all checks passed');
|
|
94
|
+
}
|
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Headless checks for how SmoOperation.computeMultipartRest groups empty measures into multimeasure
|
|
3
|
+
* rests around landmarks. Cases G1-G24 are listed in
|
|
4
|
+
* specs/032-split-multimeasure-rests/contracts/grouping-contract.md. Drawing is checked by hand.
|
|
5
|
+
*
|
|
6
|
+
* Run with: npm run test:multimeasure-rest
|
|
7
|
+
*/
|
|
8
|
+
import { SmoScore } from '../src/smo/data/score';
|
|
9
|
+
import { SmoSystemStaff } from '../src/smo/data/systemStaff';
|
|
10
|
+
import { SmoInstrument } from '../src/smo/data/staffModifiers';
|
|
11
|
+
import { SmoOperation } from '../src/smo/xform/operations';
|
|
12
|
+
import { SmoBarline, SmoRehearsalMark, SmoRepeatSymbol, SmoTempo, SmoTimeSignature,
|
|
13
|
+
SmoVolta } from '../src/smo/data/measureModifiers';
|
|
14
|
+
import { noteModifierDynamicCtorInit } from '../src/smo/data/noteModifiers';
|
|
15
|
+
import { measureModifierDynamicCtorInit } from '../src/smo/data/measureModifiers';
|
|
16
|
+
import { staffModifierDynamicCtorInit } from '../src/smo/data/staffModifiers';
|
|
17
|
+
import { scoreModifierDynamicCtorInit } from '../src/smo/data/scoreModifiers';
|
|
18
|
+
|
|
19
|
+
// The smo layer registers its deserialization factories at app start; do the same here
|
|
20
|
+
// without pulling in any UI.
|
|
21
|
+
noteModifierDynamicCtorInit();
|
|
22
|
+
measureModifierDynamicCtorInit();
|
|
23
|
+
staffModifierDynamicCtorInit();
|
|
24
|
+
scoreModifierDynamicCtorInit();
|
|
25
|
+
|
|
26
|
+
let failures = 0;
|
|
27
|
+
const check = (name: string, condition: boolean, detail?: string) => {
|
|
28
|
+
if (condition) {
|
|
29
|
+
console.log(`PASS ${name}`);
|
|
30
|
+
} else {
|
|
31
|
+
failures += 1;
|
|
32
|
+
console.log(`FAIL ${name}${detail ? ' -- ' + detail : ''}`);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const COUNT = 12;
|
|
37
|
+
/** A part of 12 empty 4/4 measures, with multimeasure rests turned on. Measures are 1-based in the helpers. */
|
|
38
|
+
const buildScore = (staffCount: number = 1): SmoScore => {
|
|
39
|
+
const score = SmoScore.getDefaultScore(SmoScore.defaults, null);
|
|
40
|
+
while (score.staves[0].measures.length < COUNT) {
|
|
41
|
+
score.addMeasure(score.staves[0].measures.length - 1);
|
|
42
|
+
}
|
|
43
|
+
for (let s = 1; s < staffCount; ++s) {
|
|
44
|
+
const instrument = SmoInstrument.defaults;
|
|
45
|
+
instrument.startSelector.staff = instrument.endSelector.staff = s;
|
|
46
|
+
const params = SmoSystemStaff.defaults;
|
|
47
|
+
params.staffId = s;
|
|
48
|
+
params.measureInstrumentMap[0] = new SmoInstrument(instrument);
|
|
49
|
+
score.addStaff(params);
|
|
50
|
+
}
|
|
51
|
+
score.staves[0].partInfo.expandMultimeasureRests = false;
|
|
52
|
+
return score;
|
|
53
|
+
};
|
|
54
|
+
const measureAt = (score: SmoScore, m: number, staff: number = 0) => score.staves[staff].measures[m - 1];
|
|
55
|
+
|
|
56
|
+
// --- landmark helpers ---
|
|
57
|
+
const addRehearsal = (score: SmoScore, m: number, staff: number = 0) =>
|
|
58
|
+
measureAt(score, m, staff).addRehearsalMark(SmoRehearsalMark.defaults);
|
|
59
|
+
const setSymbol = (score: SmoScore, m: number, name: string) => {
|
|
60
|
+
const params = SmoRepeatSymbol.defaults;
|
|
61
|
+
params.symbol = SmoRepeatSymbol.symbols[name];
|
|
62
|
+
score.staves.forEach((staff) => staff.measures[m - 1].setRepeatSymbol(new SmoRepeatSymbol(params)));
|
|
63
|
+
};
|
|
64
|
+
const setBarline = (score: SmoScore, m: number, position: 'start' | 'end', barline: string) => {
|
|
65
|
+
const params = SmoBarline.defaults;
|
|
66
|
+
params.position = SmoBarline.positions[position];
|
|
67
|
+
params.barline = SmoBarline.barlines[barline];
|
|
68
|
+
score.staves.forEach((staff) => staff.measures[m - 1].setBarline(new SmoBarline(params)));
|
|
69
|
+
};
|
|
70
|
+
/** A change carries forward, so apply it from measure m to the end */
|
|
71
|
+
const setKey = (score: SmoScore, m: number, key: string) =>
|
|
72
|
+
score.staves.forEach((staff) => staff.measures.forEach((mm, ix) => { if (ix >= m - 1) { mm.keySignature = key; } }));
|
|
73
|
+
const setTime = (score: SmoScore, m: number, beats: number, duration: number) =>
|
|
74
|
+
score.staves.forEach((staff) => staff.measures.forEach((mm, ix) => {
|
|
75
|
+
if (ix >= m - 1) {
|
|
76
|
+
mm.timeSignature = new SmoTimeSignature({ ...SmoTimeSignature.defaults, times: [{ actualBeats: beats, beatDuration: duration }] });
|
|
77
|
+
}
|
|
78
|
+
}));
|
|
79
|
+
const setTempo = (score: SmoScore, m: number, display: boolean) =>
|
|
80
|
+
score.staves.forEach((staff) => staff.measures.forEach((mm, ix) => {
|
|
81
|
+
if (ix >= m - 1) {
|
|
82
|
+
mm.tempo = new SmoTempo({ ...SmoTempo.defaults, bpm: 90, display });
|
|
83
|
+
}
|
|
84
|
+
}));
|
|
85
|
+
const setInstrument = (score: SmoScore, m: number) => {
|
|
86
|
+
const instrument = SmoInstrument.defaults;
|
|
87
|
+
instrument.startSelector.measure = m - 1;
|
|
88
|
+
score.staves[0].measureInstrumentMap[m - 1] = new SmoInstrument(instrument);
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
// --- readers ---
|
|
92
|
+
/** Blocks of two or more measures, as 'start:length' (1-based) */
|
|
93
|
+
const blocks = (score: SmoScore, staff: number = 0): string[] => {
|
|
94
|
+
const rv: string[] = [];
|
|
95
|
+
score.staves[staff].measures.forEach((mm, ix) => {
|
|
96
|
+
if (mm.svg.multimeasureLength > 0) {
|
|
97
|
+
rv.push(`${ix + 1}:${mm.svg.multimeasureLength}`);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
return rv;
|
|
101
|
+
};
|
|
102
|
+
const hidden = (score: SmoScore, staff: number = 0): number[] => {
|
|
103
|
+
const rv: number[] = [];
|
|
104
|
+
score.staves[staff].measures.forEach((mm, ix) => { if (mm.svg.hideMultimeasure) { rv.push(ix + 1); } });
|
|
105
|
+
return rv;
|
|
106
|
+
};
|
|
107
|
+
/** every measure is in a block or an ordinary bar, and the lengths add up */
|
|
108
|
+
const accounted = (score: SmoScore): boolean => {
|
|
109
|
+
let total = 0;
|
|
110
|
+
score.staves[0].measures.forEach((mm) => {
|
|
111
|
+
if (mm.svg.multimeasureLength > 0) {
|
|
112
|
+
total += mm.svg.multimeasureLength;
|
|
113
|
+
} else if (!mm.svg.hideMultimeasure) {
|
|
114
|
+
total += 1;
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
return total === COUNT;
|
|
118
|
+
};
|
|
119
|
+
const ordinary = (score: SmoScore, m: number) =>
|
|
120
|
+
measureAt(score, m).svg.multimeasureLength === 0 && !measureAt(score, m).svg.hideMultimeasure;
|
|
121
|
+
const run = (score: SmoScore) => SmoOperation.computeMultipartRest(score);
|
|
122
|
+
const same = (a: string[], b: string[]) => JSON.stringify(a) === JSON.stringify(b);
|
|
123
|
+
const range = (from: number, to: number): number[] => {
|
|
124
|
+
const rv: number[] = [];
|
|
125
|
+
for (let i = from; i <= to; ++i) { rv.push(i); }
|
|
126
|
+
return rv;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
// --- G1: no landmarks ---
|
|
130
|
+
{
|
|
131
|
+
const score = buildScore();
|
|
132
|
+
run(score);
|
|
133
|
+
check('G1 one block of 12', same(blocks(score), ['1:12']), JSON.stringify(blocks(score)));
|
|
134
|
+
check('G1 measures 2 to 12 are hidden', JSON.stringify(hidden(score)) === JSON.stringify(range(2, 12)));
|
|
135
|
+
check('G1 every measure accounted for', accounted(score));
|
|
136
|
+
}
|
|
137
|
+
// --- G2: rehearsal mark in the middle ---
|
|
138
|
+
{
|
|
139
|
+
const score = buildScore();
|
|
140
|
+
addRehearsal(score, 6);
|
|
141
|
+
run(score);
|
|
142
|
+
check('G2 two blocks, 5 and 7', same(blocks(score), ['1:5', '6:7']), JSON.stringify(blocks(score)));
|
|
143
|
+
check('G2 no lone bar: measure 6 starts a block and is not hidden', !hidden(score).includes(6) && measureAt(score, 6).svg.multimeasureLength === 7);
|
|
144
|
+
check('G2 hidden are 2-5 and 7-12', JSON.stringify(hidden(score)) === JSON.stringify(range(2, 5).concat(range(7, 12))));
|
|
145
|
+
check('G2 every measure accounted for', accounted(score));
|
|
146
|
+
}
|
|
147
|
+
// --- G3: rehearsal mark on the first measure ---
|
|
148
|
+
{
|
|
149
|
+
const score = buildScore();
|
|
150
|
+
addRehearsal(score, 1);
|
|
151
|
+
run(score);
|
|
152
|
+
check('G3 one block of 12', same(blocks(score), ['1:12']), JSON.stringify(blocks(score)));
|
|
153
|
+
}
|
|
154
|
+
// --- G4: rehearsal mark on the last measure ---
|
|
155
|
+
{
|
|
156
|
+
const score = buildScore();
|
|
157
|
+
addRehearsal(score, 12);
|
|
158
|
+
run(score);
|
|
159
|
+
check('G4 block of 11, last measure an ordinary bar', same(blocks(score), ['1:11']) && ordinary(score, 12), JSON.stringify(blocks(score)));
|
|
160
|
+
check('G4 every measure accounted for', accounted(score));
|
|
161
|
+
}
|
|
162
|
+
// --- G5: two marks ---
|
|
163
|
+
{
|
|
164
|
+
const score = buildScore();
|
|
165
|
+
addRehearsal(score, 4);
|
|
166
|
+
addRehearsal(score, 8);
|
|
167
|
+
run(score);
|
|
168
|
+
check('G5 blocks 3, 4, 5', same(blocks(score), ['1:3', '4:4', '8:5']), JSON.stringify(blocks(score)));
|
|
169
|
+
check('G5 every measure accounted for', accounted(score));
|
|
170
|
+
}
|
|
171
|
+
// --- G6-G10: key, time, tempo ---
|
|
172
|
+
{
|
|
173
|
+
const score = buildScore();
|
|
174
|
+
setKey(score, 5, 'D');
|
|
175
|
+
run(score);
|
|
176
|
+
check('G6 key change at 5', same(blocks(score), ['1:4', '5:8']), JSON.stringify(blocks(score)));
|
|
177
|
+
}
|
|
178
|
+
{
|
|
179
|
+
const score = buildScore();
|
|
180
|
+
setTime(score, 5, 3, 4);
|
|
181
|
+
run(score);
|
|
182
|
+
check('G7 time signature change at 5', same(blocks(score), ['1:4', '5:8']), JSON.stringify(blocks(score)));
|
|
183
|
+
}
|
|
184
|
+
{
|
|
185
|
+
const score = buildScore();
|
|
186
|
+
setTempo(score, 5, true);
|
|
187
|
+
run(score);
|
|
188
|
+
check('G8 displayed tempo change at 5', same(blocks(score), ['1:4', '5:8']), JSON.stringify(blocks(score)));
|
|
189
|
+
}
|
|
190
|
+
{
|
|
191
|
+
const score = buildScore();
|
|
192
|
+
setTempo(score, 5, false);
|
|
193
|
+
run(score);
|
|
194
|
+
check('G9 tempo change that is not displayed does not split', same(blocks(score), ['1:12']), JSON.stringify(blocks(score)));
|
|
195
|
+
}
|
|
196
|
+
{
|
|
197
|
+
const score = buildScore();
|
|
198
|
+
setKey(score, 5, 'D');
|
|
199
|
+
addRehearsal(score, 5);
|
|
200
|
+
run(score);
|
|
201
|
+
check('G10 key change and rehearsal mark together split once', same(blocks(score), ['1:4', '5:8']), JSON.stringify(blocks(score)));
|
|
202
|
+
}
|
|
203
|
+
// --- G11-G12: Segno and Coda start the next block ---
|
|
204
|
+
{
|
|
205
|
+
const score = buildScore();
|
|
206
|
+
setSymbol(score, 5, 'Segno');
|
|
207
|
+
run(score);
|
|
208
|
+
check('G11 Segno at 5', same(blocks(score), ['1:4', '5:8']), JSON.stringify(blocks(score)));
|
|
209
|
+
check('G11 a start symbol is not recorded as an end symbol', measureAt(score, 1).svg.multimeasureEndSymbol === null);
|
|
210
|
+
}
|
|
211
|
+
{
|
|
212
|
+
const score = buildScore();
|
|
213
|
+
setSymbol(score, 9, 'Coda');
|
|
214
|
+
run(score);
|
|
215
|
+
check('G12 Coda at 9', same(blocks(score), ['1:8', '9:4']), JSON.stringify(blocks(score)));
|
|
216
|
+
}
|
|
217
|
+
// --- G13-G15: end symbols close the block and are recorded on it ---
|
|
218
|
+
{
|
|
219
|
+
const score = buildScore();
|
|
220
|
+
setSymbol(score, 4, 'DsAlCoda');
|
|
221
|
+
run(score);
|
|
222
|
+
check('G13 D.S. al Coda on 4 ends the first block', same(blocks(score), ['1:4', '5:8']), JSON.stringify(blocks(score)));
|
|
223
|
+
const sym = measureAt(score, 1).svg.multimeasureEndSymbol;
|
|
224
|
+
check('G13 the symbol is recorded on the first measure of the block', !!sym && sym.symbol === SmoRepeatSymbol.symbols.DsAlCoda);
|
|
225
|
+
check('G13 the next block has no end symbol', measureAt(score, 5).svg.multimeasureEndSymbol === null);
|
|
226
|
+
check('G13 every measure accounted for', accounted(score));
|
|
227
|
+
}
|
|
228
|
+
{
|
|
229
|
+
const score = buildScore();
|
|
230
|
+
setSymbol(score, 6, 'ToCoda');
|
|
231
|
+
run(score);
|
|
232
|
+
check('G14 To Coda on 6', same(blocks(score), ['1:6', '7:6']), JSON.stringify(blocks(score)));
|
|
233
|
+
const sym = measureAt(score, 1).svg.multimeasureEndSymbol;
|
|
234
|
+
check('G14 the symbol is recorded on the first measure', !!sym && sym.symbol === SmoRepeatSymbol.symbols.ToCoda);
|
|
235
|
+
}
|
|
236
|
+
{
|
|
237
|
+
const score = buildScore();
|
|
238
|
+
setSymbol(score, 1, 'DcAlFine');
|
|
239
|
+
run(score);
|
|
240
|
+
check('G15 D.C. al Fine on the first measure: it is an ordinary bar, the rest follows', ordinary(score, 1) && same(blocks(score), ['2:11']), JSON.stringify(blocks(score)));
|
|
241
|
+
check('G15 the lone bar keeps its own symbol (none recorded)', measureAt(score, 1).svg.multimeasureEndSymbol === null);
|
|
242
|
+
}
|
|
243
|
+
// --- G16-G18: barlines ---
|
|
244
|
+
{
|
|
245
|
+
const score = buildScore();
|
|
246
|
+
setBarline(score, 4, 'end', 'endRepeat');
|
|
247
|
+
run(score);
|
|
248
|
+
check('G16 end repeat after measure 4', same(blocks(score), ['1:4', '5:8']), JSON.stringify(blocks(score)));
|
|
249
|
+
check('G16 the first block ends with the repeat barline', measureAt(score, 1).svg.multimeasureEndBarline === SmoBarline.barlines.endRepeat);
|
|
250
|
+
check('G16 the second block ends with a plain barline', measureAt(score, 5).svg.multimeasureEndBarline === SmoBarline.barlines.singleBar);
|
|
251
|
+
}
|
|
252
|
+
{
|
|
253
|
+
const score = buildScore();
|
|
254
|
+
setBarline(score, 5, 'start', 'startRepeat');
|
|
255
|
+
run(score);
|
|
256
|
+
check('G17 start repeat on measure 5', same(blocks(score), ['1:4', '5:8']), JSON.stringify(blocks(score)));
|
|
257
|
+
}
|
|
258
|
+
{
|
|
259
|
+
const a = buildScore();
|
|
260
|
+
setBarline(a, 4, 'end', 'doubleBar');
|
|
261
|
+
run(a);
|
|
262
|
+
const b = buildScore();
|
|
263
|
+
setBarline(b, 5, 'start', 'doubleBar');
|
|
264
|
+
run(b);
|
|
265
|
+
check('G18 double bar as the end of 4', same(blocks(a), ['1:4', '5:8']), JSON.stringify(blocks(a)));
|
|
266
|
+
check('G18 double bar as the start of 5', same(blocks(b), ['1:4', '5:8']), JSON.stringify(blocks(b)));
|
|
267
|
+
}
|
|
268
|
+
// --- G19: instrument change ---
|
|
269
|
+
{
|
|
270
|
+
const score = buildScore();
|
|
271
|
+
setInstrument(score, 7);
|
|
272
|
+
run(score);
|
|
273
|
+
check('G19 instrument change at 7', same(blocks(score), ['1:6', '7:6']), JSON.stringify(blocks(score)));
|
|
274
|
+
}
|
|
275
|
+
// --- G20: a measure with both kinds of landmark is a block of its own ---
|
|
276
|
+
{
|
|
277
|
+
const score = buildScore();
|
|
278
|
+
addRehearsal(score, 5);
|
|
279
|
+
setSymbol(score, 5, 'DsAlFine');
|
|
280
|
+
run(score);
|
|
281
|
+
check('G20 rehearsal mark and D.S. on 5: blocks 1-4 and 6-12', same(blocks(score), ['1:4', '6:7']), JSON.stringify(blocks(score)));
|
|
282
|
+
check('G20 measure 5 is an ordinary bar', ordinary(score, 5));
|
|
283
|
+
check('G20 every measure accounted for', accounted(score));
|
|
284
|
+
}
|
|
285
|
+
// --- G21: expanded rests ---
|
|
286
|
+
{
|
|
287
|
+
const score = buildScore();
|
|
288
|
+
score.staves[0].partInfo.expandMultimeasureRests = true;
|
|
289
|
+
addRehearsal(score, 6);
|
|
290
|
+
setSymbol(score, 4, 'DsAlCoda');
|
|
291
|
+
run(score);
|
|
292
|
+
check('G21 no blocks and nothing hidden when rests are expanded', blocks(score).length === 0 && hidden(score).length === 0);
|
|
293
|
+
}
|
|
294
|
+
// --- G22: a volta ending is never grouped ---
|
|
295
|
+
{
|
|
296
|
+
const score = buildScore();
|
|
297
|
+
const volta = new SmoVolta({ ...SmoVolta.defaults,
|
|
298
|
+
startSelector: { staff: 0, measure: 4, voice: 0, tick: 0, pitches: [] },
|
|
299
|
+
endSelector: { staff: 0, measure: 5, voice: 0, tick: 0, pitches: [] } } as any);
|
|
300
|
+
measureAt(score, 5).addNthEnding(volta);
|
|
301
|
+
run(score);
|
|
302
|
+
check('G22 measures 5 and 6 under the ending are ordinary bars', ordinary(score, 5) && ordinary(score, 6), JSON.stringify(blocks(score)));
|
|
303
|
+
check('G22 the rests before and after still group', same(blocks(score), ['1:4', '7:6']), JSON.stringify(blocks(score)));
|
|
304
|
+
check('G22 every measure accounted for', accounted(score));
|
|
305
|
+
}
|
|
306
|
+
// --- G23: two staves, a mark on only one ---
|
|
307
|
+
{
|
|
308
|
+
const score = buildScore(2);
|
|
309
|
+
addRehearsal(score, 6, 1);
|
|
310
|
+
run(score);
|
|
311
|
+
// measure 1 of a part with more than one staff is never the start of a block (unchanged behavior)
|
|
312
|
+
check('G23 staff 0 blocks', same(blocks(score, 0), ['2:4', '6:7']), JSON.stringify(blocks(score, 0)));
|
|
313
|
+
check('G23 staff 1 has the same blocks', same(blocks(score, 1), blocks(score, 0)), JSON.stringify(blocks(score, 1)));
|
|
314
|
+
check('G23 and the same hidden measures', JSON.stringify(hidden(score, 1)) === JSON.stringify(hidden(score, 0)));
|
|
315
|
+
}
|
|
316
|
+
// --- G24: regrouping leaves nothing stale ---
|
|
317
|
+
{
|
|
318
|
+
const score = buildScore();
|
|
319
|
+
addRehearsal(score, 6);
|
|
320
|
+
setSymbol(score, 4, 'DsAlCoda');
|
|
321
|
+
run(score);
|
|
322
|
+
measureAt(score, 6).removeRehearsalMark();
|
|
323
|
+
setSymbol(score, 4, 'None');
|
|
324
|
+
run(score);
|
|
325
|
+
check('G24 back to one block of 12', same(blocks(score), ['1:12']), JSON.stringify(blocks(score)));
|
|
326
|
+
check('G24 measures 2 to 12 hidden, none else', JSON.stringify(hidden(score)) === JSON.stringify(range(2, 12)));
|
|
327
|
+
const lengths = score.staves[0].measures.map((mm) => mm.svg.multimeasureLength).join();
|
|
328
|
+
check('G24 no stale length on other measures', lengths === '12,0,0,0,0,0,0,0,0,0,0,0', lengths);
|
|
329
|
+
check('G24 no stale end symbol', score.staves[0].measures.every((mm) => mm.svg.multimeasureEndSymbol === null));
|
|
330
|
+
check('G24 every measure accounted for', accounted(score));
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
if (failures > 0) {
|
|
334
|
+
console.log(`${failures} check(s) failed`);
|
|
335
|
+
process.exitCode = 1;
|
|
336
|
+
} else {
|
|
337
|
+
console.log('all checks passed');
|
|
338
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Headless checks for computeDivisions/findDivision, the pure region math behind SvgPage's
|
|
3
|
+
* modifier filing and lookup. Cases D1-D17 are listed in
|
|
4
|
+
* specs/027-fix-bottom-modifier-lookup/contracts/division-lookup-contract.md.
|
|
5
|
+
*
|
|
6
|
+
* Run with: npm run test:page-divisions
|
|
7
|
+
*/
|
|
8
|
+
import { computeDivisions, findDivision, PageDivision } from '../src/render/sui/pageDivisions';
|
|
9
|
+
|
|
10
|
+
let failures = 0;
|
|
11
|
+
const check = (name: string, condition: boolean, detail?: string) => {
|
|
12
|
+
if (condition) {
|
|
13
|
+
console.log(`PASS ${name}`);
|
|
14
|
+
} else {
|
|
15
|
+
failures += 1;
|
|
16
|
+
console.log(`FAIL ${name}${detail ? ' -- ' + detail : ''}`);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/** The formula SvgPage.divIndex used before this fix, kept to document the bug. */
|
|
21
|
+
const legacyIndex = (pos: number, start: number, extent: number) => Math.round((pos - start) / (extent / 8));
|
|
22
|
+
|
|
23
|
+
const table = computeDivisions(0, 1000, 8);
|
|
24
|
+
|
|
25
|
+
// --- D1-D3: shape of the table ---
|
|
26
|
+
check('D1 eight divisions', table.length === 8, `got ${table.length}`);
|
|
27
|
+
check('D2 first start and last end are exact', table[0].start === 0 && table[7].end === 1000,
|
|
28
|
+
`${table[0].start}, ${table[7].end}`);
|
|
29
|
+
{
|
|
30
|
+
let contiguous = true;
|
|
31
|
+
for (let i = 0; i < 7; ++i) {
|
|
32
|
+
contiguous = contiguous && table[i].end === table[i + 1].start;
|
|
33
|
+
}
|
|
34
|
+
check('D3 divisions are contiguous', contiguous);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// --- D4: midpoints ---
|
|
38
|
+
for (let i = 0; i < 8; ++i) {
|
|
39
|
+
const got = findDivision(62.5 + 125 * i, table);
|
|
40
|
+
check(`D4 midpoint of division ${i}`, got === i, `got ${got}`);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// --- D5: lower half of the last division (the original bug) ---
|
|
44
|
+
check('D5 legacy formula dropped 950 (index 8)', legacyIndex(950, 0, 1000) === 8);
|
|
45
|
+
check('D5 950 is in the last division', findDivision(950, table) === 7, `got ${findDivision(950, table)}`);
|
|
46
|
+
|
|
47
|
+
// --- D6-D7: page edges ---
|
|
48
|
+
check('D6 top edge is division 0', findDivision(0, table) === 0);
|
|
49
|
+
check('D7 bottom edge is the last division', findDivision(1000, table) === 7, `got ${findDivision(1000, table)}`);
|
|
50
|
+
|
|
51
|
+
// --- D8-D9: boundaries ---
|
|
52
|
+
check('D8 interior boundary belongs to the later division', findDivision(125, table) === 1);
|
|
53
|
+
check('D8 boundary result is stable', findDivision(125, table) === findDivision(125, table));
|
|
54
|
+
check('D9 just below a boundary', findDivision(124.999, table) === 0);
|
|
55
|
+
check('D9 just above a boundary', findDivision(125.001, table) === 1);
|
|
56
|
+
|
|
57
|
+
// --- D10-D12: outside the page ---
|
|
58
|
+
check('D10 before the page', findDivision(-0.001, table) === -1);
|
|
59
|
+
check('D11 after the page', findDivision(1000.001, table) === -1);
|
|
60
|
+
check('D12 NaN', findDivision(NaN, table) === -1);
|
|
61
|
+
check('D12 Infinity', findDivision(Infinity, table) === -1);
|
|
62
|
+
check('D12 -Infinity', findDivision(-Infinity, table) === -1);
|
|
63
|
+
|
|
64
|
+
// --- D13: a page that does not start at 0 ---
|
|
65
|
+
{
|
|
66
|
+
const page3 = computeDivisions(2000, 1000, 8);
|
|
67
|
+
check('D13 page start', findDivision(2000, page3) === 0);
|
|
68
|
+
check('D13 just inside the bottom', findDivision(2999, page3) === 7);
|
|
69
|
+
// 3000 is page 3's trailing edge (and page 4's top). SvgPageMap routes that coordinate to
|
|
70
|
+
// the next page before this lookup runs, so treating it as the last division here is harmless.
|
|
71
|
+
check('D13 trailing edge is the last division', findDivision(3000, page3) === 7);
|
|
72
|
+
check('D13 before the page', findDivision(1999.5, page3) === -1);
|
|
73
|
+
check('D13 first start and last end are exact', page3[0].start === 2000 && page3[7].end === 3000);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// --- D14: other page sizes ---
|
|
77
|
+
for (const extent of [800, 1056, 1123]) {
|
|
78
|
+
const t = computeDivisions(0, extent, 8);
|
|
79
|
+
let ok = true;
|
|
80
|
+
let monotonic = true;
|
|
81
|
+
let prev = -1;
|
|
82
|
+
let hitLast = false;
|
|
83
|
+
for (let p = 0; p <= extent; p += extent / 64) {
|
|
84
|
+
const ix = findDivision(p, t);
|
|
85
|
+
ok = ok && ix >= 0 && ix <= 7;
|
|
86
|
+
monotonic = monotonic && ix >= prev;
|
|
87
|
+
prev = ix;
|
|
88
|
+
hitLast = hitLast || ix === 7;
|
|
89
|
+
}
|
|
90
|
+
check(`D14 extent ${extent}: every position maps to a division`, ok);
|
|
91
|
+
check(`D14 extent ${extent}: indices never decrease`, monotonic);
|
|
92
|
+
check(`D14 extent ${extent}: last division is reached`, hitLast);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// --- D15: exhaustive sweep ---
|
|
96
|
+
{
|
|
97
|
+
let noneOutside = true;
|
|
98
|
+
let monotonic = true;
|
|
99
|
+
let prev = 0;
|
|
100
|
+
const seen = new Set<number>();
|
|
101
|
+
for (let p = 0; p <= 1000; p += 0.5) {
|
|
102
|
+
const ix = findDivision(p, table);
|
|
103
|
+
noneOutside = noneOutside && ix >= 0 && ix <= 7;
|
|
104
|
+
monotonic = monotonic && ix >= prev;
|
|
105
|
+
prev = ix;
|
|
106
|
+
seen.add(ix);
|
|
107
|
+
}
|
|
108
|
+
check('D15 no position is outside a division', noneOutside);
|
|
109
|
+
check('D15 indices never decrease', monotonic);
|
|
110
|
+
check('D15 all eight divisions are hit', seen.size === 8 && [0, 1, 2, 3, 4, 5, 6, 7].every((i) => seen.has(i)));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// --- D16: filing and lookup agree ---
|
|
114
|
+
{
|
|
115
|
+
// Mimic SvgPage.modifierTabDivs: file a tab per sampled position, then look it up.
|
|
116
|
+
const filed: Record<number, string[]> = {};
|
|
117
|
+
const positions: number[] = [];
|
|
118
|
+
for (let p = 0; p <= 1000; p += 1) {
|
|
119
|
+
positions.push(p);
|
|
120
|
+
}
|
|
121
|
+
table.forEach((d: PageDivision) => positions.push(d.start, d.end));
|
|
122
|
+
positions.forEach((p) => {
|
|
123
|
+
const ix = findDivision(p, table);
|
|
124
|
+
if (ix >= 0) {
|
|
125
|
+
filed[ix] = filed[ix] ?? [];
|
|
126
|
+
filed[ix].push(`tab-${p}`);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
const allFound = positions.every((p) => {
|
|
130
|
+
const ix = findDivision(p, table);
|
|
131
|
+
return ix >= 0 && !!filed[ix] && filed[ix].indexOf(`tab-${p}`) >= 0;
|
|
132
|
+
});
|
|
133
|
+
check('D16 a tab filed at a position is found by a lookup at that position', allFound);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// --- D17: nothing that could be filed before is lost ---
|
|
137
|
+
{
|
|
138
|
+
let nothingLost = true;
|
|
139
|
+
let closeToLegacy = true;
|
|
140
|
+
for (let p = 0; p < 937.5; p += 1) {
|
|
141
|
+
// below the old cutoff, the legacy formula produced a valid index (0-7)
|
|
142
|
+
const old = legacyIndex(p, 0, 1000);
|
|
143
|
+
const now = findDivision(p, table);
|
|
144
|
+
nothingLost = nothingLost && now >= 0;
|
|
145
|
+
closeToLegacy = closeToLegacy && Math.abs(now - old) <= 1;
|
|
146
|
+
}
|
|
147
|
+
check('D17 every position that was filed before is still filed', nothingLost);
|
|
148
|
+
check('D17 new index is within one of the legacy index', closeToLegacy);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (failures > 0) {
|
|
152
|
+
console.log(`${failures} check(s) failed`);
|
|
153
|
+
process.exitCode = 1;
|
|
154
|
+
} else {
|
|
155
|
+
console.log('all checks passed');
|
|
156
|
+
}
|