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.
Files changed (352) hide show
  1. package/build/smoosic.js +546 -125
  2. package/changes.md +85 -0
  3. package/package.json +23 -2
  4. package/release/smoosic.js +549 -128
  5. package/release/styles/menus.css +26 -0
  6. package/specs/022-text-reposition-on-resize/spec.md +1 -0
  7. package/specs/027-fix-bottom-modifier-lookup/checklists/requirements.md +38 -0
  8. package/specs/027-fix-bottom-modifier-lookup/contracts/division-lookup-contract.md +51 -0
  9. package/specs/027-fix-bottom-modifier-lookup/data-model.md +43 -0
  10. package/specs/027-fix-bottom-modifier-lookup/plan.md +77 -0
  11. package/specs/027-fix-bottom-modifier-lookup/quickstart.md +36 -0
  12. package/specs/027-fix-bottom-modifier-lookup/research.md +58 -0
  13. package/specs/027-fix-bottom-modifier-lookup/spec.md +105 -0
  14. package/specs/027-fix-bottom-modifier-lookup/tasks.md +167 -0
  15. package/specs/028-unsaved-changes-indicator/checklists/requirements.md +39 -0
  16. package/specs/028-unsaved-changes-indicator/contracts/score-change-contract.md +44 -0
  17. package/specs/028-unsaved-changes-indicator/data-model.md +64 -0
  18. package/specs/028-unsaved-changes-indicator/plan.md +96 -0
  19. package/specs/028-unsaved-changes-indicator/quickstart.md +54 -0
  20. package/specs/028-unsaved-changes-indicator/research.md +68 -0
  21. package/specs/028-unsaved-changes-indicator/spec.md +135 -0
  22. package/specs/028-unsaved-changes-indicator/tasks.md +173 -0
  23. package/specs/029-remove-promise-helpers/checklists/requirements.md +39 -0
  24. package/specs/029-remove-promise-helpers/contracts/public-api-contract.md +32 -0
  25. package/specs/029-remove-promise-helpers/data-model.md +45 -0
  26. package/specs/029-remove-promise-helpers/plan.md +86 -0
  27. package/specs/029-remove-promise-helpers/quickstart.md +53 -0
  28. package/specs/029-remove-promise-helpers/research.md +71 -0
  29. package/specs/029-remove-promise-helpers/spec.md +107 -0
  30. package/specs/029-remove-promise-helpers/tasks.md +164 -0
  31. package/specs/030-copy-paste-voices/checklists/requirements.md +39 -0
  32. package/specs/030-copy-paste-voices/contracts/voice-copy-paste-contract.md +47 -0
  33. package/specs/030-copy-paste-voices/data-model.md +63 -0
  34. package/specs/030-copy-paste-voices/plan.md +80 -0
  35. package/specs/030-copy-paste-voices/quickstart.md +50 -0
  36. package/specs/030-copy-paste-voices/research.md +80 -0
  37. package/specs/030-copy-paste-voices/spec.md +124 -0
  38. package/specs/030-copy-paste-voices/tasks.md +183 -0
  39. package/specs/031-select-voice/checklists/requirements.md +39 -0
  40. package/specs/031-select-voice/contracts/select-voice-contract.md +43 -0
  41. package/specs/031-select-voice/data-model.md +47 -0
  42. package/specs/031-select-voice/plan.md +79 -0
  43. package/specs/031-select-voice/quickstart.md +43 -0
  44. package/specs/031-select-voice/research.md +55 -0
  45. package/specs/031-select-voice/spec.md +113 -0
  46. package/specs/031-select-voice/tasks.md +171 -0
  47. package/specs/032-split-multimeasure-rests/checklists/requirements.md +40 -0
  48. package/specs/032-split-multimeasure-rests/contracts/grouping-contract.md +53 -0
  49. package/specs/032-split-multimeasure-rests/data-model.md +70 -0
  50. package/specs/032-split-multimeasure-rests/plan.md +81 -0
  51. package/specs/032-split-multimeasure-rests/quickstart.md +46 -0
  52. package/specs/032-split-multimeasure-rests/research.md +63 -0
  53. package/specs/032-split-multimeasure-rests/spec.md +127 -0
  54. package/specs/032-split-multimeasure-rests/tasks.md +174 -0
  55. package/specs/033-key-distance-transposition/checklists/requirements.md +35 -0
  56. package/specs/033-key-distance-transposition/contracts/spelling-api.md +36 -0
  57. package/specs/033-key-distance-transposition/data-model.md +49 -0
  58. package/specs/033-key-distance-transposition/plan.md +87 -0
  59. package/specs/033-key-distance-transposition/quickstart.md +40 -0
  60. package/specs/033-key-distance-transposition/research.md +82 -0
  61. package/specs/033-key-distance-transposition/spec.md +132 -0
  62. package/specs/033-key-distance-transposition/tasks.md +139 -0
  63. package/specs/034-smz-compressed-scores/checklists/requirements.md +35 -0
  64. package/specs/034-smz-compressed-scores/contracts/archive-api.md +30 -0
  65. package/specs/034-smz-compressed-scores/data-model.md +48 -0
  66. package/specs/034-smz-compressed-scores/plan.md +89 -0
  67. package/specs/034-smz-compressed-scores/quickstart.md +44 -0
  68. package/specs/034-smz-compressed-scores/research.md +86 -0
  69. package/specs/034-smz-compressed-scores/spec.md +137 -0
  70. package/specs/034-smz-compressed-scores/tasks.md +148 -0
  71. package/specs/035-paste-special/checklists/requirements.md +35 -0
  72. package/specs/035-paste-special/contracts/paste-special-api.md +50 -0
  73. package/specs/035-paste-special/data-model.md +47 -0
  74. package/specs/035-paste-special/plan.md +83 -0
  75. package/specs/035-paste-special/quickstart.md +51 -0
  76. package/specs/035-paste-special/research.md +97 -0
  77. package/specs/035-paste-special/spec.md +170 -0
  78. package/specs/035-paste-special/tasks.md +149 -0
  79. package/specs/036-autosave-recovery/checklists/requirements.md +36 -0
  80. package/specs/036-autosave-recovery/contracts/autosave-api.md +111 -0
  81. package/specs/036-autosave-recovery/data-model.md +70 -0
  82. package/specs/036-autosave-recovery/plan.md +87 -0
  83. package/specs/036-autosave-recovery/quickstart.md +65 -0
  84. package/specs/036-autosave-recovery/research.md +105 -0
  85. package/specs/036-autosave-recovery/spec.md +143 -0
  86. package/specs/036-autosave-recovery/tasks.md +165 -0
  87. package/specs/037-fix-new-part-dialog/checklists/requirements.md +38 -0
  88. package/specs/037-fix-new-part-dialog/contracts/create-part-api.md +84 -0
  89. package/specs/037-fix-new-part-dialog/data-model.md +68 -0
  90. package/specs/037-fix-new-part-dialog/plan.md +83 -0
  91. package/specs/037-fix-new-part-dialog/quickstart.md +58 -0
  92. package/specs/037-fix-new-part-dialog/research.md +86 -0
  93. package/specs/037-fix-new-part-dialog/spec.md +144 -0
  94. package/specs/037-fix-new-part-dialog/tasks.md +174 -0
  95. package/specs/038-per-measure-beam-groups/checklists/requirements.md +36 -0
  96. package/specs/038-per-measure-beam-groups/contracts/beam-groups-api.md +74 -0
  97. package/specs/038-per-measure-beam-groups/data-model.md +75 -0
  98. package/specs/038-per-measure-beam-groups/plan.md +84 -0
  99. package/specs/038-per-measure-beam-groups/quickstart.md +53 -0
  100. package/specs/038-per-measure-beam-groups/research.md +72 -0
  101. package/specs/038-per-measure-beam-groups/spec.md +146 -0
  102. package/specs/038-per-measure-beam-groups/tasks.md +132 -0
  103. package/specs/039-measure-fill-submenu/checklists/requirements.md +35 -0
  104. package/specs/039-measure-fill-submenu/contracts/measure-fill-api.md +56 -0
  105. package/specs/039-measure-fill-submenu/data-model.md +79 -0
  106. package/specs/039-measure-fill-submenu/plan.md +81 -0
  107. package/specs/039-measure-fill-submenu/quickstart.md +62 -0
  108. package/specs/039-measure-fill-submenu/research.md +68 -0
  109. package/specs/039-measure-fill-submenu/spec.md +153 -0
  110. package/specs/039-measure-fill-submenu/tasks.md +121 -0
  111. package/specs/040-dynamics-dialog-cleanup/checklists/requirements.md +36 -0
  112. package/specs/040-dynamics-dialog-cleanup/contracts/dynamics-dialog.md +52 -0
  113. package/specs/040-dynamics-dialog-cleanup/data-model.md +48 -0
  114. package/specs/040-dynamics-dialog-cleanup/plan.md +89 -0
  115. package/specs/040-dynamics-dialog-cleanup/quickstart.md +69 -0
  116. package/specs/040-dynamics-dialog-cleanup/research.md +80 -0
  117. package/specs/040-dynamics-dialog-cleanup/spec.md +120 -0
  118. package/specs/040-dynamics-dialog-cleanup/tasks.md +114 -0
  119. package/specs/041-delete-special/checklists/requirements.md +35 -0
  120. package/specs/041-delete-special/contracts/delete-special-api.md +41 -0
  121. package/specs/041-delete-special/data-model.md +40 -0
  122. package/specs/041-delete-special/plan.md +93 -0
  123. package/specs/041-delete-special/quickstart.md +41 -0
  124. package/specs/041-delete-special/research.md +75 -0
  125. package/specs/041-delete-special/spec.md +136 -0
  126. package/specs/041-delete-special/tasks.md +106 -0
  127. package/src/application/application.ts +475 -459
  128. package/src/application/exports.ts +401 -395
  129. package/src/application/generateVexTests.ts +2 -2
  130. package/src/common/promiseHelpers.ts +2 -2
  131. package/src/render/audio/samples.ts +117 -118
  132. package/src/render/sui/NoteEntryCaret.ts +117 -16
  133. package/src/render/sui/autosave.ts +265 -0
  134. package/src/render/sui/formatter.ts +12 -2
  135. package/src/render/sui/pageDivisions.ts +58 -0
  136. package/src/render/sui/renderState.ts +469 -464
  137. package/src/render/sui/scoreChangeState.ts +67 -0
  138. package/src/render/sui/scoreView.ts +77 -2
  139. package/src/render/sui/scoreViewOperations.ts +363 -37
  140. package/src/render/sui/staffLineGeometry.ts +82 -0
  141. package/src/render/sui/svgPageMap.ts +16 -17
  142. package/src/render/sui/textEdit.ts +310 -311
  143. package/src/render/sui/tracker.ts +40 -0
  144. package/src/render/vex/vxMeasure.ts +22 -8
  145. package/src/render/vex/vxNote.ts +5 -5
  146. package/src/smo/data/measure.ts +58 -1
  147. package/src/smo/data/measureModifiers.ts +81 -1
  148. package/src/smo/data/music.ts +169 -359
  149. package/src/smo/data/note.ts +1 -1
  150. package/src/smo/data/noteModifiers.ts +12 -0
  151. package/src/smo/data/score.ts +167 -2
  152. package/src/smo/data/scoreModifiers.ts +46 -1
  153. package/src/smo/data/systemStaff.ts +43 -0
  154. package/src/smo/xform/beamers.ts +80 -6
  155. package/src/smo/xform/copypaste.ts +511 -51
  156. package/src/smo/xform/measureFill.ts +89 -0
  157. package/src/smo/xform/operations.ts +403 -61
  158. package/src/smo/xform/selections.ts +75 -0
  159. package/src/smo/xform/undo.ts +9 -0
  160. package/src/styles/menus.css +26 -0
  161. package/src/ui/buttons/ribbon.ts +3 -1
  162. package/src/ui/components/buttons/sidebar.vue +15 -6
  163. package/src/ui/components/dialogs/beamGroups.vue +106 -0
  164. package/src/ui/components/dialogs/deleteSpecial.vue +38 -0
  165. package/src/ui/components/dialogs/dynamics.vue +16 -3
  166. package/src/ui/components/dialogs/fileUpload.vue +2 -2
  167. package/src/ui/components/dialogs/hairpin.vue +3 -3
  168. package/src/ui/components/dialogs/library.vue +3 -1
  169. package/src/ui/components/dialogs/newPart.vue +148 -184
  170. package/src/ui/components/dialogs/pasteSpecial.vue +49 -0
  171. package/src/ui/components/dialogs/recovery.vue +66 -0
  172. package/src/ui/components/dialogs/save.vue +11 -4
  173. package/src/ui/components/dialogs/scorePreferences.vue +23 -1
  174. package/src/ui/components/dialogs/slur.vue +6 -6
  175. package/src/ui/components/dialogs/tempo.vue +11 -3
  176. package/src/ui/components/dialogs/timeSignature.vue +5 -0
  177. package/src/ui/components/dialogs/unsavedChanges.vue +44 -0
  178. package/src/ui/components/dialogs/volta.vue +3 -3
  179. package/src/ui/dialogs/adapter.ts +181 -183
  180. package/src/ui/dialogs/addMeasure.ts +97 -97
  181. package/src/ui/dialogs/annotationVue.ts +56 -56
  182. package/src/ui/dialogs/audioSettings.ts +121 -123
  183. package/src/ui/dialogs/beamGroupsVue.ts +69 -0
  184. package/src/ui/dialogs/chordChangeVue.ts +46 -46
  185. package/src/ui/dialogs/clefChange.ts +53 -53
  186. package/src/ui/dialogs/createPartHelpers.ts +68 -0
  187. package/src/ui/dialogs/customTuplets.ts +95 -96
  188. package/src/ui/dialogs/customTupletsVue.ts +47 -47
  189. package/src/ui/dialogs/deleteSpecial.ts +57 -0
  190. package/src/ui/dialogs/dialog.ts +627 -620
  191. package/src/ui/dialogs/durations.ts +34 -34
  192. package/src/ui/dialogs/dynamicsVue.ts +87 -60
  193. package/src/ui/dialogs/factory.ts +196 -198
  194. package/src/ui/dialogs/fileDialogs.ts +286 -179
  195. package/src/ui/dialogs/fonts.ts +93 -93
  196. package/src/ui/dialogs/globalLayout.ts +40 -40
  197. package/src/ui/dialogs/gracenote.ts +31 -31
  198. package/src/ui/dialogs/hairpin.ts +108 -110
  199. package/src/ui/dialogs/hairpinVue.ts +51 -51
  200. package/src/ui/dialogs/instrument.ts +119 -112
  201. package/src/ui/dialogs/keySignature.ts +175 -176
  202. package/src/ui/dialogs/keySignatureVue.ts +47 -47
  203. package/src/ui/dialogs/library.ts +207 -207
  204. package/src/ui/dialogs/libraryVue.ts +62 -48
  205. package/src/ui/dialogs/lyricVue.ts +46 -46
  206. package/src/ui/dialogs/measureFormat.ts +78 -78
  207. package/src/ui/dialogs/microtones.ts +147 -147
  208. package/src/ui/dialogs/noteHead.ts +319 -319
  209. package/src/ui/dialogs/pageLayout.ts +61 -61
  210. package/src/ui/dialogs/partInfo.ts +60 -60
  211. package/src/ui/dialogs/pasteSpecial.ts +59 -0
  212. package/src/ui/dialogs/pedalMarking.ts +117 -117
  213. package/src/ui/dialogs/pedalMarkingVue.ts +73 -73
  214. package/src/ui/dialogs/pitch.ts +352 -352
  215. package/src/ui/dialogs/preferences.ts +1 -0
  216. package/src/ui/dialogs/recovery.ts +49 -0
  217. package/src/ui/dialogs/rehearsalMark.ts +64 -64
  218. package/src/ui/dialogs/rehearsalMarkVue.ts +57 -57
  219. package/src/ui/dialogs/scoreId.ts +35 -36
  220. package/src/ui/dialogs/scoreView.ts +42 -42
  221. package/src/ui/dialogs/slur.ts +308 -310
  222. package/src/ui/dialogs/slurVue.ts +91 -91
  223. package/src/ui/dialogs/staffGroup.ts +112 -112
  224. package/src/ui/dialogs/tabNote.ts +84 -84
  225. package/src/ui/dialogs/tabStave.ts +182 -182
  226. package/src/ui/dialogs/tempo.ts +261 -263
  227. package/src/ui/dialogs/tempoVue.ts +73 -73
  228. package/src/ui/dialogs/textBlockVue.ts +127 -127
  229. package/src/ui/dialogs/textBracket.ts +114 -116
  230. package/src/ui/dialogs/textBracketVue.ts +56 -56
  231. package/src/ui/dialogs/tie.ts +140 -142
  232. package/src/ui/dialogs/timeSignature.ts +65 -66
  233. package/src/ui/dialogs/transposeScore.ts +39 -39
  234. package/src/ui/dialogs/unsavedChanges.ts +43 -0
  235. package/src/ui/dialogs/volta.ts +120 -122
  236. package/src/ui/dialogs/voltaVue.ts +51 -51
  237. package/src/ui/fileio/fileInput.ts +12 -3
  238. package/src/ui/fileio/library.ts +110 -111
  239. package/src/ui/fileio/scoreArchive.ts +151 -0
  240. package/src/ui/fileio/xhrLoader.ts +26 -0
  241. package/src/ui/i18n/language.ts +1 -1
  242. package/src/ui/menus/beams.ts +181 -112
  243. package/src/ui/menus/edit.ts +143 -6
  244. package/src/ui/menus/file.ts +40 -4
  245. package/src/ui/menus/measure.ts +40 -1
  246. package/tests/autosave.ts +332 -0
  247. package/tests/beamDotted.ts +56 -0
  248. package/tests/beamGroups.ts +338 -0
  249. package/tests/createPart.ts +292 -0
  250. package/tests/deleteSpecial.ts +350 -0
  251. package/tests/dynamicsFontSize.ts +132 -0
  252. package/tests/keyDistanceTransposition.ts +351 -0
  253. package/tests/measureFill.ts +295 -0
  254. package/tests/movePart.ts +94 -0
  255. package/tests/multimeasureRest.ts +338 -0
  256. package/tests/pageDivisions.ts +156 -0
  257. package/tests/pasteIntoMeasure.ts +103 -0
  258. package/tests/pasteSpecial.ts +541 -0
  259. package/tests/promiseHelpersUsage.ts +142 -0
  260. package/tests/quickBeam.ts +126 -0
  261. package/tests/scoreArchive.ts +218 -0
  262. package/tests/scoreChangeState.ts +104 -0
  263. package/tests/selectVoice.ts +189 -0
  264. package/tests/staffLineGeometry.ts +179 -0
  265. package/tests/timeSignatureDisplay.ts +58 -0
  266. package/tests/voiceCopyPaste.ts +417 -0
  267. package/tools/smoosic-schema.json +37 -0
  268. package/typedoc.ts +1 -1
  269. package/types/src/application/exports.d.ts +453 -447
  270. package/types/src/common/promiseHelpers.d.ts +30 -30
  271. package/types/src/common/vex.d.ts +224 -224
  272. package/types/src/render/sui/NoteEntryCaret.d.ts +107 -107
  273. package/types/src/render/sui/autosave.d.ts +99 -0
  274. package/types/src/render/sui/scoreView.d.ts +23 -0
  275. package/types/src/render/sui/scoreViewOperations.d.ts +759 -639
  276. package/types/src/render/sui/svgHelpers.d.ts +88 -88
  277. package/types/src/render/sui/svgPageMap.d.ts +344 -344
  278. package/types/src/render/sui/textEdit.d.ts +96 -96
  279. package/types/src/render/sui/textRender.d.ts +199 -199
  280. package/types/src/render/vex/smoAdapter.d.ts +47 -47
  281. package/types/src/render/vex/vxMeasure.d.ts +97 -97
  282. package/types/src/render/vex/vxNote.d.ts +56 -56
  283. package/types/src/render/vex/vxSystem.d.ts +71 -71
  284. package/types/src/smo/data/measure.d.ts +30 -0
  285. package/types/src/smo/data/measureModifiers.d.ts +568 -513
  286. package/types/src/smo/data/music.d.ts +74 -32
  287. package/types/src/smo/data/note.d.ts +498 -498
  288. package/types/src/smo/data/noteModifiers.d.ts +615 -606
  289. package/types/src/smo/data/score.d.ts +476 -421
  290. package/types/src/smo/data/scoreModifiers.d.ts +30 -0
  291. package/types/src/smo/data/scoreText.d.ts +334 -334
  292. package/types/src/smo/data/systemStaff.d.ts +14 -0
  293. package/types/src/smo/xform/beamers.d.ts +23 -1
  294. package/types/src/smo/xform/copypaste.d.ts +138 -2
  295. package/types/src/smo/xform/measureFill.d.ts +21 -0
  296. package/types/src/smo/xform/operations.d.ts +245 -129
  297. package/types/src/smo/xform/selections.d.ts +154 -154
  298. package/types/src/smo/xform/undo.d.ts +142 -142
  299. package/types/src/ui/buttons/button.d.ts +100 -100
  300. package/types/src/ui/buttons/ribbon.d.ts +70 -70
  301. package/types/src/ui/common.d.ts +76 -76
  302. package/types/src/ui/components/dialogs/chordText.d.ts +28 -28
  303. package/types/src/ui/components/dialogs/textBlockAtomNode.d.ts +20 -20
  304. package/types/src/ui/components/dialogs/textGroupHtml.d.ts +29 -29
  305. package/types/src/ui/composable/draggable.d.ts +15 -15
  306. package/types/src/ui/dialogs/adapter.d.ts +120 -120
  307. package/types/src/ui/dialogs/annotationVue.d.ts +9 -9
  308. package/types/src/ui/dialogs/audioSettings.d.ts +32 -32
  309. package/types/src/ui/dialogs/beamGroupsVue.d.ts +20 -0
  310. package/types/src/ui/dialogs/chordChangeVue.d.ts +8 -8
  311. package/types/src/ui/dialogs/createPartHelpers.d.ts +29 -0
  312. package/types/src/ui/dialogs/customTupletsVue.d.ts +9 -9
  313. package/types/src/ui/dialogs/deleteSpecial.d.ts +8 -0
  314. package/types/src/ui/dialogs/dialog.d.ts +203 -203
  315. package/types/src/ui/dialogs/dynamicsVue.d.ts +10 -10
  316. package/types/src/ui/dialogs/factory.d.ts +15 -15
  317. package/types/src/ui/dialogs/fileDialogs.d.ts +4 -4
  318. package/types/src/ui/dialogs/hairpin.d.ts +35 -35
  319. package/types/src/ui/dialogs/hairpinVue.d.ts +7 -7
  320. package/types/src/ui/dialogs/instrument.d.ts +3 -3
  321. package/types/src/ui/dialogs/keySignatureVue.d.ts +7 -7
  322. package/types/src/ui/dialogs/libraryVue.d.ts +15 -15
  323. package/types/src/ui/dialogs/lyricVue.d.ts +8 -8
  324. package/types/src/ui/dialogs/pasteSpecial.d.ts +8 -0
  325. package/types/src/ui/dialogs/pedalMarkingVue.d.ts +7 -7
  326. package/types/src/ui/dialogs/recovery.d.ts +8 -0
  327. package/types/src/ui/dialogs/rehearsalMark.d.ts +25 -25
  328. package/types/src/ui/dialogs/rehearsalMarkVue.d.ts +7 -7
  329. package/types/src/ui/dialogs/slur.d.ts +57 -57
  330. package/types/src/ui/dialogs/slurVue.d.ts +7 -7
  331. package/types/src/ui/dialogs/tempo.d.ts +50 -50
  332. package/types/src/ui/dialogs/tempoVue.d.ts +10 -10
  333. package/types/src/ui/dialogs/textBlockVue.d.ts +8 -8
  334. package/types/src/ui/dialogs/textBracket.d.ts +35 -35
  335. package/types/src/ui/dialogs/textBracketVue.d.ts +7 -7
  336. package/types/src/ui/dialogs/tie.d.ts +41 -41
  337. package/types/src/ui/dialogs/volta.d.ts +40 -40
  338. package/types/src/ui/dialogs/voltaVue.d.ts +7 -7
  339. package/types/src/ui/fileio/fileInput.d.ts +7 -1
  340. package/types/src/ui/fileio/library.d.ts +40 -40
  341. package/types/src/ui/fileio/scoreArchive.d.ts +55 -0
  342. package/types/src/ui/fileio/xhrLoader.d.ts +7 -0
  343. package/types/src/ui/menus/file.d.ts +8 -8
  344. package/types/src/ui/menus/language.d.ts +7 -7
  345. package/types/src/ui/menus/manager.d.ts +58 -58
  346. package/types/src/ui/menus/menu.d.ts +159 -159
  347. package/types/src/ui/menus/partSelection.d.ts +14 -14
  348. package/types/src/ui/menus/score.d.ts +8 -8
  349. package/types/src/ui/menus/staffModifier.d.ts +17 -17
  350. package/types/typedoc.d.ts +147 -147
  351. package/src/ui/dialogs/dynamics.ts +0 -143
  352. package/types/src/ui/dialogs/dynamics.d.ts +0 -37
@@ -0,0 +1,124 @@
1
+ # Feature Specification: Copy and Paste Voices
2
+
3
+ **Feature Branch**: `030-copy-paste-voices`
4
+
5
+ **Created**: 2026-10-15
6
+
7
+ **Status**: Draft
8
+
9
+ **Input**: User description: "Currently the edit/copy menu option calls copypaste.ts setSelections. This only copies notes in the current voice. Create a 'Copy Voices' submenu of Edit menu. It allows you to copy any single voice or all the voices (up to 4). Copying voices happens on measure boundaries, so if any partial measure is selected, the selection is extended to that whole measure. When pasting, add a voices submenu (Paste Voice). You can copy into an empty voice (voice 2 of there is only 1 voice), or an existing voice. Paste Voice menu option 'All' will paste all copied voices into the destination. Pastes always align on measure boundaries, if a voice doesn't exist on a paste target measure, it is first created for that measure."
10
+
11
+ ## User Scenarios & Testing *(mandatory)*
12
+
13
+ ### User Story 1 - Copy a whole passage with all its voices (Priority: P1)
14
+
15
+ A composer has written a passage with two or more voices in the same staff (for example, a melody with a bass line in voice 2). They select part of the passage, open the Edit menu, choose Copy Voices, then All, and later choose Paste Voice, then All at another place in the score. The whole passage, with every voice, appears there, starting at the beginning of the chosen measure.
16
+
17
+ **Why this priority**: Today a copy takes only the notes of one voice, so multi-voice music cannot be moved or repeated without copying and pasting each voice by hand and recreating the other voices first. This is the main reason for the feature.
18
+
19
+ **Independent Test**: Make a 4-measure passage with 2 voices. Select a few notes inside measures 1 to 4, choose Edit > Copy Voices > All. Click a note in measure 9 and choose Edit > Paste Voice > All. Measures 9 to 12 should now contain both voices, identical to measures 1 to 4.
20
+
21
+ **Acceptance Scenarios**:
22
+
23
+ 1. **Given** a selection covering part of one measure and part of the next, in a staff with two voices, **When** the user chooses Copy Voices > All, **Then** both whole measures are copied, with all their voices, even though only part of each was selected.
24
+ 2. **Given** copied voices and a destination measure that has only voice 1, **When** the user chooses Paste Voice > All, **Then** the missing voices are created on each destination measure, and every copied voice is pasted into the voice of the same number.
25
+ 3. **Given** copied voices and a destination in which some measures already have more voices than others, **When** the user pastes with All, **Then** every pasted measure ends up with the copied voices, and any voices not copied are left as they were.
26
+ 4. **Given** a paste that has been done, **When** the user chooses Undo once, **Then** the whole paste is undone together, including any voices that were created.
27
+
28
+ ---
29
+
30
+ ### User Story 2 - Copy one voice and put it in a chosen voice (Priority: P1)
31
+
32
+ A composer wants only one line from a passage, such as voice 2, and wants to place it into a different voice, possibly a new one. They choose Copy Voices and pick the voice to copy. At the destination they open Paste Voice and pick which voice to paste into: an existing voice (replacing what it holds in those measures) or the next empty voice.
33
+
34
+ **Why this priority**: This is the other half of the request, and it allows moving a line between voices, for example copying a melody from voice 1 into a new voice 2 to harmonize it.
35
+
36
+ **Independent Test**: In a staff with a single voice, select a measure, choose Edit > Copy Voices > Voice 1, then click a different measure and choose Edit > Paste Voice > Voice 2. The measure now has a second voice containing the copied notes, and voice 1 is unchanged.
37
+
38
+ **Acceptance Scenarios**:
39
+
40
+ 1. **Given** a staff with voices 1 and 2, **When** the user opens Copy Voices, **Then** the menu offers Voice 1, Voice 2 and All; and Voice 3 and 4 only when the selection contains them.
41
+ 2. **Given** copied music from a single voice, **When** the user opens Paste Voice, **Then** the menu offers each existing voice at the destination and a New Voice choice (a new voice 2 when only voice 1 exists), but no New Voice choice when the destination already has four voices, and never a fifth voice. **Given** copied music from all voices, **Then** the menu offers only All.
42
+ 3. **Given** a single copied voice, **When** the user pastes it into an existing voice, **Then** the contents of that voice on the destination measures are replaced by the copied notes, and other voices on those measures are unchanged.
43
+ 4. **Given** a single copied voice, **When** the user pastes it into the next empty voice, **Then** that voice is created on every destination measure it is pasted into, filled with the copied notes.
44
+ 5. **Given** a paste of a single voice, **When** the copy source was voice 2 but the destination is voice 1, **Then** the notes go to voice 1 (the voice chosen at paste time, not the voice it was copied from).
45
+
46
+ ---
47
+
48
+ ### User Story 3 - Whole measures only, and sensible menu choices (Priority: P2)
49
+
50
+ Copying and pasting voices always works on whole measures. The user can select any notes (even one note); the copy covers the entire measure(s) they touch. The menus show only choices that make sense for the current selection and clipboard, so the user can't end up with a half-measure voice or an impossible paste.
51
+
52
+ **Why this priority**: It keeps voices aligned and removes the need to think about where inside a measure a voice starts. It matters, but the feature is usable without the menu refinements.
53
+
54
+ **Independent Test**: Select a single note in the middle of a measure and choose Copy Voices > Voice 1. Paste Voice > Voice 1 on another measure: the whole measure's content appears, not just the one note. Open Paste Voice before anything has been copied: it offers nothing.
55
+
56
+ **Acceptance Scenarios**:
57
+
58
+ 1. **Given** a selection that starts or ends in the middle of a measure, **When** the user copies voices, **Then** the copy begins at the start of the first selected measure and ends at the end of the last selected measure.
59
+ 2. **Given** a paste destination that is a note in the middle of a measure, **When** the user pastes voices, **Then** the paste starts at the beginning of that measure.
60
+ 3. **Given** nothing has been copied with Copy Voices, **When** the user opens Paste Voice, **Then** no paste choices are offered (or they are shown as unavailable).
61
+ 4. **Given** the existing Copy and Paste choices, **When** the user uses them, **Then** they behave exactly as before, copying and pasting the notes of the current voice from the exact notes selected.
62
+
63
+ ---
64
+
65
+ ### Edge Cases
66
+
67
+ - What happens when the pasted measures would run past the last measure of the score? The paste is limited to the measures that exist; the extra copied measures are ignored.
68
+ - What happens when a copied voice has no content on some of the copied measures, because that voice only exists on part of the passage? Those measures are copied as empty (rests), so a voice pasted over existing music in those measures replaces it with rests.
69
+ - What happens when the destination measure has a different time signature from the source measure? The paste follows the same rules the existing paste uses when music doesn't fit a measure (the overflow continues into the following measure).
70
+ - What happens when the destination staff or measure doesn't exist, for example when nothing is selected? Paste Voice does nothing and offers no choices.
71
+ - What happens when the selection spans several staves? Each staff's selected measures are copied, and a paste places them on the same number of staves starting at the destination staff, as the existing copy and paste does.
72
+ - What happens when a copied voice contains tuplets, ties, lyrics, chords, or markings that apply to notes (slurs, dynamics)? Because whole measures are copied, whole tuplets are always included, and the music keeps whatever the existing copy and paste preserves.
73
+ - What happens when the user already has four voices on the destination measure and pastes All with four copied voices? All four destination voices are replaced; no fifth voice is created.
74
+ - What happens when a paste is made into a different clef or transposing instrument? Pitches are adjusted the same way as the existing paste.
75
+ - What happens when the user pastes the same copy more than once, or at several places? Each paste works the same; the copy remains available until the next copy.
76
+
77
+ ## Requirements *(mandatory)*
78
+
79
+ ### Functional Requirements
80
+
81
+ - **FR-001**: The Edit menu MUST contain a Copy Voices submenu and a Paste Voice submenu, in addition to the existing Copy and Paste choices, which MUST be unchanged.
82
+ - **FR-002**: The Copy Voices submenu MUST offer one choice per voice present in the selected measures (up to four), and an All choice when more than one voice is present.
83
+ - **FR-003**: Copy Voices MUST copy whole measures: from the start of the first selected measure to the end of the last selected measure, regardless of how much of those measures was selected.
84
+ - **FR-004**: Copy Voices > a single voice MUST copy only that voice's music; Copy Voices > All MUST copy every voice (up to four) present in the selected measures.
85
+ - **FR-005**: A copied voice that does not exist on some of the selected measures MUST be treated as empty on those measures.
86
+ - **FR-006**: The Paste Voice submenu MUST be available only when music has been copied with Copy Voices. When a single voice was copied, it MUST offer one choice for each voice already present at the destination (to replace it) and, unless the destination already has four voices, a New Voice choice that pastes into a new voice after the existing ones (voice 2 when only voice 1 exists). When all voices were copied (more than one), it MUST offer only the All choice. It MUST NOT offer a voice beyond the next empty voice or beyond voice 4.
87
+ - **FR-007**: Paste Voice MUST start at the beginning of the measure that contains the destination selection, never in the middle of a measure.
88
+ - **FR-008**: Pasting a single copied voice into a chosen voice MUST replace that voice's content on the destination measures with the copied content, and MUST leave the other voices on those measures unchanged.
89
+ - **FR-009**: Paste Voice > All MUST paste each copied voice into the voice of the same number at the destination, and MUST leave any destination voices that were not copied unchanged.
90
+ - **FR-010**: If the voice being pasted into does not exist on a destination measure, the system MUST create it for that measure first, and then paste the content into it.
91
+ - **FR-011**: A paste that would extend past the last measure of the score MUST be limited to the measures that exist, with no error.
92
+ - **FR-012**: Copied music MUST keep what the existing copy and paste preserves (pitches adjusted for transposition and clef, tuplets, lyrics and chords, and markings attached to the notes). Lines that span notes (slurs, hairpins and similar) MUST be carried when a voice is pasted into the voice number it was copied from, including with All; when a voice is pasted into a different voice number they are not carried.
93
+ - **FR-013**: A voice paste MUST be a single undoable action: one Undo restores all the affected measures, including removing any voices the paste created.
94
+ - **FR-014**: After a paste, the displayed score MUST show the new music, with beams, voices and measure layout updated, without requiring any other action by the user.
95
+ - **FR-015**: The copy made by Copy Voices MUST remain available for repeated pastes until the next copy.
96
+
97
+ ### Key Entities
98
+
99
+ - **Voice**: One of up to four independent lines of notes within the same staff, in each measure, numbered 1 to 4.
100
+ - **Voice copy**: A copy of one or more complete voices over a run of whole measures, held until the next copy; for each voice it records the music of each measure.
101
+ - **Paste target**: The staff and measure where the user has selected a note; a voice paste always begins at the start of that measure.
102
+
103
+ ## Success Criteria *(mandatory)*
104
+
105
+ ### Measurable Outcomes
106
+
107
+ - **SC-001**: A user can duplicate a multi-voice passage to another place in the score with one copy choice and one paste choice (two menu selections plus the selection and destination click), and every pasted voice matches the source note for note in 100% of cases.
108
+ - **SC-002**: After a paste from a copy that included partial measures, the pasted passage always covers whole measures: the first pasted note is on the first beat of a measure in 100% of cases.
109
+ - **SC-003**: Pasting into a measure that lacks the chosen voice always produces that voice with the copied music, without the user adding the voice first, in 100% of cases.
110
+ - **SC-004**: One Undo returns every affected measure to its state before the paste, including removing any voices the paste added, in 100% of cases.
111
+ - **SC-005**: The existing Copy and Paste choices produce exactly the same results as before this feature, verified on the same sample passages.
112
+ - **SC-006**: In a manual pass, users never see a Paste Voice choice that would produce more than four voices or skip a voice number.
113
+
114
+ ## Assumptions
115
+
116
+ - Up to four voices per measure is the existing limit, and is not changed here.
117
+ - Copy Voices lists voices that exist in the selected measures; Voice 3 and 4 appear only if they exist there.
118
+ - All, in Paste Voice, is the only choice when the copy holds more than one voice (each voice goes to the voice of the same number); with a single copied voice only the per-voice choices appear. Putting one voice of a multi-voice copy into a chosen voice is done by copying just that voice.
119
+ - A voice pasted into an existing voice replaces that voice's music for the pasted measures; it does not merge with it.
120
+ - Where the source and destination measures differ in length, the existing paste's behavior for music that doesn't fit is reused rather than redefined here.
121
+ - Copying across several staves and pasting into the same number of staves from the destination works as the existing copy and paste does; per-staff selection of voices is the same voice choice applied to every copied staff.
122
+ - Keyboard shortcuts for Copy and Paste stay as they are; the new submenus are reached through the Edit menu. Adding shortcuts is out of scope.
123
+ - The existing menu structure that lets a menu choice open a submenu beside it is available and used for the two new submenus.
124
+ - Voice-level copy and paste does not change the saved score format.
@@ -0,0 +1,183 @@
1
+ ---
2
+
3
+ description: "Task list for Copy and Paste Voices"
4
+ ---
5
+
6
+ # Tasks: Copy and Paste Voices
7
+
8
+ **Input**: Design documents from `/specs/030-copy-paste-voices/`
9
+
10
+ **Prerequisites**: [plan.md](./plan.md), [spec.md](./spec.md), [research.md](./research.md), [data-model.md](./data-model.md), [contracts/voice-copy-paste-contract.md](./contracts/voice-copy-paste-contract.md), [quickstart.md](./quickstart.md)
11
+
12
+ **Tests**: Included. The plan commits to a headless `tests/voiceCopyPaste.ts` (cases V1 to V20) that drives the real `PasteBuffer` on in-memory scores. Undo, menus and redraw are checked manually (cases M1 to M10).
13
+
14
+ **Organization**: Tasks are grouped by user story. The core copy and paste logic in `copypaste.ts` is shared by all three stories, so it is the foundation; each story then adds its tests and its menu/view surface.
15
+
16
+ ## Format: `[ID] [P?] [Story] Description`
17
+
18
+ - **[P]**: Can run in parallel (different files, no dependencies on incomplete tasks)
19
+ - **[Story]**: Which user story this task belongs to (US1, US2, US3)
20
+
21
+ ## Path Conventions
22
+
23
+ Single project: `src/`, `tests/`, repo-root `package.json`.
24
+
25
+ ---
26
+
27
+ ## Phase 1: Setup
28
+
29
+ - [X] T001 Add the script `"test:voice-copy-paste": "ts-node -P tests/tsconfig.json tests/voiceCopyPaste.ts"` to `package.json`, next to the existing `test:promise-helpers` entry.
30
+ - [X] T002 Create `tests/voiceCopyPaste.ts` with the scaffold and the shared test score builder: header comment pointing at `specs/030-copy-paste-voices/contracts/voice-copy-paste-contract.md`; the dynamic-ctor-init calls and imports used by `tests/attachedTextMigration.ts`; the `failures` counter and `check()` helper; the final summary block; and `buildScore()` which makes the single-staff 12-measure 4/4 test score described in the contract (voice 1 on every measure with four quarter notes whose pitches encode the position; voice 2 on measures 1 to 4; voice 3 on measure 2 only; a triplet in voice 1 of measure 6; a triplet in voice 2 of measure 7 is added to measure 7 for case V17; measure 10 with one voice only), plus helpers `voiceNotes(score, measure, voice)` returning `pitch:ticks` strings and `selectNotes(score, measure, firstTick, lastTick, voice)` returning note `SmoSelection`s. Use `SmoScore.getDefaultScore`, `SmoScore.addMeasure`/`addStaff` equivalents, `SmoMeasure.populateVoice`, `SmoNote` and `SmoMeasure.makeTuplet` helpers already used elsewhere in the code.
31
+
32
+ ---
33
+
34
+ ## Phase 2: Foundational (Blocking Prerequisites)
35
+
36
+ **Purpose**: The voice-copy capture and paste logic in the smo layer, used by every story.
37
+
38
+ **CRITICAL**: No user story work can begin until this phase is complete.
39
+
40
+ - [X] T003 In `src/smo/xform/copypaste.ts`, add the `VoiceCopy` interface (fields per [data-model.md](./data-model.md)) and a `voiceCopy: VoiceCopy | null = null` field on `PasteBuffer`, and implement `setVoiceSelections(score: SmoScore, selections: SmoSelection[], voice: number | 'all'): boolean`: derive the staves and first/last measure from the selections (extending to whole measures), choose the voice list (the one voice, or every voice present in any selected measure, up to 4), and for each voice and staff build the full note list for all copied measures using the existing `_populateSelectArray` per voice (set `this.notes = {}` and `this.modifiers = []` before each call, store the results in `voiceCopy.notes[voice]` and `voiceCopy.modifiers[voice]`, then restore `this.notes` and `this.modifiers` to empty). For a measure that lacks the voice, add a `PasteNote` for each note of `SmoMeasure.getDefaultNotes(measure)` (default rests) with a selector `{ staff, measure, voice, tick }`. Return false if nothing was copied.
41
+ - [X] T004 In `src/smo/xform/copypaste.ts`, implement the paste core `pasteVoice(destination: SmoSelector, voice: number): SmoSelection[]` that requires a single-voice `voiceCopy`; for each copied staff `k` (stopping when the destination staff `destination.staff + k` does not exist) deep-copy the notes (using `SmoNote.deserialize(note.serialize())` and `SmoTupletTree.deserialize(tupletStart.serialize())` like `pasteNoteSelections` does), set each copied `PasteNote.selector.voice` and each copied tuplet tree's `voice` to the destination voice, and call `pasteNoteSelections({ staff, measure: destination.measure, voice, tick: 0, pitches: [] }, notes)`. Set `this.modifiers` to the voice's copied modifiers only if the destination voice equals the source voice; otherwise set it to an empty list ([research.md](./research.md) section 5). Collect and return the replaced measure selections from `this.replacementMeasures`. Reject (return `[]`) a destination voice above 3.
42
+ - [X] T005 In `src/smo/xform/copypaste.ts`, implement `pasteAllVoices(destination: SmoSelector): SmoSelection[]` which, for a multi-voice `voiceCopy`, calls the same paste step as `pasteVoice` once per copied voice in ascending voice order, each into the voice of the same number (so missing voices are created in order), and returns all replaced measure selections.
43
+ - [X] T006 In `src/smo/xform/copypaste.ts` `_populateMeasureArray`, change the middle-measure tuplet clearing loop to `for (let i = 1; i < this.measures.length - 1; i++)` and remove only the trees of the destination voice: `this.measures[i].tupletTrees = this.measures[i].tupletTrees.filter((tree) => tree.voice !== this.destination.voice);` ([research.md](./research.md) section 3).
44
+ - [X] T007 [P] In `src/smo/xform/copypaste.ts`, add the pure static functions `PasteBuffer.copyVoiceChoices(voicesInSelection: number)` and `PasteBuffer.pasteVoiceChoices(copiedVoices: number[], destVoiceCount: number)` exactly as specified in [data-model.md](./data-model.md), and the queries `hasVoiceCopy()`, `copiedVoiceNumbers()` and `getVoiceCopyTickCount()` (the ticks of one copied voice on one staff).
45
+ - [X] T008 In `src/smo/xform/copypaste.ts`, clear `voiceCopy` in `setSelections` and `clearSelections` so a normal copy invalidates a voice copy, and add a `clearVoiceCopy()` method.
46
+ - [X] T009 Run `npx tsc --noEmit -p tsconfig.json` and fix any errors; confirm the existing tests still pass (`npm run test:attached-text` and the others).
47
+
48
+ **Checkpoint**: The smo layer can capture and paste voices; nothing in the UI uses it yet.
49
+
50
+ ---
51
+
52
+ ## Phase 3: User Story 2 - Copy one voice and put it in a chosen voice (Priority: P1) MVP
53
+
54
+ **Goal**: Copy Voices > Voice N and Paste Voice > Voice M work from the Edit menu.
55
+
56
+ **Independent Test**: quickstart.md section 3, steps 1, 2, 5, 6, 7.
57
+
58
+ ### Tests for User Story 2
59
+
60
+ - [X] T010 [P] [US2] In `tests/voiceCopyPaste.ts`, add cases V5 to V10 (copy extent from partial selections, paste into the same voice number, other voices unchanged, paste into an existing different voice, paste into a new voice, voice number change).
61
+ - [X] T011 [P] [US2] In `tests/voiceCopyPaste.ts`, add cases V14 to V18 (end-of-score limiting, missing voice becomes rests, a triplet kept intact and registered for the destination voice, another voice's triplet survives a multi-measure paste, no stale tuplet tree in the second-to-last pasted measure).
62
+ - [X] T012 [US2] Run `npm run test:voice-copy-paste` and fix `copypaste.ts` until V5 to V10 and V14 to V18 pass.
63
+
64
+ ### Implementation for User Story 2
65
+
66
+ - [X] T013 [US2] In `src/render/sui/scoreViewOperations.ts`, add `async copyVoices(voice: number | 'all'): Promise<void>`: map `this.tracker.selections` to store-score selections with `_getEquivalentSelection` (as `copy()` does), call `this.storePaste.setVoiceSelections(this.storeScore, altSelections, voice)`, and `await this.renderer.updatePromise()`.
67
+ - [X] T014 [US2] In `src/render/sui/scoreViewOperations.ts`, add `async pasteVoices(voice: number | 'all'): Promise<void>` modeled on `paste()`: return if there is no voice copy or no selection; take the first selection's measure as the target (tick forced to 0); compute the affected measure range by adding destination measure lengths (`getTicksFromThisOrAnyVoice`) until they reach `storePaste.getVoiceCopyTickCount()`, limited to the last measure; set `storeUndo.grouping = true`, call `_undoColumn('paste voices', i)` and `renderer.unrenderColumn(...)` for each measure in the range, set `grouping = false`; call `pasteVoice(target, voice)` or `pasteAllVoices(target)` on `storePaste` using the store-equivalent selector; then `replaceMeasureView(range)` and `await this.renderer.updatePromise()`.
68
+ - [X] T015 [US2] In `src/render/sui/scoreViewOperations.ts`, add `getSelectionVoiceCount(): number` (highest `voices.length` among the selected measures) and `getDestinationVoiceCount(): number` (`voices.length` of the first selected measure), for the menus.
69
+ - [X] T016 [US2] In `src/ui/menus/edit.ts`, add the `Copy Voices` option with a `subMenu` of four choices (value `copyVoice0` to `copyVoice3`, text `Voice 1` to `Voice 4`), each calling `menu.view.copyVoices(n)` and displayed when `PasteBuffer.copyVoiceChoices(menu.view.getSelectionVoiceCount())` includes `n`; the parent option's `display` is true when that list is non-empty. Add the `Paste Voice` option with a `subMenu` of four choices (`pasteVoice0` to `pasteVoice3`) each calling `menu.view.pasteVoices(n)` and displayed when `PasteBuffer.pasteVoiceChoices(menu.view.storePaste.copiedVoiceNumbers(), menu.view.getDestinationVoiceCount())` includes `n`; the parent is displayed when that list is non-empty. Add both options to `SuiEditMenuOptions` after `Paste Chords`.
70
+ - [X] T017 [US2] Run `npx tsc --noEmit -p tsconfig.json` and fix any errors.
71
+ - [ ] T018 [US2] Manual validation: quickstart.md section 3, steps 1, 2, 5, 6, 7 (M1, M2, M3, M5, M8).
72
+
73
+ **Checkpoint**: Single-voice copy and paste work from the menu.
74
+
75
+ ---
76
+
77
+ ## Phase 4: User Story 1 - Copy a whole passage with all its voices (Priority: P1)
78
+
79
+ **Goal**: Copy Voices > All and Paste Voice > All.
80
+
81
+ **Independent Test**: quickstart.md section 3, steps 3 and 4.
82
+
83
+ ### Tests for User Story 1
84
+
85
+ - [X] T019 [P] [US1] In `tests/voiceCopyPaste.ts`, add cases V11 to V13 and V19 (paste All into a one-voice destination, into a destination with existing voices, uncopied destination voices unchanged, slurs carried within a voice number and not carried when the number changes).
86
+ - [X] T020 [US1] Run `npm run test:voice-copy-paste` and fix `copypaste.ts` until V11 to V13 and V19 pass.
87
+
88
+ ### Implementation for User Story 1
89
+
90
+ - [X] T021 [US1] In `src/ui/menus/edit.ts`, add an `All Voices` choice (value `copyVoiceAll`, calls `menu.view.copyVoices('all')`) to the Copy Voices submenu, displayed when `PasteBuffer.copyVoiceChoices(...)` includes `'all'`; and an `All` choice (value `pasteVoiceAll`, calls `menu.view.pasteVoices('all')`) to the Paste Voice submenu, displayed when `PasteBuffer.pasteVoiceChoices(...)` includes `'all'`.
91
+ - [X] T022 [US1] Run `npx tsc --noEmit -p tsconfig.json`.
92
+ - [ ] T023 [US1] Manual validation: quickstart.md section 3, steps 3 and 4 (M4, M6).
93
+
94
+ **Checkpoint**: Whole passages with several voices can be copied and pasted, and undone in one step.
95
+
96
+ ---
97
+
98
+ ## Phase 5: User Story 3 - Whole measures only, and sensible menu choices (Priority: P2)
99
+
100
+ **Goal**: Whole-measure behavior and menu choices are tested and the clipboard is invalidated correctly.
101
+
102
+ **Independent Test**: V1 to V4, V15, V20 pass; quickstart.md steps 1 to 3 and 8 to 11.
103
+
104
+ ### Tests for User Story 3
105
+
106
+ - [X] T024 [P] [US3] In `tests/voiceCopyPaste.ts`, add cases V1 to V4 (the pure choice functions) and V20 (the existing `setSelections` / `pasteSelections` path gives the same result as before for single-voice, multi-voice-selected and multi-measure copies; capture the expected notes from a run before the T006 change by reasoning from the source score and assert they equal the pasted notes).
107
+ - [X] T025 [US3] Run `npm run test:voice-copy-paste` and fix until all cases V1 to V20 pass.
108
+
109
+ ### Implementation for User Story 3
110
+
111
+ - [X] T026 [US3] In `src/render/sui/scoreView.ts` `changeScore`, call `this.storePaste.clearVoiceCopy()` so a voice copy from a previous score is not offered after a new score is loaded.
112
+ - [X] T027 [US3] In `src/render/sui/scoreViewOperations.ts` `pasteVoices`, make sure the target tick is 0 whatever note was selected (the paste starts at the beginning of its measure) and that nothing is done when the selection or the clipboard is empty; confirm in the code that no existing `paste()` tick handling is reused.
113
+ - [ ] T028 [US3] Manual validation: quickstart.md section 3, steps 8 to 11 (edge cases, existing Copy/Paste, part view).
114
+
115
+ **Checkpoint**: All stories complete.
116
+
117
+ ---
118
+
119
+ ## Phase 6: Polish & Cross-Cutting Concerns
120
+
121
+ - [X] T029 Run `npm run test:voice-copy-paste` and all seven existing test scripts; confirm all pass.
122
+ - [X] T030 Run `npx tsc --noEmit -p tsconfig.json` and `npm run build`; confirm both succeed with no new warnings.
123
+ - [ ] T031 Run through all of quickstart.md (sections 1 to 3) and note the result.
124
+
125
+ ---
126
+
127
+ ## Dependencies & Execution Order
128
+
129
+ ### Phase Dependencies
130
+
131
+ - **Setup (Phase 1)**: none.
132
+ - **Foundational (Phase 2)**: depends on Setup. T003 to T006 all edit `copypaste.ts`, so do them in order; T007 can be written in parallel to a separate region of the same file only if edited carefully, otherwise after T006.
133
+ - **US2 (Phase 3)**: depends on Phase 2. Its tests (T010, T011) are in the shared test file and depend on T002.
134
+ - **US1 (Phase 4)**: depends on Phase 2 and on T013 to T016 (the view methods and submenu it extends).
135
+ - **US3 (Phase 5)**: depends on Phase 2; T026 and T027 touch the view files after US2's edits.
136
+ - **Polish (Phase 6)**: depends on all stories.
137
+
138
+ ### Within Each Story
139
+
140
+ - `copypaste.ts` is edited in Phase 2 only (and `scoreViewOperations.ts` by T013 to T015, then T027); keep edits in the order given.
141
+ - `edit.ts` is edited by T016 then T021.
142
+ - `tests/voiceCopyPaste.ts` is edited by T002, T010, T011, T019 and T024: add cases in separate blocks, in order.
143
+
144
+ ### Parallel Opportunities
145
+
146
+ - T010 and T011 (separate test blocks) with T013 to T015 (different file).
147
+ - T007 is independent in logic from T003 to T006.
148
+ - Most other work is in shared files, so it is sequential.
149
+
150
+ ---
151
+
152
+ ## Parallel Example: Phase 3
153
+
154
+ ```text
155
+ Task: "Add cases V5-V10 to tests/voiceCopyPaste.ts" (T010)
156
+ Task: "Add cases V14-V18 to tests/voiceCopyPaste.ts" (T011)
157
+ Task: "copyVoices / pasteVoices / count helpers in scoreViewOperations.ts" (T013-T015)
158
+ ```
159
+
160
+ ---
161
+
162
+ ## Implementation Strategy
163
+
164
+ ### MVP First (User Story 2)
165
+
166
+ 1. Phases 1 and 2 (the smo logic, compiled but untested).
167
+ 2. Phase 3: tests prove single-voice copy and paste; the view and menu expose them.
168
+ 3. Stop and validate in the app: copy a voice, paste it into a new voice.
169
+
170
+ ### Incremental Delivery
171
+
172
+ 1. US2 delivers single-voice copy and paste.
173
+ 2. US1 adds the All choices.
174
+ 3. US3 adds the regression guard for existing Copy/Paste, the choice-function tests and score-change invalidation.
175
+
176
+ ---
177
+
178
+ ## Notes
179
+
180
+ - Tests are written before the view and menu code in each story and should fail first where they exercise new logic; if T003 to T008 already make them pass, record that.
181
+ - The two fixes in `_populateMeasureArray` (T006) also affect existing paste in a narrow way (other voices' tuplets in middle measures are kept). Case V20 and V17 guard it.
182
+ - No keyboard shortcuts are added (spec assumption).
183
+ - Commit after each phase.
@@ -0,0 +1,39 @@
1
+ # Specification Quality Checklist: Select Voice
2
+
3
+ **Purpose**: Validate specification completeness and quality before proceeding to planning
4
+
5
+ **Created**: 2026-10-20
6
+
7
+ **Feature**: [spec.md](../spec.md)
8
+
9
+ ## Content Quality
10
+
11
+ - [x] No implementation details (languages, frameworks, APIs)
12
+ - [x] Focused on user value and business needs
13
+ - [x] Written for non-technical stakeholders
14
+ - [x] All mandatory sections completed
15
+
16
+ ## Requirement Completeness
17
+
18
+ - [x] No [NEEDS CLARIFICATION] markers remain
19
+ - [x] Requirements are testable and unambiguous
20
+ - [x] Success criteria are measurable
21
+ - [x] Success criteria are technology-agnostic (no implementation details)
22
+ - [x] All acceptance scenarios are defined
23
+ - [x] Edge cases are identified
24
+ - [x] Scope is clearly bounded
25
+ - [x] Dependencies and assumptions identified
26
+
27
+ ## Feature Readiness
28
+
29
+ - [x] All functional requirements have clear acceptance criteria
30
+ - [x] User scenarios cover primary flows
31
+ - [x] Feature meets measurable outcomes defined in Success Criteria
32
+ - [x] No implementation details leak into specification
33
+
34
+ ## Notes
35
+
36
+ - The Input line quotes the request verbatim. The rest of the spec uses behavioral terms.
37
+ - Defaults chosen without asking: rests count as notes of a voice; a voice missing from some selected measures simply contributes nothing there (and is never created); choosing a voice does not add an undo entry; multi-staff selections apply the chosen voice on every selected staff.
38
+ - The existing Voices menu already has "Voice N" entries that make a voice active and may create it; the spec keeps Select Voice separate (FR-011, User Story 3) so the plan phase should reuse the existing logic for selecting the active voice's notes only if it does not create voices or change the score.
39
+ - Ready for `/speckit-clarify` or `/speckit-plan`.
@@ -0,0 +1,43 @@
1
+ # Contract: Select Voice
2
+
3
+ Headless cases S1 to S14 are verified by `tests/selectVoice.ts` (`npm run test:select-voice`) against in-memory scores. Manual cases M1 to M10 are in [quickstart.md](../quickstart.md). Spec references: [spec.md](../spec.md).
4
+
5
+ ## Test score used by S-cases
6
+
7
+ Two staves, 6 measures each, 4/4. Staff 0: voice 0 on every measure as four quarter notes; voice 1 on measures 0 to 2 (measure 0: a single whole note; measure 1: two half notes; measure 2: four quarter notes); voice 2 on measure 2 only. Staff 1: voice 0 on every measure; voice 1 on measure 1 only. Measure 3 of staff 0 has voice 0 as four quarter rests. Helpers build selections from tick ranges (as the tracker would hold them).
8
+
9
+ ## Headless cases
10
+
11
+ | ID | Case | Expected | Spec |
12
+ |----|------|----------|------|
13
+ | S1 | `voiceChoices` with a selection in one single-voice measure (staff 0, measure 4) | `[]` | FR-003, US2.1 |
14
+ | S2 | `voiceChoices` with no selection | `[]` | FR-003, US2.5 |
15
+ | S3 | Selection in staff 0 measure 0 (voices 0, 1) | `[0, 1]` | FR-002, US2.2 |
16
+ | S4 | Selection in measures 0 to 2 of staff 0 (voice 2 only in measure 2) | `[0, 1, 2]` | FR-002 |
17
+ | S5 | `voiceChoices` with a selection spanning measures 3 and 4 of staff 0 (both single-voice) | `[]` | FR-003 |
18
+ | S6 | One note selected in measure 0 (the third quarter of voice 0); `getVoiceSelectors` voice 1 | one selector: the whole note of measure 0 voice 1 | FR-004, FR-005, US1.2 |
19
+ | S7 | Measure 1 selected; voice 1 (two half notes) | two selectors ticks 0 and 1, even though voice 0 has four notes | FR-005, US1.3 |
20
+ | S8 | Measures 0 to 2 selected; voice 1 | 1 + 2 + 4 = 7 selectors, in measure then tick order, all voice 1 | FR-004, US1.1 |
21
+ | S9 | Measures 0 to 2 selected; voice 2 | only the four notes of measure 2 | FR-007, US2.3 |
22
+ | S10 | Measures 0 to 1 selected; voice 2 (no notes anywhere in them) | `[]` | FR-008, US2.4 |
23
+ | S11 | Selection on staff 0 and staff 1, measure 1; voice 1 | staff 0 two notes and staff 1 its voice 1 notes; neither staff gets the other's | FR-004, US1.4 |
24
+ | S12 | Selection on staff 0 and staff 1, measure 0; voice 1 | staff 0's whole note only; staff 1 (no voice 1 in measure 0) contributes nothing and gets no voice | FR-007 |
25
+ | S13 | Measure 3 selected (voice 0 all rests); voice 0 | four selectors for the rests | edge case, rests |
26
+ | S14 | `getVoiceSelectors` leaves the score unchanged: serialize before and after; voice counts per measure unchanged | identical | FR-007, FR-009, SC-004 |
27
+ | S15 | voice 4 and voice -1 | `[]` | robustness |
28
+ | S16 | selectors contain no `pitches` entries (whole notes) and the voice field equals the requested voice | true | FR-006 |
29
+
30
+ ## Manual cases
31
+
32
+ | ID | Case | Expected | Spec |
33
+ |----|------|----------|------|
34
+ | M1 | Select a single-voice measure, open Edit | no Select Voice entry | FR-003 |
35
+ | M2 | Select a two-voice measure, open Edit > Select Voice | Voice 1 and Voice 2 | FR-002 |
36
+ | M3 | Select one note, Select Voice > Voice 2 | all voice 2 notes of that measure are highlighted, none of voice 1 | US1.2 |
37
+ | M4 | Select measures 1 to 4, Select Voice > Voice 2, then change pitch with the arrow keys | only voice 2 changes | SC-002, US1.5 |
38
+ | M5 | Choose a voice with no notes in the selected measures (if offered by another selected measure) | selection unchanged | FR-008 |
39
+ | M6 | Select Voice several times alternating voices, then Undo | Undo applies to the last edit, not the selections | FR-009, US3.2 |
40
+ | M7 | Two staves selected | the chosen voice is selected on both | US1.4 |
41
+ | M8 | Part view | works on displayed measures | edge case |
42
+ | M9 | After Select Voice, use arrow keys | navigation continues from the selection | edge case |
43
+ | M10 | Voices menu still behaves as before | unchanged | FR-011 |
@@ -0,0 +1,47 @@
1
+ # Data Model: Select Voice
2
+
3
+ No persisted data, score structure or undo structure changes (constitution Principle #1). All state is the tracker's current selection.
4
+
5
+ ## Selected measure pair
6
+
7
+ A `(staff, measure)` pair taken from the current selections. The set of pairs is the set of measures that currently have at least one selected note, on each staff. Order: by staff, then measure.
8
+
9
+ ## Pure functions (static on `SmoSelection`)
10
+
11
+ ```ts
12
+ SmoSelection.voiceChoices(score: SmoScore, selections: SmoSelection[]): number[]
13
+ // maxVoices = most voices (capped at 4) in any selected (staff, measure) pair
14
+ // maxVoices < 2 -> []
15
+ // otherwise -> [0 .. maxVoices - 1]
16
+
17
+ SmoSelection.getVoiceSelectors(score: SmoScore, selections: SmoSelection[], voice: number): SmoSelector[]
18
+ // for each selected (staff, measure) pair, in staff then measure order:
19
+ // if voice < measure.voices.length: one selector per note of that voice, ticks 0..n-1 in order
20
+ // else: nothing (and the voice is never created)
21
+ // pitches is [] on every selector (the whole note is selected)
22
+ ```
23
+
24
+ Rests are notes of the voice and are included. If `voice` is outside 0 to 3, or the selections list is empty, the result is empty.
25
+
26
+ ## Tracker
27
+
28
+ | Member | Meaning |
29
+ |--------|---------|
30
+ | `SuiTracker.selectVoice(voice: number): boolean` | Replace the selection with the rendered notes of the chosen voice in the selected measures. Returns false, changing nothing, if no such notes are found |
31
+
32
+ Steps on success: `this.selections = mapped`; `pitchIndex = -1`; `measure.setActiveVoice(voice)` for each measure that has the voice; `score.setActiveStaff(first selected staff)`; `_createLocalModifiersList()`; `deferHighlight()`.
33
+
34
+ ## View (`SuiScoreViewOperations`)
35
+
36
+ | Method | Meaning |
37
+ |--------|---------|
38
+ | `getSelectVoiceChoices(): number[]` | `SmoSelection.voiceChoices(this.score, this.tracker.selections)`, for the menu |
39
+ | `selectVoice(voice: number): Promise<void>` | Calls `tracker.selectVoice(voice)`; no undo, no score change |
40
+
41
+ ## State transitions
42
+
43
+ | Event | Effect |
44
+ |-------|--------|
45
+ | Select Voice > Voice N, notes found | selection replaced; active voice of the affected measures set to N |
46
+ | Select Voice > Voice N, no notes found | nothing changes |
47
+ | Any later selection action | replaces the selection as usual |
@@ -0,0 +1,79 @@
1
+ # Implementation Plan: Select Voice
2
+
3
+ **Branch**: `031-select-voice` | **Date**: 2026-10-20 | **Spec**: [spec.md](./spec.md)
4
+
5
+ **Input**: Feature specification from `/specs/031-select-voice/spec.md`
6
+
7
+ ## Summary
8
+
9
+ Two pure static functions on `SmoSelection` (`src/smo/xform/selections.ts`) hold all the decision logic: `voiceChoices(score, selections)` returns the voices to offer (empty unless some selected measure has more than one voice), and `getVoiceSelectors(score, selections, voice)` returns the selector of every note of the chosen voice in every measure that currently has a selection, on every selected staff. The tracker (`SuiTracker`, in `src/render/sui/tracker.ts`) gets `selectVoice(voice)`: it maps those selectors to the already-rendered selections in `measureNoteMap` (looked up by `SmoSelector.getNoteKey`, which carries the boxes the highlighter needs), and replaces `selections` with them only if at least one was found; otherwise it changes nothing. It sets the chosen voice active on the affected measures as `selectSuggestion` does, refreshes the local modifier list and highlights. The view (`SuiScoreViewOperations`) exposes a thin `selectVoice` and `getSelectVoiceChoices`, and `edit.ts` adds a Select Voice option with four voice choices whose `display` rules come from the pure function. No score data, undo or serialization is touched.
10
+
11
+ ## Technical Context
12
+
13
+ **Language/Version**: TypeScript (built by `build/build.js`).
14
+
15
+ **Primary Dependencies**: None new. `SmoSelection`/`SmoSelector`, `SuiTracker` (`measureNoteMap`, `deferHighlight`, `_createLocalModifiersList`), the menu `subMenu` support already used by the Copy Voices and arpeggio menus.
16
+
17
+ **Storage**: None. The selection is runtime state in the tracker.
18
+
19
+ **Testing**: A headless script `tests/selectVoice.ts` (`npm run test:select-voice`) running the pure functions against in-memory scores: choices, the whole-measure rule, uneven voices, multiple staves, missing voices, rests, no-op cases. The tracker mapping, highlighting and the menu are verified manually (quickstart.md); they need the renderer.
20
+
21
+ **Target Platform**: Browser application; tests run under Node.
22
+
23
+ **Project Type**: Single project (library + application).
24
+
25
+ **Performance Goals**: A selection of a few hundred notes is built with one dictionary lookup per note and one highlight pass, the same as any range selection. No DOM measurement is added.
26
+
27
+ **Constraints**: No change to the score, no undo entry (FR-009); the existing Voices menu is untouched (FR-011); no voice is ever created; the selection must carry rendered boxes or the highlighter skips it.
28
+
29
+ **Scale/Scope**: Two pure functions, one tracker method, two small view methods, one menu option, one test.
30
+
31
+ ## Constitution Check
32
+
33
+ *GATE: Must pass before Phase 0 research. Re-check after Phase 1 design.*
34
+
35
+ - **Principle #1 (Serialization)**: PASS. Nothing is added to the score. (Setting a measure's active voice, which `selectSuggestion` already does on every note selection, is an existing serialized measure parameter and is not new state.)
36
+ - **Principle #2 (Music editing logic regression testing)**: PASS. Selection construction (which notes belong to which voice in which measures) is pure and covered by a headless script with a contract case list, as for specs 019 to 030.
37
+ - **Principle #3 (Rendering performance)**: PASS. One selection replacement and one deferred highlight, the same path as any multi-note selection. No DOM measurement added.
38
+ - **Principle #4 (Logical dependencies)**: PASS. The pure functions are in `src/smo`. The tracker only maps selectors to rendered artifacts. `edit.ts` only maps choices to view calls.
39
+
40
+ No violations; Complexity Tracking is not needed. Re-check after Phase 1: unchanged, still PASS.
41
+
42
+ ## Project Structure
43
+
44
+ ### Documentation (this feature)
45
+
46
+ ```text
47
+ specs/031-select-voice/
48
+ ├── plan.md
49
+ ├── research.md
50
+ ├── data-model.md
51
+ ├── quickstart.md
52
+ ├── contracts/
53
+ │ └── select-voice-contract.md
54
+ ├── checklists/
55
+ │ └── requirements.md
56
+ └── tasks.md # created later by /speckit-tasks
57
+ ```
58
+
59
+ ### Source Code (repository root)
60
+
61
+ ```text
62
+ src/
63
+ ├── smo/xform/selections.ts # SmoSelection.voiceChoices(), SmoSelection.getVoiceSelectors()
64
+ ├── render/sui/
65
+ │ ├── tracker.ts # SuiTracker.selectVoice(voice): boolean
66
+ │ └── scoreViewOperations.ts # selectVoice(voice), getSelectVoiceChoices()
67
+ └── ui/menus/edit.ts # "Select Voice" option with Voice 1-4 subMenu
68
+
69
+ tests/
70
+ └── selectVoice.ts # NEW headless regression script
71
+
72
+ package.json # add "test:select-voice"
73
+ ```
74
+
75
+ **Structure Decision**: Put the logic where selections already live (`SmoSelection`), and keep the tracker method a thin mapping step so the part that needs a renderer is as small as possible.
76
+
77
+ ## Complexity Tracking
78
+
79
+ *No Constitution Check violations; table not needed.*
@@ -0,0 +1,43 @@
1
+ # Quickstart: Validating Select Voice
2
+
3
+ Contract cases are in [contracts/select-voice-contract.md](./contracts/select-voice-contract.md); structures are in [data-model.md](./data-model.md).
4
+
5
+ ## 1. Headless regression test
6
+
7
+ ```bash
8
+ npm run test:select-voice
9
+ ```
10
+
11
+ Expected: every case S1 to S16 prints `PASS`, the run ends with `all checks passed`, and the exit code is 0.
12
+
13
+ ## 2. Type check, build, existing tests
14
+
15
+ ```bash
16
+ npx tsc --noEmit -p tsconfig.json
17
+ npm run build
18
+ npm run test:voice-copy-paste
19
+ npm run test:promise-helpers
20
+ npm run test:score-change-state
21
+ npm run test:page-divisions
22
+ npm run test:global-layout-reposition
23
+ npm run test:text-drag-placement
24
+ npm run test:attached-text
25
+ npm run test:rehearsal-measure-number
26
+ ```
27
+
28
+ Expected: no errors; all scripts pass.
29
+
30
+ ## 3. Manual check in the app
31
+
32
+ Prerequisite: build and open the app. Make a score with at least four measures. Give measures 1 to 3 two voices (use the Voices menu), with different numbers of notes in the two voices in one of them (for example a whole note in voice 2 under four quarters in voice 1). Leave measure 4 with one voice.
33
+
34
+ 1. Select a note in measure 4 (one voice) and open the Edit menu: there is no Select Voice entry.
35
+ 2. Select a single note in measure 1 and open Edit > Select Voice: Voice 1 and Voice 2 are offered, no others.
36
+ 3. Choose Voice 2: all the notes of voice 2 in measure 1 are highlighted (including a long note that does not line up with the original selection), and no voice 1 note is.
37
+ 4. Select measures 1 to 3 (drag or Shift+arrow), choose Select Voice > Voice 2, then press the up arrow: only voice 2 notes change pitch.
38
+ 5. Select measures 1 to 4, choose Select Voice > Voice 2: the voice 2 notes of measures 1 to 3 are selected; measure 4 contributes nothing.
39
+ 6. Select Voice 1, then Voice 2, then Voice 1 again several times, then choose Edit > Undo: the undo applies to your last edit, not to the selections.
40
+ 7. With two staves selected over the same measure, choose Select Voice > Voice 1: voice 1 is selected on both staves.
41
+ 8. Open the Voices menu and use its Voice N entries: it behaves as before (it can create a voice).
42
+ 9. After Select Voice, use the arrow keys to move: navigation continues from the selection.
43
+ 10. Expose a part (part view) and repeat step 3.
@@ -0,0 +1,55 @@
1
+ # Research: Select Voice
2
+
3
+ No NEEDS CLARIFICATION items remained after the spec. Findings from reading the code:
4
+
5
+ ## 1. `selectActiveVoice` cannot be reused
6
+
7
+ **Finding**: `SuiTracker.selectActiveVoice()` takes `this.selections[0]`, changes its voice to the measure's active voice and replaces the whole selection with that one note (`_getClosestTick`). It is for the single-note case after the Voices menu or a click. It cannot build a range, ignores the other selected measures, and `_getClosestTick` falls back to the first note of the measure (or the first note anywhere) when the exact note is not mapped, which would select the wrong notes.
8
+
9
+ **Decision**: Add a new tracker method, `selectVoice(voice)`, and do not touch `selectActiveVoice`.
10
+
11
+ ## 2. How rendered selections are found
12
+
13
+ **Finding**: Highlighting (`highlightSelection`) draws the union of each selection's `box` and returns early if the first selection has no box. Rendered `SmoSelection` objects, with boxes, are held in `measureNoteMap`, keyed by `SmoSelector.getNoteKey` (`staff-measure-voice-tick`). `SmoSelection.noteSelection(score, ...)` builds a selection without boxes.
14
+
15
+ **Decision**: The pure function returns selectors. The tracker turns each into a rendered selection with a direct `measureNoteMap[SmoSelector.getNoteKey(selector)]` lookup (O(1) per note), skipping any note that is not currently mapped (for example a measure that has not been rendered). It does not use `_getClosestTick`, so a missing note is skipped, not replaced by a nearby one.
16
+
17
+ ## 3. What counts as "the selected measures"
18
+
19
+ **Finding**: `tracker.getSelectedMeasures()` collapses selections to one entry per measure *index* regardless of staff; the Select Voice rule needs staff-aware pairs because a multi-staff selection can cover measure 3 on staff 0 and staff 1 independently, and a voice may exist on one and not the other.
20
+
21
+ **Decision**: The pure functions work on unique `(staff, measure)` pairs taken from the current selections. Every note of the chosen voice in each pair's measure is selected (FR-004, FR-005); a measure that lacks the voice contributes nothing and is never given the voice (FR-007).
22
+
23
+ ## 4. The choice rule
24
+
25
+ **Finding**: Voices in a measure are contiguous (a measure with voice index 2 also has 0 and 1; `populateVoice` only appends).
26
+
27
+ **Decision**: Let `maxVoices` be the largest `voices.length` among the selected `(staff, measure)` pairs, capped at 4. `voiceChoices` returns `[]` when `maxVoices < 2` (FR-003) and `[0 .. maxVoices - 1]` otherwise. Every listed voice therefore exists in at least one selected measure (FR-002), and a "no notes" result is only possible if the voice's notes list is empty, handled by FR-008.
28
+
29
+ ## 5. No-op rule
30
+
31
+ **Decision**: If `getVoiceSelectors` returns no selectors, or none of them is currently mapped to a rendered note, `selectVoice` returns false and leaves `this.selections`, the pitch index, the modifier selection and the highlight untouched (FR-008).
32
+
33
+ ## 6. Active voice
34
+
35
+ **Finding**: Selecting a single note with `selectSuggestion` calls `selection.measure.setActiveVoice(selection.selector.voice)`, so the keyboard-entry voice follows the selection. `setActiveVoice` is a measure property that is serialized with the measure, but it is not recorded in undo and `selectSuggestion` already changes it on every click.
36
+
37
+ **Decision**: After a successful selection, call `measure.setActiveVoice(voice)` on each selected measure that has the voice, so the voice highlight and the keyboard entry agree with the selection. This is not an undoable edit (FR-009) and uses the same mechanism as clicking a note.
38
+
39
+ ## 7. Highlighting
40
+
41
+ **Finding**: With more than one selection the highlighter sorts `selections` (staff, measure, voice, tick), unions boxes that are on the same staff and line, and draws the union rectangles. A single voice's notes in a measure are non-contiguous in screen position only when interleaved with the other voice's notes, which is already how a multi-voice selection is drawn.
42
+
43
+ **Decision**: Reuse the existing highlight path (`deferHighlight`). Also refresh the local modifier list the way `selectSuggestion` does (`_createLocalModifiersList`) and reset the pitch index.
44
+
45
+ ## 8. Menu
46
+
47
+ **Finding**: Submenu items and the parent are filtered with `display` (`menu.vue`); the Copy Voices option already uses this pattern.
48
+
49
+ **Decision**: A Select Voice option whose `display` is `voiceChoices(...).length > 0` and a `subMenu` of four voice choices each displayed only when its index is in the list. It is placed after the Paste Voice option in the Edit menu. No keyboard shortcut (spec assumption).
50
+
51
+ ## 9. Existing Voices menu
52
+
53
+ **Finding**: The Voices menu's `selectVoiceMenuOption` calls `populateVoice`, which creates a missing voice, sets the active voice for the selected measures and (through `selectActiveVoice`) selects that voice's note.
54
+
55
+ **Decision**: Leave it unchanged (FR-011). Select Voice never calls `populateVoice` and never adds voices.