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,417 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Headless checks for copying and pasting voices (PasteBuffer.setVoiceSelections, pasteVoice,
|
|
3
|
+
* pasteAllVoices, and the menu choice functions). Cases V1-V20 are listed in
|
|
4
|
+
* specs/030-copy-paste-voices/contracts/voice-copy-paste-contract.md.
|
|
5
|
+
*
|
|
6
|
+
* Run with: npm run test:voice-copy-paste
|
|
7
|
+
*/
|
|
8
|
+
import { SmoScore } from '../src/smo/data/score';
|
|
9
|
+
import { SmoMeasure } from '../src/smo/data/measure';
|
|
10
|
+
import { SmoNote } from '../src/smo/data/note';
|
|
11
|
+
import { SmoSelection, SmoSelector } from '../src/smo/xform/selections';
|
|
12
|
+
import { SmoOperation } from '../src/smo/xform/operations';
|
|
13
|
+
import { PasteBuffer } from '../src/smo/xform/copypaste';
|
|
14
|
+
import { SmoSlur } from '../src/smo/data/staffModifiers';
|
|
15
|
+
import { noteModifierDynamicCtorInit } from '../src/smo/data/noteModifiers';
|
|
16
|
+
import { measureModifierDynamicCtorInit } from '../src/smo/data/measureModifiers';
|
|
17
|
+
import { staffModifierDynamicCtorInit } from '../src/smo/data/staffModifiers';
|
|
18
|
+
import { scoreModifierDynamicCtorInit } from '../src/smo/data/scoreModifiers';
|
|
19
|
+
|
|
20
|
+
// The smo layer registers its deserialization factories at app start; do the same here
|
|
21
|
+
// without pulling in any UI.
|
|
22
|
+
noteModifierDynamicCtorInit();
|
|
23
|
+
measureModifierDynamicCtorInit();
|
|
24
|
+
staffModifierDynamicCtorInit();
|
|
25
|
+
scoreModifierDynamicCtorInit();
|
|
26
|
+
|
|
27
|
+
let failures = 0;
|
|
28
|
+
const check = (name: string, condition: boolean, detail?: string) => {
|
|
29
|
+
if (condition) {
|
|
30
|
+
console.log(`PASS ${name}`);
|
|
31
|
+
} else {
|
|
32
|
+
failures += 1;
|
|
33
|
+
console.log(`FAIL ${name}${detail ? ' -- ' + detail : ''}`);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const LETTERS = ['c', 'd', 'e', 'f', 'g', 'a', 'b'];
|
|
38
|
+
/** Give a quarter-note slot a pitch that encodes where it is, so a pasted note can be traced */
|
|
39
|
+
const encodePitch = (note: SmoNote, measure: number, voice: number, tick: number) => {
|
|
40
|
+
note.noteType = 'n';
|
|
41
|
+
note.pitches = [{ letter: LETTERS[(measure + tick + voice * 2) % 7] as any, accidental: 'n', octave: 3 + voice }];
|
|
42
|
+
};
|
|
43
|
+
const fillVoice = (measure: SmoMeasure, voice: number, measureIx: number) => {
|
|
44
|
+
while (measure.voices.length <= voice) {
|
|
45
|
+
measure.populateVoice(measure.voices.length);
|
|
46
|
+
}
|
|
47
|
+
measure.voices[voice].notes.forEach((note, tick) => encodePitch(note, measureIx, voice, tick));
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/** Voice `v` of measure `m` as a list of 'pitch:ticks' strings, or null if the voice doesn't exist */
|
|
51
|
+
const voiceNotes = (score: SmoScore, m: number, v: number, staff: number = 0): string[] | null => {
|
|
52
|
+
const measure = score.staves[staff].measures[m];
|
|
53
|
+
if (!measure || measure.voices.length <= v) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
return measure.voices[v].notes.map((note) => {
|
|
57
|
+
const p = note.pitches[0];
|
|
58
|
+
return `${note.noteType === 'r' ? 'r' : p.letter + p.octave}:${note.tickCount}`;
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
const same = (a: string[] | null, b: string[] | null) => JSON.stringify(a) === JSON.stringify(b);
|
|
62
|
+
const voiceCount = (score: SmoScore, m: number, staff: number = 0) => score.staves[staff].measures[m].voices.length;
|
|
63
|
+
const tupletVoices = (score: SmoScore, m: number, staff: number = 0): number[] =>
|
|
64
|
+
score.staves[staff].measures[m].tupletTrees.map((tree) => tree.voice);
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Single staff, 12 measures (indexes 0-11) of 4/4. Voice 0 on every measure; voice 1 on
|
|
68
|
+
* measures 0-3; voice 2 on measure 1 only; a triplet in voice 0 of measure 5 and in voice 1 of
|
|
69
|
+
* measure 6 (voice 1 also exists there); measure 9 has one voice.
|
|
70
|
+
*/
|
|
71
|
+
const buildScore = (): SmoScore => {
|
|
72
|
+
const score = SmoScore.getDefaultScore(SmoScore.defaults, null);
|
|
73
|
+
while (score.staves[0].measures.length < 12) {
|
|
74
|
+
score.addMeasure(score.staves[0].measures.length - 1);
|
|
75
|
+
}
|
|
76
|
+
score.staves[0].measures.forEach((measure, m) => {
|
|
77
|
+
fillVoice(measure, 0, m);
|
|
78
|
+
if (m < 4 || m === 6) {
|
|
79
|
+
fillVoice(measure, 1, m);
|
|
80
|
+
}
|
|
81
|
+
if (m === 1) {
|
|
82
|
+
fillVoice(measure, 2, m);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
// triplets: quarter notes 0-2 of voice 0 in measure 5, and of voice 1 in measure 6
|
|
86
|
+
const trip = (m: number, v: number) => {
|
|
87
|
+
const sel = SmoSelection.noteSelection(score, 0, m, v, 0)!;
|
|
88
|
+
SmoOperation.makeTuplet(sel, { numNotes: 3, notesOccupied: 2, bracketed: true, ratioed: false } as any);
|
|
89
|
+
};
|
|
90
|
+
trip(5, 0);
|
|
91
|
+
trip(6, 1);
|
|
92
|
+
return score;
|
|
93
|
+
};
|
|
94
|
+
/** Note selections covering ticks first-last of voice v in measure m, for copy */
|
|
95
|
+
const selectNotes = (score: SmoScore, m: number, first: number, last: number, v: number = 0): SmoSelection[] => {
|
|
96
|
+
const rv: SmoSelection[] = [];
|
|
97
|
+
for (let t = first; t <= last; ++t) {
|
|
98
|
+
const sel = SmoSelection.noteSelection(score, 0, m, v, t);
|
|
99
|
+
if (sel) {
|
|
100
|
+
rv.push(sel);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return rv;
|
|
104
|
+
};
|
|
105
|
+
const dest = (measure: number, staff: number = 0): SmoSelector => ({ staff, measure, voice: 0, tick: 0, pitches: [] });
|
|
106
|
+
|
|
107
|
+
// --- V1-V4: menu choice functions ---
|
|
108
|
+
check('V1 copy choices, no voices', JSON.stringify(PasteBuffer.copyVoiceChoices(0)) === '[]');
|
|
109
|
+
check('V1 copy choices, one voice', JSON.stringify(PasteBuffer.copyVoiceChoices(1)) === '[0]');
|
|
110
|
+
check('V1 copy choices, two voices', JSON.stringify(PasteBuffer.copyVoiceChoices(2)) === '[0,1,"all"]');
|
|
111
|
+
check('V1 copy choices, three voices', JSON.stringify(PasteBuffer.copyVoiceChoices(3)) === '[0,1,2,"all"]');
|
|
112
|
+
check('V2 paste choices with no voice copy', JSON.stringify(PasteBuffer.pasteVoiceChoices([], 2)) === '[]');
|
|
113
|
+
check('V3 one destination voice: replace it, or add a new voice', JSON.stringify(PasteBuffer.pasteVoiceChoices([1], 1)) === '[0,"new"]');
|
|
114
|
+
check('V3 two destination voices', JSON.stringify(PasteBuffer.pasteVoiceChoices([0], 2)) === '[0,1,"new"]');
|
|
115
|
+
check('V3 three destination voices', JSON.stringify(PasteBuffer.pasteVoiceChoices([0], 3)) === '[0,1,2,"new"]');
|
|
116
|
+
check('V3 four destination voices: existing voices only, no new voice', JSON.stringify(PasteBuffer.pasteVoiceChoices([0], 4)) === '[0,1,2,3]');
|
|
117
|
+
check('V3 no destination offers nothing', JSON.stringify(PasteBuffer.pasteVoiceChoices([0], 0)) === '[]');
|
|
118
|
+
check('V4 paste choices, several copied voices', JSON.stringify(PasteBuffer.pasteVoiceChoices([0, 1], 1)) === '["all"]');
|
|
119
|
+
|
|
120
|
+
// --- V5: copy extends to whole measures ---
|
|
121
|
+
{
|
|
122
|
+
const score = buildScore();
|
|
123
|
+
const buffer = new PasteBuffer();
|
|
124
|
+
// from the 3rd note of measure 1 to the 2nd note of measure 2
|
|
125
|
+
const sels = selectNotes(score, 1, 2, 3).concat(selectNotes(score, 2, 0, 1));
|
|
126
|
+
const ok = buffer.setVoiceSelections(score, sels, 0);
|
|
127
|
+
const vc = buffer.voiceCopy!;
|
|
128
|
+
check('V5 voice copy succeeds', ok && !!vc);
|
|
129
|
+
check('V5 covers measures 1 to 2', vc.firstMeasure === 1 && vc.measureCount === 2, `first=${vc.firstMeasure} count=${vc.measureCount}`);
|
|
130
|
+
check('V5 copies all 8 notes of the two whole measures', vc.notes[0][0].length === 8, `n=${vc.notes[0][0].length}`);
|
|
131
|
+
check('V5 one voice copied', JSON.stringify(vc.voices) === '[0]');
|
|
132
|
+
check('V5 tick count is two measures', buffer.getVoiceCopyTickCount() === 2 * 16384, `${buffer.getVoiceCopyTickCount()}`);
|
|
133
|
+
|
|
134
|
+
// --- V6, V7: paste into the same voice number elsewhere; other voices unchanged ---
|
|
135
|
+
const before7 = voiceNotes(score, 7, 1);
|
|
136
|
+
buffer.pasteVoice(dest(7), 0);
|
|
137
|
+
check('V6 measure 7 voice 0 equals measure 1 voice 0', same(voiceNotes(score, 7, 0), voiceNotes(score, 1, 0)));
|
|
138
|
+
check('V6 measure 8 voice 0 equals measure 2 voice 0', same(voiceNotes(score, 8, 0), voiceNotes(score, 2, 0)));
|
|
139
|
+
check('V7 other voices of the destination unchanged', same(voiceNotes(score, 7, 1), before7) && voiceCount(score, 7) === 1);
|
|
140
|
+
check('V6 the copy is still there after a paste', buffer.hasVoiceCopy());
|
|
141
|
+
buffer.pasteVoice(dest(10), 0);
|
|
142
|
+
check('V6 a second paste from the same copy works', same(voiceNotes(score, 10, 0), voiceNotes(score, 1, 0)) &&
|
|
143
|
+
same(voiceNotes(score, 11, 0), voiceNotes(score, 2, 0)));
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// --- V8: paste into an existing different voice ---
|
|
147
|
+
{
|
|
148
|
+
const score = buildScore();
|
|
149
|
+
const buffer = new PasteBuffer();
|
|
150
|
+
buffer.setVoiceSelections(score, selectNotes(score, 0, 0, 0), 0);
|
|
151
|
+
const v0Before = voiceNotes(score, 3, 0);
|
|
152
|
+
buffer.pasteVoice(dest(3), 1);
|
|
153
|
+
check('V8 voice 1 of measure 3 replaced by the copied voice 0', same(voiceNotes(score, 3, 1), voiceNotes(score, 0, 0)));
|
|
154
|
+
check('V8 voice 0 of measure 3 unchanged', same(voiceNotes(score, 3, 0), v0Before));
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// --- V9: paste into the next empty voice ---
|
|
158
|
+
{
|
|
159
|
+
const score = buildScore();
|
|
160
|
+
const buffer = new PasteBuffer();
|
|
161
|
+
buffer.setVoiceSelections(score, selectNotes(score, 0, 0, 0), 0);
|
|
162
|
+
const v0Before = voiceNotes(score, 9, 0);
|
|
163
|
+
check('V9 measure 9 starts with one voice', voiceCount(score, 9) === 1);
|
|
164
|
+
buffer.pasteVoice(dest(9), 1);
|
|
165
|
+
check('V9 measure 9 now has two voices', voiceCount(score, 9) === 2, `n=${voiceCount(score, 9)}`);
|
|
166
|
+
check('V9 the new voice holds the copied notes', same(voiceNotes(score, 9, 1), voiceNotes(score, 0, 0)));
|
|
167
|
+
check('V9 voice 0 unchanged', same(voiceNotes(score, 9, 0), v0Before));
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// --- V10: copy voice 1, paste into voice 0 ---
|
|
171
|
+
{
|
|
172
|
+
const score = buildScore();
|
|
173
|
+
const buffer = new PasteBuffer();
|
|
174
|
+
buffer.setVoiceSelections(score, selectNotes(score, 0, 0, 0, 1), 1);
|
|
175
|
+
check('V10 voice 1 copied', JSON.stringify(buffer.copiedVoiceNumbers()) === '[1]');
|
|
176
|
+
buffer.pasteVoice(dest(10), 0);
|
|
177
|
+
check('V10 measure 10 voice 0 equals measure 0 voice 1', same(voiceNotes(score, 10, 0), voiceNotes(score, 0, 1)));
|
|
178
|
+
check('V10 measure 10 gets no second voice', voiceCount(score, 10) === 1);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// --- V11: copy All, paste All into a one-voice destination ---
|
|
182
|
+
{
|
|
183
|
+
const score = buildScore();
|
|
184
|
+
const buffer = new PasteBuffer();
|
|
185
|
+
const ok = buffer.setVoiceSelections(score, selectNotes(score, 1, 1, 2).concat(selectNotes(score, 2, 0, 0)), 'all');
|
|
186
|
+
check('V11 copy all succeeds', ok);
|
|
187
|
+
check('V11 voices 0 and 1 and 2 copied (measure 1 has three)', JSON.stringify(buffer.copiedVoiceNumbers()) === '[0,1,2]',
|
|
188
|
+
JSON.stringify(buffer.copiedVoiceNumbers()));
|
|
189
|
+
buffer.pasteAllVoices(dest(7));
|
|
190
|
+
check('V11 measure 7 has three voices', voiceCount(score, 7) === 3, `n=${voiceCount(score, 7)}`);
|
|
191
|
+
[0, 1, 2].forEach((v) => {
|
|
192
|
+
check(`V11 measure 7 voice ${v} equals measure 1 voice ${v}`, same(voiceNotes(score, 7, v), voiceNotes(score, 1, v)));
|
|
193
|
+
});
|
|
194
|
+
check('V11 measure 8 voice 0 equals measure 2 voice 0', same(voiceNotes(score, 8, 0), voiceNotes(score, 2, 0)));
|
|
195
|
+
check('V11 measure 8 voice 1 equals measure 2 voice 1', same(voiceNotes(score, 8, 1), voiceNotes(score, 2, 1)));
|
|
196
|
+
// measure 2 has no voice 2: the copy holds rests there, pasted as rests
|
|
197
|
+
const rests = voiceNotes(score, 8, 2);
|
|
198
|
+
check('V11 a copied voice missing from a measure is pasted as rests', rests !== null && rests.every((n) => n.startsWith('r:')),
|
|
199
|
+
JSON.stringify(rests));
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// --- V12: paste All onto a destination that already has voices ---
|
|
203
|
+
{
|
|
204
|
+
const score = buildScore();
|
|
205
|
+
const buffer = new PasteBuffer();
|
|
206
|
+
buffer.setVoiceSelections(score, selectNotes(score, 0, 0, 0), 'all');
|
|
207
|
+
buffer.pasteAllVoices(dest(2));
|
|
208
|
+
check('V12 measure 2 voice 0 replaced', same(voiceNotes(score, 2, 0), voiceNotes(score, 0, 0)));
|
|
209
|
+
check('V12 measure 2 voice 1 replaced', same(voiceNotes(score, 2, 1), voiceNotes(score, 0, 1)));
|
|
210
|
+
check('V12 measure 2 has two voices, no extra voice', voiceCount(score, 2) === 2, `n=${voiceCount(score, 2)}`);
|
|
211
|
+
check('V12 measure 3 (destination for the second copied measure? only one copied) is unchanged',
|
|
212
|
+
same(voiceNotes(score, 3, 1), voiceNotes(buildScore(), 3, 1)));
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// --- V13: uncopied destination voices are unchanged ---
|
|
216
|
+
{
|
|
217
|
+
const score = buildScore();
|
|
218
|
+
const buffer = new PasteBuffer();
|
|
219
|
+
// copy All from measure 6 (two voices: 0 and 1); the destination (measure 1) has a third voice
|
|
220
|
+
buffer.setVoiceSelections(score, selectNotes(score, 6, 0, 0), 'all');
|
|
221
|
+
check('V13 two voices copied', JSON.stringify(buffer.copiedVoiceNumbers()) === '[0,1]');
|
|
222
|
+
const v2Before = voiceNotes(score, 1, 2);
|
|
223
|
+
buffer.pasteAllVoices(dest(1));
|
|
224
|
+
check('V13 voice 2 of the destination, which was not copied, is unchanged', same(voiceNotes(score, 1, 2), v2Before));
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// --- V14: a paste past the end of the score is limited ---
|
|
228
|
+
{
|
|
229
|
+
const score = buildScore();
|
|
230
|
+
const buffer = new PasteBuffer();
|
|
231
|
+
buffer.setVoiceSelections(score, selectNotes(score, 0, 0, 0).concat(selectNotes(score, 3, 0, 0)), 0);
|
|
232
|
+
check('V14 copies four measures', buffer.voiceCopy!.measureCount === 4);
|
|
233
|
+
let threw = false;
|
|
234
|
+
try {
|
|
235
|
+
buffer.pasteVoice(dest(10), 0);
|
|
236
|
+
} catch (e) {
|
|
237
|
+
threw = true;
|
|
238
|
+
}
|
|
239
|
+
check('V14 pasting past the end does not throw', !threw);
|
|
240
|
+
check('V14 score still has 12 measures', score.staves[0].measures.length === 12);
|
|
241
|
+
check('V14 measure 10 holds the first copied measure', same(voiceNotes(score, 10, 0), voiceNotes(score, 0, 0)));
|
|
242
|
+
check('V14 measure 11 holds the second copied measure', same(voiceNotes(score, 11, 0), voiceNotes(score, 1, 0)));
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// --- V15: a voice missing on part of the copy is copied as rests ---
|
|
246
|
+
{
|
|
247
|
+
const score = buildScore();
|
|
248
|
+
const buffer = new PasteBuffer();
|
|
249
|
+
// voice 1 exists on measures 2, 3 and 6, not 4 or 5
|
|
250
|
+
buffer.setVoiceSelections(score, selectNotes(score, 2, 0, 0, 0).concat(selectNotes(score, 4, 0, 0, 0)), 1);
|
|
251
|
+
check('V15 voice 1 copied over three measures', buffer.voiceCopy!.measureCount === 3);
|
|
252
|
+
buffer.pasteVoice(dest(8), 1);
|
|
253
|
+
check('V15 measure 8 voice 1 equals measure 2 voice 1', same(voiceNotes(score, 8, 1), voiceNotes(score, 2, 1)));
|
|
254
|
+
check('V15 measure 9 voice 1 equals measure 3 voice 1', same(voiceNotes(score, 9, 1), voiceNotes(score, 3, 1)));
|
|
255
|
+
const rests = voiceNotes(score, 10, 1);
|
|
256
|
+
check('V15 measure 10 voice 1 is rests (the source had no voice 1 in measure 4)', rests !== null && rests.every((n) => n.startsWith('r:')),
|
|
257
|
+
JSON.stringify(rests));
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// --- V16: tuplets are kept, and registered for the destination voice ---
|
|
261
|
+
{
|
|
262
|
+
const score = buildScore();
|
|
263
|
+
const buffer = new PasteBuffer();
|
|
264
|
+
check('V16 the source has a tuplet in voice 0 of measure 5', tupletVoices(score, 5).join() === '0');
|
|
265
|
+
buffer.setVoiceSelections(score, selectNotes(score, 5, 0, 0), 0);
|
|
266
|
+
buffer.pasteVoice(dest(8), 0);
|
|
267
|
+
check('V16 pasted measure has the same notes, including the tuplet', same(voiceNotes(score, 8, 0), voiceNotes(score, 5, 0)));
|
|
268
|
+
check('V16 the tuplet is registered for voice 0', tupletVoices(score, 8).join() === '0', tupletVoices(score, 8).join());
|
|
269
|
+
buffer.pasteVoice(dest(9), 1);
|
|
270
|
+
check('V16 pasted into voice 1, the tuplet belongs to voice 1', tupletVoices(score, 9).join() === '1', tupletVoices(score, 9).join());
|
|
271
|
+
check('V16 the tuplet notes are tuplets in the new voice', score.staves[0].measures[9].voices[1].notes[0].isTuplet === true);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// --- V17: another voice's tuplet survives a multi-measure paste ---
|
|
275
|
+
{
|
|
276
|
+
const score = buildScore();
|
|
277
|
+
const buffer = new PasteBuffer();
|
|
278
|
+
// copy voice 0 of measures 0-2, paste over measures 5-7; voice 1 of measure 6 has a triplet
|
|
279
|
+
buffer.setVoiceSelections(score, selectNotes(score, 0, 0, 0).concat(selectNotes(score, 2, 0, 0)), 0);
|
|
280
|
+
check('V17 voice 1 of measure 6 has a tuplet before', tupletVoices(score, 6).indexOf(1) >= 0);
|
|
281
|
+
buffer.pasteVoice(dest(5), 0);
|
|
282
|
+
check('V17 voice 1 tuplet of the middle measure survives', tupletVoices(score, 6).indexOf(1) >= 0, tupletVoices(score, 6).join());
|
|
283
|
+
check('V17 voice 1 notes of the middle measure are still a tuplet', score.staves[0].measures[6].voices[1].notes[0].isTuplet === true);
|
|
284
|
+
check('V17 voice 0 of measure 5 was replaced (its tuplet is gone)', tupletVoices(score, 5).indexOf(0) < 0, tupletVoices(score, 5).join());
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// --- V18: no stale tuplet trees in the replaced voice ---
|
|
288
|
+
{
|
|
289
|
+
const score = buildScore();
|
|
290
|
+
const buffer = new PasteBuffer();
|
|
291
|
+
// copy 3 measures of plain voice 0 (measures 0-2), paste over measures 3-5; measure 5 voice 0 has a triplet
|
|
292
|
+
buffer.setVoiceSelections(score, selectNotes(score, 0, 0, 0).concat(selectNotes(score, 2, 0, 0)), 0);
|
|
293
|
+
buffer.pasteVoice(dest(3), 0);
|
|
294
|
+
check('V18 the triplet in the last pasted measure is gone', tupletVoices(score, 5).indexOf(0) < 0, tupletVoices(score, 5).join());
|
|
295
|
+
check('V18 the pasted notes are plain', score.staves[0].measures[5].voices[0].notes.every((n) => !n.isTuplet));
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// --- V19: slurs are carried when the voice number is kept ---
|
|
299
|
+
{
|
|
300
|
+
const slurFor = (score: SmoScore) => {
|
|
301
|
+
const a = SmoSelection.noteSelection(score, 0, 0, 0, 0)!;
|
|
302
|
+
const b = SmoSelection.noteSelection(score, 0, 0, 0, 2)!;
|
|
303
|
+
const slur = SmoOperation.createSlur(score, a, b);
|
|
304
|
+
a.staff.addStaffModifier(slur);
|
|
305
|
+
return slur;
|
|
306
|
+
};
|
|
307
|
+
const slursAt = (score: SmoScore, m: number) =>
|
|
308
|
+
score.staves[0].getModifiers().filter((mod: any) => mod.ctor === 'SmoSlur' && mod.startSelector.measure === m);
|
|
309
|
+
// same voice number: carried
|
|
310
|
+
{
|
|
311
|
+
const score = buildScore();
|
|
312
|
+
slurFor(score);
|
|
313
|
+
const buffer = new PasteBuffer();
|
|
314
|
+
buffer.setVoiceSelections(score, selectNotes(score, 0, 0, 0), 0);
|
|
315
|
+
buffer.pasteVoice(dest(7), 0);
|
|
316
|
+
check('V19 a slur is carried when pasted into the same voice number', slursAt(score, 7).length === 1, `n=${slursAt(score, 7).length}`);
|
|
317
|
+
}
|
|
318
|
+
// different voice number: not carried
|
|
319
|
+
{
|
|
320
|
+
const score = buildScore();
|
|
321
|
+
slurFor(score);
|
|
322
|
+
const buffer = new PasteBuffer();
|
|
323
|
+
buffer.setVoiceSelections(score, selectNotes(score, 0, 0, 0), 0);
|
|
324
|
+
buffer.pasteVoice(dest(8), 1);
|
|
325
|
+
check('V19 a slur is not carried into a different voice number', slursAt(score, 8).length === 0, `n=${slursAt(score, 8).length}`);
|
|
326
|
+
check('V19 the notes are still pasted', same(voiceNotes(score, 8, 1), voiceNotes(score, 0, 0)));
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
// --- V20: the existing copy and paste are unchanged ---
|
|
331
|
+
{
|
|
332
|
+
const score = buildScore();
|
|
333
|
+
const buffer = new PasteBuffer();
|
|
334
|
+
buffer.setVoiceSelections(score, selectNotes(score, 0, 0, 0), 0);
|
|
335
|
+
check('V20 a voice copy exists before a normal copy', buffer.hasVoiceCopy());
|
|
336
|
+
buffer.setSelections(score, selectNotes(score, 1, 0, 3, 0));
|
|
337
|
+
check('V20 a normal copy clears the voice copy', !buffer.hasVoiceCopy());
|
|
338
|
+
buffer.pasteSelections({ staff: 0, measure: 8, voice: 0, tick: 0, pitches: [] });
|
|
339
|
+
check('V20 plain paste of one voice into measure 8', same(voiceNotes(score, 8, 0), voiceNotes(score, 1, 0)));
|
|
340
|
+
check('V20 plain paste leaves measure 8 with one voice', voiceCount(score, 8) === 1);
|
|
341
|
+
// a partial-measure copy and paste still works note by note
|
|
342
|
+
const score2 = buildScore();
|
|
343
|
+
const buffer2 = new PasteBuffer();
|
|
344
|
+
buffer2.setSelections(score2, selectNotes(score2, 0, 1, 2, 0));
|
|
345
|
+
buffer2.pasteSelections({ staff: 0, measure: 8, voice: 0, tick: 0, pitches: [] });
|
|
346
|
+
const src = voiceNotes(score2, 0, 0)!;
|
|
347
|
+
const got = voiceNotes(score2, 8, 0)!;
|
|
348
|
+
check('V20 partial plain paste puts the 2 notes first', got[0] === src[1] && got[1] === src[2], JSON.stringify(got));
|
|
349
|
+
check('V20 partial plain paste keeps the rest of the measure', got.length === 4 && got[2] === voiceNotes(buildScore(), 8, 0)![2]);
|
|
350
|
+
// an unrelated voice's tuplet in middle measures is kept by a plain multi-measure paste
|
|
351
|
+
const score3 = buildScore();
|
|
352
|
+
const buffer3 = new PasteBuffer();
|
|
353
|
+
buffer3.setSelections(score3, selectNotes(score3, 0, 0, 3, 0).concat(selectNotes(score3, 1, 0, 3, 0), selectNotes(score3, 2, 0, 3, 0)));
|
|
354
|
+
buffer3.pasteSelections({ staff: 0, measure: 5, voice: 0, tick: 0, pitches: [] });
|
|
355
|
+
check('V20 plain multi-measure paste works', same(voiceNotes(score3, 6, 0), voiceNotes(score3, 1, 0)));
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
// --- P1: a note split across a measure boundary is transposed once, not once per measure ---
|
|
359
|
+
// (existing paste bug: the remainder in the next measure was transposed a second time)
|
|
360
|
+
{
|
|
361
|
+
const score = buildScore();
|
|
362
|
+
// measure 1 becomes a single whole note
|
|
363
|
+
const src = score.staves[0].measures[1];
|
|
364
|
+
src.voices = [{ notes: [src.voices[0].notes[0]] }];
|
|
365
|
+
src.voices[0].notes[0].ticks = { numerator: 16384, denominator: 1, remainder: 0 };
|
|
366
|
+
// measures 8 and 9 belong to a transposing instrument (written 2 semitones above concert)
|
|
367
|
+
[8, 9].forEach((m) => {
|
|
368
|
+
const measure = score.staves[0].measures[m];
|
|
369
|
+
measure.transposeIndex = 2;
|
|
370
|
+
measure.keySignature = 'd';
|
|
371
|
+
});
|
|
372
|
+
const buffer = new PasteBuffer();
|
|
373
|
+
buffer.setSelections(score, selectNotes(score, 1, 0, 0));
|
|
374
|
+
// start on the third beat, so the whole note has to be split
|
|
375
|
+
buffer.pasteSelections({ staff: 0, measure: 8, voice: 0, tick: 2, pitches: [] });
|
|
376
|
+
const m8 = voiceNotes(score, 8, 0)!;
|
|
377
|
+
const m9 = voiceNotes(score, 9, 0)!;
|
|
378
|
+
check('P1 the first part is in measure 8, on the third beat', m8.length === 3, JSON.stringify(m8));
|
|
379
|
+
const first = m8[2].split(':')[0];
|
|
380
|
+
const rest = m9[0].split(':')[0];
|
|
381
|
+
check('P1 the remainder in measure 9 has the same pitch as the first part', first === rest, `first=${first} remainder=${rest}`);
|
|
382
|
+
// the split note is pasted once: its remainder fills the first half of measure 9 and the
|
|
383
|
+
// existing music follows, not a second copy of the note
|
|
384
|
+
const original9 = voiceNotes(buildScore(), 9, 0)!;
|
|
385
|
+
check('P2 the remainder is a half note', m9[0].endsWith(':8192'), JSON.stringify(m9));
|
|
386
|
+
check('P2 the split note is not pasted a second time', m9.length === 3 && m9[1] === original9[2] && m9[2] === original9[3],
|
|
387
|
+
`measure 9 = ${JSON.stringify(m9)}, existing = ${JSON.stringify(original9)}`);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// --- P3: after a split note, the notes copied after it follow, each pasted once ---
|
|
391
|
+
{
|
|
392
|
+
const score = buildScore();
|
|
393
|
+
// measure 1 becomes two half notes
|
|
394
|
+
const src = score.staves[0].measures[1];
|
|
395
|
+
src.voices = [{ notes: [src.voices[0].notes[0], src.voices[0].notes[1]] }];
|
|
396
|
+
src.voices[0].notes.forEach((n) => { n.ticks = { numerator: 8192, denominator: 1, remainder: 0 }; });
|
|
397
|
+
const copied = voiceNotes(score, 1, 0)!;
|
|
398
|
+
const original9 = voiceNotes(buildScore(), 9, 0)!;
|
|
399
|
+
const buffer = new PasteBuffer();
|
|
400
|
+
buffer.setSelections(score, selectNotes(score, 1, 0, 1));
|
|
401
|
+
// start on the fourth beat: the first half note is split, one beat in measure 8 and one in measure 9
|
|
402
|
+
buffer.pasteSelections({ staff: 0, measure: 8, voice: 0, tick: 3, pitches: [] });
|
|
403
|
+
const m8 = voiceNotes(score, 8, 0)!;
|
|
404
|
+
const m9 = voiceNotes(score, 9, 0)!;
|
|
405
|
+
const pitchA = copied[0].split(':')[0];
|
|
406
|
+
const pitchB = copied[1].split(':')[0];
|
|
407
|
+
check('P3 measure 8 ends with one beat of the first note', m8[m8.length - 1] === `${pitchA}:4096`, JSON.stringify(m8));
|
|
408
|
+
check('P3 measure 9 is: rest of the first note, the second note, then the existing last beat',
|
|
409
|
+
JSON.stringify(m9) === JSON.stringify([`${pitchA}:4096`, `${pitchB}:8192`, original9[3]]), JSON.stringify(m9));
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
if (failures > 0) {
|
|
413
|
+
console.log(`${failures} check(s) failed`);
|
|
414
|
+
process.exitCode = 1;
|
|
415
|
+
} else {
|
|
416
|
+
console.log('all checks passed');
|
|
417
|
+
}
|
|
@@ -810,6 +810,29 @@
|
|
|
810
810
|
}
|
|
811
811
|
}
|
|
812
812
|
},
|
|
813
|
+
"SmoBeamPreferences": {
|
|
814
|
+
"description": "beam grouping for one measure, for compound or irregular meters. A measure with none beams by the score default",
|
|
815
|
+
"type": "object",
|
|
816
|
+
"required": [
|
|
817
|
+
"ctor",
|
|
818
|
+
"groups"
|
|
819
|
+
],
|
|
820
|
+
"properties": {
|
|
821
|
+
"ctor": {
|
|
822
|
+
"const": "SmoBeamPreferences"
|
|
823
|
+
},
|
|
824
|
+
"groups": {
|
|
825
|
+
"description": "the longest beam group, in eighth notes (sixteenth notes in x/16 time), for each beam group in turn. The list starts over if the measure has more groups",
|
|
826
|
+
"type": "array",
|
|
827
|
+
"minItems": 1,
|
|
828
|
+
"items": {
|
|
829
|
+
"type": "integer",
|
|
830
|
+
"minimum": 1,
|
|
831
|
+
"maximum": 4
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
},
|
|
813
836
|
"SmoTempoModeEnum": {
|
|
814
837
|
"enum": [
|
|
815
838
|
"duration",
|
|
@@ -1030,6 +1053,8 @@
|
|
|
1030
1053
|
"$ref": "#/definitions/measureModifierSchema/SmoBarline"
|
|
1031
1054
|
}, {
|
|
1032
1055
|
"$ref": "#/definitions/measureModifierSchema/SmoMeasureText"
|
|
1056
|
+
}, {
|
|
1057
|
+
"$ref": "#/definitions/measureModifierSchema/SmoBeamPreferences"
|
|
1033
1058
|
}
|
|
1034
1059
|
]
|
|
1035
1060
|
}
|
|
@@ -1669,6 +1694,18 @@
|
|
|
1669
1694
|
"defaultTripleDuration": {
|
|
1670
1695
|
"type": "integer",
|
|
1671
1696
|
"default": 6144
|
|
1697
|
+
},
|
|
1698
|
+
"autosaveInterval": {
|
|
1699
|
+
"type": "integer",
|
|
1700
|
+
"default": 10,
|
|
1701
|
+
"minimum": 5,
|
|
1702
|
+
"maximum": 60
|
|
1703
|
+
},
|
|
1704
|
+
"autosaveCount": {
|
|
1705
|
+
"type": "integer",
|
|
1706
|
+
"default": 10,
|
|
1707
|
+
"minimum": 1,
|
|
1708
|
+
"maximum": 20
|
|
1672
1709
|
}
|
|
1673
1710
|
}
|
|
1674
1711
|
},
|
package/typedoc.ts
CHANGED
|
@@ -84,8 +84,8 @@ export * from './src/ui/dialogs/components/tie';
|
|
|
84
84
|
export * from './src/ui/dialogs/components/toggle';
|
|
85
85
|
export * from './src/ui/dialogs/components/tree';
|
|
86
86
|
export * from './src/ui/dialogs/dialog';
|
|
87
|
+
export * from './src/ui/dialogs/deleteSpecial';
|
|
87
88
|
export * from './src/ui/dialogs/durations';
|
|
88
|
-
export * from './src/ui/dialogs/dynamics';
|
|
89
89
|
export * from './src/ui/dialogs/endings';
|
|
90
90
|
export * from './src/ui/dialogs/factory';
|
|
91
91
|
export * from './src/ui/dialogs/fileDialogs';
|