smoosic 2.0.2 → 2.0.3
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 +167 -74
- package/package.json +82 -77
- package/release/smoosic.js +171 -78
- 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/src/application/application.ts +464 -459
- package/src/common/promiseHelpers.ts +2 -2
- package/src/render/audio/samples.ts +117 -118
- package/src/render/sui/pageDivisions.ts +58 -0
- package/src/render/sui/renderState.ts +469 -464
- package/src/render/sui/scoreChangeState.ts +62 -0
- package/src/render/sui/scoreView.ts +30 -0
- package/src/render/sui/scoreViewOperations.ts +2555 -2380
- 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/vxNote.ts +3 -1
- package/src/smo/xform/copypaste.ts +304 -4
- package/src/smo/xform/selections.ts +68 -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/library.vue +3 -1
- package/src/ui/components/dialogs/unsavedChanges.vue +44 -0
- 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/chordChangeVue.ts +46 -46
- package/src/ui/dialogs/clefChange.ts +53 -53
- package/src/ui/dialogs/customTuplets.ts +95 -96
- package/src/ui/dialogs/customTupletsVue.ts +47 -47
- package/src/ui/dialogs/dialog.ts +627 -620
- package/src/ui/dialogs/durations.ts +34 -34
- package/src/ui/dialogs/dynamics.ts +140 -142
- package/src/ui/dialogs/factory.ts +198 -198
- package/src/ui/dialogs/fileDialogs.ts +245 -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 +111 -111
- 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/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 +40 -40
- 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/library.ts +110 -111
- package/src/ui/menus/edit.ts +100 -1
- package/src/ui/menus/file.ts +19 -3
- package/tests/pageDivisions.ts +156 -0
- package/tests/promiseHelpersUsage.ts +142 -0
- package/tests/scoreChangeState.ts +102 -0
- package/tests/selectVoice.ts +189 -0
- package/tests/voiceCopyPaste.ts +417 -0
|
@@ -1,2380 +1,2555 @@
|
|
|
1
|
-
// [Smoosic](https://github.com/AaronDavidNewman/Smoosic)
|
|
2
|
-
// Copyright (c) Aaron David Newman 2021.
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
|
|
34
|
-
import {
|
|
35
|
-
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
|
|
40
|
-
declare var
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
*
|
|
63
|
-
* @
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
partInfo.
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
this.
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
*
|
|
91
|
-
* @
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
let
|
|
96
|
-
|
|
97
|
-
const
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
textGroup.elements
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
this.
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
* @param
|
|
136
|
-
* @
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
const
|
|
141
|
-
const
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
return
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
//
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
//
|
|
177
|
-
//
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
partInfo.
|
|
182
|
-
|
|
183
|
-
displayPartInfo.
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
* @
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
const
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
const
|
|
204
|
-
const
|
|
205
|
-
score.
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
*
|
|
211
|
-
* @
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
* @
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
this.
|
|
235
|
-
this.
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
*
|
|
242
|
-
* @
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
const
|
|
248
|
-
const
|
|
249
|
-
const
|
|
250
|
-
|
|
251
|
-
this.
|
|
252
|
-
|
|
253
|
-
const
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
this.
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
this.
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
*
|
|
270
|
-
* @
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
this.
|
|
275
|
-
this.
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
sel.note.arpeggio =
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
sel.note.clefNote =
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
*
|
|
320
|
-
* @
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
*
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
*
|
|
355
|
-
*
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
const
|
|
378
|
-
SmoMeasure.defaultPitchForClef[
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
altSel!.note!.
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
*
|
|
404
|
-
*
|
|
405
|
-
*
|
|
406
|
-
* @
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
* @
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
equiv
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
* @
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
* @
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
equiv
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
SmoOperation.depopulateVoice(
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
*
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
*
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
SmoOperation.populateVoice(
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
this.
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
*
|
|
552
|
-
* @
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
this.
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
*
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
//
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
*
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
this.
|
|
602
|
-
|
|
603
|
-
this.
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
this.
|
|
610
|
-
this.
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
this.
|
|
617
|
-
this.
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
const
|
|
630
|
-
|
|
631
|
-
altTabStave
|
|
632
|
-
altTabStave.
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
this.
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
const
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
const
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
*
|
|
669
|
-
* @
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
let
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
}
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
const
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
const
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
*
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
const
|
|
756
|
-
const
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
this.updateTempoScore(measure,
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
selections
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
const
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
selections
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
SmoOperation.removeGraceNote(
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
grace.
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
this.
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
*
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
const
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
const
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
const
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
SmoOperation.toggleEnharmonic(
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
const
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
const
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
SmoOperation.toggleCourtesyAccidental(
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
*
|
|
940
|
-
*
|
|
941
|
-
*
|
|
942
|
-
*
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
const
|
|
948
|
-
const
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
*
|
|
972
|
-
* @
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
const
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
const
|
|
1043
|
-
SmoOperation.makeTuplet(
|
|
1044
|
-
this.
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
const
|
|
1055
|
-
SmoOperation.unmakeTuplet(
|
|
1056
|
-
this.
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
*
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
selections
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
SmoOperation.interval(
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
selections
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
note.pitches
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
selections
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
SmoOperation.toggleSlash(
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
selections
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
SmoOperation.toggleRest(
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
const
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
this.
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
selections
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
SmoOperation.unbeamSelections(
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
this.
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
SmoOperation.addKeySignature(this.
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
*
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
this.
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
const
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
SuiPiano.
|
|
1249
|
-
}
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
*
|
|
1256
|
-
* @
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
const
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
const
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
const
|
|
1292
|
-
SmoOperation.setPitch(
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
*
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
SmoOperation.setPitch(
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
this.
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
*
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
const
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
*
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
this.
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
}
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
this.
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
this.
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
this.
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
*
|
|
1595
|
-
* @
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
this.
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
const
|
|
1651
|
-
const
|
|
1652
|
-
const
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
return
|
|
1674
|
-
}
|
|
1675
|
-
/**
|
|
1676
|
-
*
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
this.
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
this.
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
*
|
|
1698
|
-
* @
|
|
1699
|
-
*/
|
|
1700
|
-
async
|
|
1701
|
-
this.
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
const
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
async
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
const
|
|
1749
|
-
|
|
1750
|
-
const
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
this.
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
this.
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
if (
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
this.
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
this.
|
|
1877
|
-
this.
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
this.
|
|
1888
|
-
this.
|
|
1889
|
-
this.renderer.
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
* @
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
this.
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
this.
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
}
|
|
1965
|
-
}
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
this.
|
|
1972
|
-
this.renderer.
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
*
|
|
1977
|
-
* @param
|
|
1978
|
-
* @returns
|
|
1979
|
-
*/
|
|
1980
|
-
async
|
|
1981
|
-
this.
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
}
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
this.
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
this.
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
this.
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
*
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
this.
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
this.
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
const
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
this.
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
if (
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
this.
|
|
2307
|
-
|
|
2308
|
-
}
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
*
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
this.tracker.
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
1
|
+
// [Smoosic](https://github.com/AaronDavidNewman/Smoosic)
|
|
2
|
+
// Copyright (c) Aaron David Newman 2021.
|
|
3
|
+
import { toRaw } from 'vue';
|
|
4
|
+
import { isFullSaveFormat } from './scoreChangeState';
|
|
5
|
+
import { SuiScoreView, updateStaffModifierFunc } from './scoreView';
|
|
6
|
+
import { SmoScore, engravingFontType } from '../../smo/data/score';
|
|
7
|
+
import { SmoSystemStaffParams, SmoSystemStaff } from '../../smo/data/systemStaff';
|
|
8
|
+
import { SmoPartInfo } from '../../smo/data/partInfo';
|
|
9
|
+
import { SmoMeasure } from '../../smo/data/measure';
|
|
10
|
+
import { SmoNote } from '../../smo/data/note';
|
|
11
|
+
import { KeyEvent, SvgBox, Pitch, PitchLetter, RemoveElementLike, ElementLike } from '../../smo/data/common';
|
|
12
|
+
import { SmoRenderConfiguration } from './configuration';
|
|
13
|
+
import { SmoSystemGroup, SmoPageLayout, SmoGlobalLayout, SmoLayoutManager, SmoAudioPlayerSettings,
|
|
14
|
+
SmoScorePreferences, SmoScoreInfo } from '../../smo/data/scoreModifiers';
|
|
15
|
+
import { SmoTextGroup } from '../../smo/data/scoreText';
|
|
16
|
+
import { SmoDynamicText, SmoNoteModifierBase, SmoGraceNote, SmoArticulation,
|
|
17
|
+
SmoOrnament, SmoLyric, SmoMicrotone, SmoArpeggio, SmoArpeggioType, SmoClefChange,
|
|
18
|
+
SmoTabNote} from '../../smo/data/noteModifiers';
|
|
19
|
+
import { SmoTempo, SmoVolta, SmoBarline, SmoRepeatSymbol,
|
|
20
|
+
SmoRehearsalMark, SmoMeasureFormat, SmoTimeSignature } from '../../smo/data/measureModifiers';
|
|
21
|
+
import { UndoBuffer } from '../../smo/xform/undo';
|
|
22
|
+
import {
|
|
23
|
+
SmoOperation, createStaffModifierType, MakeTupletOperation
|
|
24
|
+
} from '../../smo/xform/operations';
|
|
25
|
+
import { BatchSelectionOperation } from '../../smo/xform/operations';
|
|
26
|
+
import { smoSerialize } from '../../common/serializationHelpers';
|
|
27
|
+
import { FontInfo } from '../../common/vex';
|
|
28
|
+
import { SmoMusic } from '../../smo/data/music';
|
|
29
|
+
import { SuiOscillator } from '../audio/oscillator';
|
|
30
|
+
import { XmlToSmo } from '../../smo/mxml/xmlToSmo';
|
|
31
|
+
import { SuiAudioPlayer } from '../audio/player';
|
|
32
|
+
import { SuiXhrLoader } from '../../ui/fileio/xhrLoader';
|
|
33
|
+
import { SmoSelection, SmoSelector } from '../../smo/xform/selections';
|
|
34
|
+
import { StaffModifierBase,
|
|
35
|
+
SmoInstrument, SmoInstrumentParams, SmoStaffTextBracket, SmoTabStave } from '../../smo/data/staffModifiers';
|
|
36
|
+
import { SuiPiano } from './piano';
|
|
37
|
+
import { SvgHelpers } from './svgHelpers';
|
|
38
|
+
import { parseJsonText } from 'typescript';
|
|
39
|
+
import {NoteEntryCaret} from "./NoteEntryCaret";
|
|
40
|
+
declare var $: any;
|
|
41
|
+
declare var SmoConfig: SmoRenderConfiguration;
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* MVVM-like operations on the displayed score.
|
|
46
|
+
*
|
|
47
|
+
* All operations that can be performed on a 'live' score go through this
|
|
48
|
+
* module. It maps the score view to the actual score and makes sure the
|
|
49
|
+
* model and view stay in sync.
|
|
50
|
+
*
|
|
51
|
+
* Because this object operates on the current selections,
|
|
52
|
+
* all operations return promise so applications can wait for the
|
|
53
|
+
* operation to complete and update the selection list.
|
|
54
|
+
* @category SuiRender
|
|
55
|
+
*/
|
|
56
|
+
export class SuiScoreViewOperations extends SuiScoreView {
|
|
57
|
+
constructor(config: SmoRenderConfiguration, score: SmoScore, undoBuffer: UndoBuffer) {
|
|
58
|
+
super(config, score, undoBuffer);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Add a new text group to the score
|
|
63
|
+
* @param textGroup a new text group
|
|
64
|
+
* @returns
|
|
65
|
+
*/
|
|
66
|
+
async addTextGroup(textGroup: SmoTextGroup): Promise<void> {
|
|
67
|
+
const altNew = SmoTextGroup.deserializePreserveId(textGroup.serialize());
|
|
68
|
+
const isPartExposed = this.isPartExposed();
|
|
69
|
+
let selector = textGroup.selector ?? SmoSelector.default;
|
|
70
|
+
const partInfo = this.score.staves[0].partInfo;
|
|
71
|
+
const bufType = isPartExposed && partInfo.preserveTextGroups
|
|
72
|
+
? UndoBuffer.bufferTypes.PART_MODIFIER : UndoBuffer.bufferTypes.SCORE_MODIFIER;
|
|
73
|
+
if (bufType === UndoBuffer.bufferTypes.PART_MODIFIER) {
|
|
74
|
+
selector.staff = this.staffMap[0];
|
|
75
|
+
}
|
|
76
|
+
this.storeUndo.addBuffer('remove text group', bufType,
|
|
77
|
+
selector, textGroup, UndoBuffer.bufferSubtypes.ADD);
|
|
78
|
+
if (isPartExposed && partInfo.preserveTextGroups) {
|
|
79
|
+
this.score.staves[0].partInfo.updateTextGroup(textGroup, true);
|
|
80
|
+
const partInfo = this.storeScore.staves[this._getEquivalentStaff(0)].partInfo;
|
|
81
|
+
partInfo.updateTextGroup(altNew, true);
|
|
82
|
+
} else {
|
|
83
|
+
this.score.updateTextGroup(textGroup, true);
|
|
84
|
+
this.storeScore.updateTextGroup(altNew, true);
|
|
85
|
+
}
|
|
86
|
+
await this.renderer.rerenderTextGroups();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Remove the text group from the score
|
|
91
|
+
* @param textGroup
|
|
92
|
+
* @returns
|
|
93
|
+
*/
|
|
94
|
+
async removeTextGroup(textGroup: SmoTextGroup): Promise<void> {
|
|
95
|
+
let selector = textGroup.selector ?? SmoSelector.default;
|
|
96
|
+
let altSelector = JSON.parse(JSON.stringify(selector));
|
|
97
|
+
const partInfo = this.score.staves[0].partInfo;
|
|
98
|
+
const isPartExposed = this.isPartExposed();
|
|
99
|
+
const bufType = isPartExposed && partInfo.preserveTextGroups
|
|
100
|
+
? UndoBuffer.bufferTypes.PART_MODIFIER : UndoBuffer.bufferTypes.SCORE_MODIFIER;
|
|
101
|
+
let ogText = this.storeScore.textGroups.find((tg) => tg.attrs.id === textGroup.attrs.id);
|
|
102
|
+
if (isPartExposed && partInfo.preserveTextGroups) {
|
|
103
|
+
ogText = partInfo.textGroups.find((tg) => tg.attrs.id === textGroup.attrs.id);
|
|
104
|
+
}
|
|
105
|
+
if (bufType === UndoBuffer.bufferTypes.PART_MODIFIER) {
|
|
106
|
+
selector.staff = this.staffMap[0];
|
|
107
|
+
} else {
|
|
108
|
+
altSelector.staff = this.staffMap[selector.staff];
|
|
109
|
+
}
|
|
110
|
+
if (!ogText) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
// We undo buffer using the score location, not the group location
|
|
114
|
+
this.storeUndo.addBuffer('remove text group', bufType,
|
|
115
|
+
altSelector, ogText, UndoBuffer.bufferSubtypes.REMOVE);
|
|
116
|
+
const altGroup = SmoTextGroup.deserializePreserveId(textGroup.serialize());
|
|
117
|
+
if (altGroup.selector) {
|
|
118
|
+
altGroup.selector.staff = altSelector.staff;
|
|
119
|
+
}
|
|
120
|
+
textGroup.elements.forEach((el: ElementLike) => RemoveElementLike(el));
|
|
121
|
+
textGroup.elements = [];
|
|
122
|
+
if (isPartExposed && partInfo.preserveTextGroups) {
|
|
123
|
+
partInfo.updateTextGroup(textGroup, false);
|
|
124
|
+
this.storeScore.staves[this._getEquivalentStaff(0)].partInfo.updateTextGroup(altGroup, false);
|
|
125
|
+
} else {
|
|
126
|
+
this.score.updateTextGroup(textGroup, false);
|
|
127
|
+
this.storeScore.updateTextGroup(altGroup, false);
|
|
128
|
+
}
|
|
129
|
+
await this.renderer.rerenderTextGroups();
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* UPdate an existing text group. The original is passed in, because since TG not tied to a musical
|
|
134
|
+
* element, we need to find the one we're updating.
|
|
135
|
+
* @param oldVersion
|
|
136
|
+
* @param newVersion
|
|
137
|
+
* @returns
|
|
138
|
+
*/
|
|
139
|
+
async updateTextGroup(newVersion: SmoTextGroup): Promise<void> {
|
|
140
|
+
const selector = newVersion.selector ?? SmoSelector.default; // for score view
|
|
141
|
+
const altSelector = JSON.parse(JSON.stringify(selector)); // for full score
|
|
142
|
+
const isPartExposed = this.isPartExposed();
|
|
143
|
+
const partInfo = this.score.staves[0].partInfo;
|
|
144
|
+
|
|
145
|
+
// If this text was attached to a staff that is not in the part, ignore the update
|
|
146
|
+
if (newVersion.selector && newVersion.selector.staff >= this.score.staves.length) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
// Back up the original score text
|
|
150
|
+
let ogtg = this.storeScore.textGroups.find((tg) => tg.attrs.id === newVersion.attrs.id);
|
|
151
|
+
if (isPartExposed && partInfo.preserveTextGroups) {
|
|
152
|
+
ogtg = partInfo.textGroups.find((tg) => tg.attrs.id === newVersion.attrs.id);
|
|
153
|
+
}
|
|
154
|
+
if (!ogtg) {
|
|
155
|
+
// there is nothing to update, return.
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
if (ogtg) {
|
|
159
|
+
const bufType = isPartExposed && partInfo.preserveTextGroups
|
|
160
|
+
? UndoBuffer.bufferTypes.PART_MODIFIER : UndoBuffer.bufferTypes.SCORE_MODIFIER;
|
|
161
|
+
// if this is part text, make sure the undo buffer is associated with the part stave
|
|
162
|
+
// in the full score, so undo works properly
|
|
163
|
+
if (bufType === UndoBuffer.bufferTypes.PART_MODIFIER) {
|
|
164
|
+
altSelector.staff = this.staffMap[0];
|
|
165
|
+
} else {
|
|
166
|
+
altSelector.staff = this.staffMap[selector.staff];
|
|
167
|
+
}
|
|
168
|
+
this.storeUndo.addBuffer('modify text',
|
|
169
|
+
bufType, altSelector, ogtg, UndoBuffer.bufferSubtypes.UPDATE);
|
|
170
|
+
}
|
|
171
|
+
const altNew = SmoTextGroup.deserializePreserveId(newVersion.serialize());
|
|
172
|
+
if (altNew.selector) {
|
|
173
|
+
altNew.selector.staff = altSelector.staff;
|
|
174
|
+
}
|
|
175
|
+
this.score.updateTextGroup(newVersion, true);
|
|
176
|
+
// If this is part text and part-specific text is set,
|
|
177
|
+
// only set the partInfo for the stored score, but don't add to
|
|
178
|
+
// global text.
|
|
179
|
+
if (isPartExposed) {
|
|
180
|
+
// Update the full score copy for this part
|
|
181
|
+
const partInfo = this.storeScore.staves[altSelector.staff].partInfo;
|
|
182
|
+
partInfo.updateTextGroup(altNew, true);
|
|
183
|
+
const displayPartInfo = this.score.staves[0].partInfo;
|
|
184
|
+
displayPartInfo.updateTextGroup(newVersion, true);
|
|
185
|
+
} else {
|
|
186
|
+
this.storeScore.updateTextGroup(altNew, true);
|
|
187
|
+
}
|
|
188
|
+
// TODO: only render the one TG.
|
|
189
|
+
await this.renderer.rerenderTextGroups();
|
|
190
|
+
// return this.renderer.updatePromise();
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* load an mxml score remotely, return a promise that
|
|
194
|
+
* completes when the file is loaded
|
|
195
|
+
* @param url where to find the xml file
|
|
196
|
+
* @returns
|
|
197
|
+
*/
|
|
198
|
+
async loadRemoteXml(url: string): Promise<any> {
|
|
199
|
+
const req = new SuiXhrLoader(url);
|
|
200
|
+
const self = this;
|
|
201
|
+
// Shouldn't we return promise of actually displaying the score?
|
|
202
|
+
await req.loadAsync();
|
|
203
|
+
const parser = new DOMParser();
|
|
204
|
+
const xml = parser.parseFromString(req.value, 'text/xml');
|
|
205
|
+
const score = XmlToSmo.convert(xml);
|
|
206
|
+
score.layoutManager!.zoomToWidth($('body').width());
|
|
207
|
+
await self.changeScore(score);
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* load a remote score in SMO format
|
|
211
|
+
* @param url url to find the score
|
|
212
|
+
* @returns
|
|
213
|
+
*/
|
|
214
|
+
async loadRemoteJson(url: string) : Promise<any> {
|
|
215
|
+
const req = new SuiXhrLoader(url);
|
|
216
|
+
await req.loadAsync();
|
|
217
|
+
const score = SmoScore.deserialize(req.value);
|
|
218
|
+
await this.changeScore(score);
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Load a remote score, return promise when it's been loaded
|
|
222
|
+
* from afar.
|
|
223
|
+
* @param pref
|
|
224
|
+
* @returns
|
|
225
|
+
*/
|
|
226
|
+
async loadRemoteScore(url: string): Promise<any> {
|
|
227
|
+
if (url.endsWith('xml') || url.endsWith('mxl')) {
|
|
228
|
+
return this.loadRemoteXml(url);
|
|
229
|
+
} else {
|
|
230
|
+
return this.loadRemoteJson(url);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
async updateAudioSettings(pref: SmoAudioPlayerSettings) {
|
|
234
|
+
this._undoScorePreferences('Update preferences');
|
|
235
|
+
this.score.audioSettings = pref;
|
|
236
|
+
this.storeScore.audioSettings = new SmoAudioPlayerSettings(pref);
|
|
237
|
+
// No rendering to be done
|
|
238
|
+
return this.renderer.updatePromise();
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Global settings that control how the score editor behaves
|
|
242
|
+
* @param pref
|
|
243
|
+
* @returns
|
|
244
|
+
*/
|
|
245
|
+
async updateScorePreferences(pref: SmoScorePreferences): Promise<void> {
|
|
246
|
+
this._undoScorePreferences('Update preferences');
|
|
247
|
+
const oldXpose = this.score.preferences.transposingScore;
|
|
248
|
+
const curXpose = pref.transposingScore;
|
|
249
|
+
const currentLayout = this.score.layoutManager?.getGlobalLayout();
|
|
250
|
+
const oldDisplayMode = currentLayout ? currentLayout.displayMode : 'vertical';
|
|
251
|
+
this.score.updateScorePreferences(new SmoScorePreferences(pref));
|
|
252
|
+
this.storeScore.updateScorePreferences(new SmoScorePreferences(pref));
|
|
253
|
+
const newLayout = this.score.layoutManager?.getGlobalLayout();
|
|
254
|
+
const displayMode = newLayout ? newLayout.displayMode : 'vertical';
|
|
255
|
+
if (oldDisplayMode !== displayMode) {
|
|
256
|
+
this.renderer.setViewport();
|
|
257
|
+
}
|
|
258
|
+
if (curXpose === false && oldXpose === true) {
|
|
259
|
+
this.score.setNonTransposing();
|
|
260
|
+
this.storeScore.setNonTransposing();
|
|
261
|
+
} else if (curXpose === true && oldXpose === false) {
|
|
262
|
+
this.score.setTransposing();
|
|
263
|
+
this.storeScore.setTransposing();
|
|
264
|
+
}
|
|
265
|
+
this.renderer.setDirty();
|
|
266
|
+
return this.renderer.updatePromise();
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Update information about the score, composer etc.
|
|
270
|
+
* @param scoreInfo
|
|
271
|
+
* @returns
|
|
272
|
+
*/
|
|
273
|
+
async updateScoreInfo(scoreInfo: SmoScoreInfo): Promise<void> {
|
|
274
|
+
this._undoScorePreferences('Update preferences');
|
|
275
|
+
this.score.scoreInfo = scoreInfo;
|
|
276
|
+
this.storeScore.scoreInfo = JSON.parse(JSON.stringify(scoreInfo));
|
|
277
|
+
this.refreshScoreName();
|
|
278
|
+
return this.renderer.updatePromise()
|
|
279
|
+
}
|
|
280
|
+
async addRemoveArpeggio(code: SmoArpeggioType) {
|
|
281
|
+
await this.modifyCurrentSelections('add/remove addRemoveArpeggio',
|
|
282
|
+
(score, selections) => {
|
|
283
|
+
selections.forEach((sel) => {
|
|
284
|
+
if (sel.note) {
|
|
285
|
+
if (code === 'none') {
|
|
286
|
+
sel.note.arpeggio = undefined;
|
|
287
|
+
} else {
|
|
288
|
+
sel.note.arpeggio = new SmoArpeggio({ type: code });
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* A clef change mid-measure (clefNote)
|
|
296
|
+
* @param clef
|
|
297
|
+
*/
|
|
298
|
+
async addRemoveClefChange(clef: SmoClefChange) {
|
|
299
|
+
await this.modifyCurrentSelections('add/remove addRemoveClefChange',
|
|
300
|
+
(score, selections) => {
|
|
301
|
+
selections.forEach((sel) => {
|
|
302
|
+
const measureClef = sel.measure.clef;
|
|
303
|
+
if (sel.note) {
|
|
304
|
+
if (measureClef === clef.clef) {
|
|
305
|
+
sel.note.clefNote = null;
|
|
306
|
+
} else {
|
|
307
|
+
sel.note.clefNote = clef;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
});
|
|
312
|
+
// Make sure all the notes in the measure after the change are updated.
|
|
313
|
+
// We only need to do this for the displayed score, not the storeScore.
|
|
314
|
+
SmoSelection.getMeasureList(this.tracker.selections).forEach((ms) => {
|
|
315
|
+
ms.measure.updateClefChangeNotes();
|
|
316
|
+
})
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Modify the dynamics assoicated with the specific selection
|
|
320
|
+
* @param selection
|
|
321
|
+
* @param dynamic
|
|
322
|
+
* @returns
|
|
323
|
+
*/
|
|
324
|
+
async addDynamic(selection: SmoSelection, dynamic: SmoDynamicText): Promise<void> {
|
|
325
|
+
await this.modifySelection('add dynamic', selection, (score, selections) => {
|
|
326
|
+
SmoOperation.addDynamic(selections[0], dynamic);
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Remove dynamics from the current selection
|
|
332
|
+
* @param dynamic
|
|
333
|
+
* @returns
|
|
334
|
+
*/
|
|
335
|
+
async removeDynamic(dynamic: SmoDynamicText): Promise<void> {
|
|
336
|
+
const measures = SmoSelection.getMeasureList(this.tracker.selections);
|
|
337
|
+
for (let j = 0; j < this.tracker.selections.length; ++j) {
|
|
338
|
+
const selection = this.tracker.selections[j];
|
|
339
|
+
if (selection) {
|
|
340
|
+
const equiv = this._getEquivalentSelection(selection);
|
|
341
|
+
if (equiv?.note && selection.note) {
|
|
342
|
+
const altModifiers = equiv.note.getModifiers('SmoDynamicText');
|
|
343
|
+
SmoOperation.removeDynamic(selection, dynamic);
|
|
344
|
+
if (altModifiers.length) {
|
|
345
|
+
SmoOperation.removeDynamic(equiv, altModifiers[0] as SmoDynamicText);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
this._renderChangedMeasures(measures);
|
|
351
|
+
await this.renderer.updatePromise()
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* we never really delete a note, but we will convert it into a rest and if it's
|
|
355
|
+
* already a rest we will try to hide it.
|
|
356
|
+
* Operates on current selections
|
|
357
|
+
* */
|
|
358
|
+
async deleteNote(): Promise<void> {
|
|
359
|
+
const measureSelections = this.undoTrackerMeasureSelections('delete note');
|
|
360
|
+
this.tracker.selections.forEach((sel) => {
|
|
361
|
+
if (sel.note) {
|
|
362
|
+
|
|
363
|
+
const altSel = this._getEquivalentSelection(sel);
|
|
364
|
+
|
|
365
|
+
// If this is a chord and a specific pitch is selected, just remove that pitch
|
|
366
|
+
const pitchIndex = this.tracker.getPitchIndex();
|
|
367
|
+
if (sel.note.pitches.length > 1 && pitchIndex >= 0 && pitchIndex < sel.note.pitches.length) {
|
|
368
|
+
sel.note.pitches.splice(pitchIndex, 1);
|
|
369
|
+
altSel!.note!.pitches.splice(pitchIndex, 1);
|
|
370
|
+
SmoNote.sortPitches(sel.note);
|
|
371
|
+
SmoNote.sortPitches(altSel!.note! as SmoNote);
|
|
372
|
+
this.tracker.clearPitchIndex();
|
|
373
|
+
return; // skip rest/hide logic for this selection
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
// set the pitch to be a good position for the rest
|
|
377
|
+
const pitch = JSON.parse(JSON.stringify(
|
|
378
|
+
SmoMeasure.defaultPitchForClef[sel.measure.clef]));
|
|
379
|
+
const altPitch = JSON.parse(JSON.stringify(
|
|
380
|
+
SmoMeasure.defaultPitchForClef[altSel!.measure.clef]));
|
|
381
|
+
sel.note.pitches = [pitch];
|
|
382
|
+
altSel!.note!.pitches = [altPitch];
|
|
383
|
+
|
|
384
|
+
// If the note is a note, make it into a rest. If the note is a rest already,
|
|
385
|
+
// make it invisible. If it is invisible already, make it back into a rest.
|
|
386
|
+
if (sel.note.isRest() && !sel.note.isHidden()) {
|
|
387
|
+
sel.note.makeHidden(true);
|
|
388
|
+
altSel!.note!.makeHidden(true);
|
|
389
|
+
} else {
|
|
390
|
+
sel.note.clearArticulations();
|
|
391
|
+
sel.note.makeRest();
|
|
392
|
+
altSel!.note!.makeRest();
|
|
393
|
+
altSel!.note!.clearArticulations();
|
|
394
|
+
sel.note.makeHidden(false);
|
|
395
|
+
altSel!.note!.makeHidden(false);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
});
|
|
399
|
+
this._renderChangedMeasures(measureSelections);
|
|
400
|
+
await this.renderer.updatePromise()
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* The lyric editor moves around, so we can't depend on the tracker for the
|
|
404
|
+
* correct selection. We get it directly from the editor.
|
|
405
|
+
*
|
|
406
|
+
* @param selector - the selector of the note with the lyric to remove
|
|
407
|
+
* @param lyric - a copy of the lyric to remove. We use the verse, parser to identify it
|
|
408
|
+
* @returns render promise
|
|
409
|
+
*/
|
|
410
|
+
async removeLyric(selector: SmoSelector, lyric: SmoLyric): Promise<void> {
|
|
411
|
+
const selection = SmoSelection.noteFromSelector(this.score, selector);
|
|
412
|
+
if (selection === null) {
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
this._undoSelection('remove lyric', selection);
|
|
416
|
+
selection.note!.removeLyric(lyric);
|
|
417
|
+
const equiv = this._getEquivalentSelection(selection);
|
|
418
|
+
const storeLyric = equiv!.note!.getLyricForVerse(lyric.verse, lyric.parser);
|
|
419
|
+
if (typeof (storeLyric) !== 'undefined') {
|
|
420
|
+
equiv!.note!.removeLyric(lyric);
|
|
421
|
+
}
|
|
422
|
+
this.renderer.addToReplaceQueue(selection);
|
|
423
|
+
lyric.deleted = true;
|
|
424
|
+
await this.renderer.updatePromise();
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* @param selector where to add or update the lyric
|
|
429
|
+
* @param lyric a copy of the lyric to remove
|
|
430
|
+
* @returns
|
|
431
|
+
*/
|
|
432
|
+
async addOrUpdateLyric(selector: SmoSelector, lyric: SmoLyric): Promise<void> {
|
|
433
|
+
const selection = SmoSelection.noteFromSelector(this.score, selector);
|
|
434
|
+
if (selection === null) {
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
this._undoSelection('update lyric', selection);
|
|
438
|
+
selection.note!.addLyric(lyric);
|
|
439
|
+
const equiv = this._getEquivalentSelection(selection);
|
|
440
|
+
const altLyric = SmoNoteModifierBase.deserialize(lyric.serialize() as any) as SmoLyric;
|
|
441
|
+
equiv!.note!.addLyric(altLyric);
|
|
442
|
+
this.renderer.addToReplaceQueue(selection);
|
|
443
|
+
await this.renderer.updatePromise();
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* @param selector the selector of the note with the annotation to remove
|
|
448
|
+
* @param annotation a copy of the annotation to remove. We use the verse, parser to identify it
|
|
449
|
+
* @returns render promise
|
|
450
|
+
*/
|
|
451
|
+
async removeAnnotation(selector: SmoSelector, annotation: SmoLyric): Promise<void> {
|
|
452
|
+
const selection = SmoSelection.noteFromSelector(this.score, selector);
|
|
453
|
+
if (selection === null) {
|
|
454
|
+
return;
|
|
455
|
+
}
|
|
456
|
+
this._undoSelection('remove annotation', selection);
|
|
457
|
+
selection.note!.removeAnnotations(annotation);
|
|
458
|
+
const equiv = this._getEquivalentSelection(selection);
|
|
459
|
+
const storeAnnotation = equiv!.note!.getLyricForVerse(annotation.verse, annotation.parser);
|
|
460
|
+
if (typeof (storeAnnotation) !== 'undefined') {
|
|
461
|
+
equiv!.note!.removeAnnotations(annotation);
|
|
462
|
+
}
|
|
463
|
+
this.renderer.addToReplaceQueue(selection);
|
|
464
|
+
annotation.deleted = true;
|
|
465
|
+
await this.renderer.updatePromise();
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* @param selector where to add or update the annotation
|
|
470
|
+
* @param annotation a copy of the annotation to add/update
|
|
471
|
+
* @returns
|
|
472
|
+
*/
|
|
473
|
+
async addOrUpdateAnnotation(selector: SmoSelector, annotation: SmoLyric): Promise<void> {
|
|
474
|
+
const selection = SmoSelection.noteFromSelector(this.score, selector);
|
|
475
|
+
if (selection === null) {
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
this._undoSelection('update annotation', selection);
|
|
479
|
+
selection.note!.addAnnotation(annotation);
|
|
480
|
+
const equiv = this._getEquivalentSelection(selection);
|
|
481
|
+
const altAnnotation = SmoNoteModifierBase.deserialize(annotation.serialize() as any) as SmoLyric;
|
|
482
|
+
equiv!.note!.addAnnotation(altAnnotation);
|
|
483
|
+
this.renderer.addToReplaceQueue(selection);
|
|
484
|
+
await this.renderer.updatePromise();
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* Delete all the notes for the currently selected voice
|
|
489
|
+
* @returns
|
|
490
|
+
*/
|
|
491
|
+
async depopulateVoice(): Promise<void> {
|
|
492
|
+
const measureSelections = this.undoTrackerMeasureSelections('depopulate voice');
|
|
493
|
+
measureSelections.forEach((selection) => {
|
|
494
|
+
const ix = selection.measure.getActiveVoice();
|
|
495
|
+
if (ix !== 0) {
|
|
496
|
+
SmoOperation.depopulateVoice(selection, ix);
|
|
497
|
+
const equiv = this._getEquivalentSelection(selection);
|
|
498
|
+
SmoOperation.depopulateVoice(equiv!, ix);
|
|
499
|
+
}
|
|
500
|
+
});
|
|
501
|
+
SmoOperation.setActiveVoice(this.score, 0);
|
|
502
|
+
this._renderChangedMeasures(measureSelections);
|
|
503
|
+
await this.renderer.updatePromise();
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* Change the active voice in a multi-voice measure.
|
|
507
|
+
* @param index
|
|
508
|
+
* @returns
|
|
509
|
+
*/
|
|
510
|
+
_changeActiveVoice(index: number): SmoSelection[] {
|
|
511
|
+
const measuresToAdd: SmoSelection[] = [];
|
|
512
|
+
const measureSelections = SmoSelection.getMeasureList(this.tracker.selections);
|
|
513
|
+
measureSelections.forEach((measureSelection) => {
|
|
514
|
+
if (index === measureSelection.measure.voices.length) {
|
|
515
|
+
measuresToAdd.push(measureSelection);
|
|
516
|
+
}
|
|
517
|
+
});
|
|
518
|
+
return measuresToAdd;
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* Populate a new voice with default notes
|
|
522
|
+
* @param index the voice to populate
|
|
523
|
+
* @returns
|
|
524
|
+
*/
|
|
525
|
+
async populateVoice(index: number): Promise<void> {
|
|
526
|
+
const measuresToAdd = this._changeActiveVoice(index);
|
|
527
|
+
if (measuresToAdd.length === 0) {
|
|
528
|
+
SmoOperation.setActiveVoice(this.score, index);
|
|
529
|
+
this.tracker.selectActiveVoice();
|
|
530
|
+
return this.renderer.updatePromise();
|
|
531
|
+
}
|
|
532
|
+
measuresToAdd.forEach((selection) => {
|
|
533
|
+
this._undoSelection('popualteVoice', selection);
|
|
534
|
+
SmoOperation.populateVoice(selection, index);
|
|
535
|
+
const equiv = this._getEquivalentSelection(selection);
|
|
536
|
+
SmoOperation.populateVoice(equiv!, index);
|
|
537
|
+
});
|
|
538
|
+
SmoOperation.setActiveVoice(this.score, index);
|
|
539
|
+
this._renderChangedMeasures(measuresToAdd);
|
|
540
|
+
await this.renderer.updatePromise();
|
|
541
|
+
this.tracker.selectActiveVoice();
|
|
542
|
+
}
|
|
543
|
+
async swapVoices(voice1: number, voice2: number): Promise<void> {
|
|
544
|
+
const selections = this.tracker.getSelectedMeasures();
|
|
545
|
+
const altSelections = this._getEquivalentSelections(selections);
|
|
546
|
+
SmoOperation.swapVoice(selections, voice1, voice2);
|
|
547
|
+
SmoOperation.swapVoice(altSelections, voice1, voice2);
|
|
548
|
+
this._renderChangedMeasures(selections);
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* Assign an instrument to a set of measures
|
|
552
|
+
* @param instrument the instrument to assign to the selections
|
|
553
|
+
* @param selections
|
|
554
|
+
* @returns
|
|
555
|
+
*/
|
|
556
|
+
async changeInstrument(instrument: SmoInstrument, selections: SmoSelection[]): Promise<void> {
|
|
557
|
+
if (typeof (selections) === 'undefined') {
|
|
558
|
+
selections = this.tracker.selections;
|
|
559
|
+
}
|
|
560
|
+
this._undoSelections('change instrument', selections);
|
|
561
|
+
const altSelections = this._getEquivalentSelections(selections);
|
|
562
|
+
SmoOperation.changeInstrument(instrument, this.score, selections);
|
|
563
|
+
SmoOperation.changeInstrument(instrument, this.storeScore, altSelections);
|
|
564
|
+
this._renderChangedMeasures(selections);
|
|
565
|
+
await this.renderer.updatePromise();
|
|
566
|
+
}
|
|
567
|
+
/**
|
|
568
|
+
* Set the time signature for a selection
|
|
569
|
+
* @param timeSignature actual time signature
|
|
570
|
+
*/
|
|
571
|
+
async setTimeSignature(timeSignature: SmoTimeSignature): Promise<void> {
|
|
572
|
+
this._undoScore('Set time signature');
|
|
573
|
+
const selections = this.tracker.selections;
|
|
574
|
+
const altSelections = this._getEquivalentSelections(selections);
|
|
575
|
+
SmoOperation.setTimeSignature(this.score, selections, timeSignature);
|
|
576
|
+
SmoOperation.setTimeSignature(this.storeScore, altSelections, timeSignature);
|
|
577
|
+
this._renderChangedMeasures(SmoSelection.getMeasureList(this.tracker.selections));
|
|
578
|
+
return this.renderer.updatePromise();
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* Move selected staff up or down in the score.
|
|
582
|
+
* @param index direction to move
|
|
583
|
+
* @returns
|
|
584
|
+
*/
|
|
585
|
+
async moveStaffUpDown(index: number): Promise<void> {
|
|
586
|
+
this._undoScore('re-order staves');
|
|
587
|
+
// Get staff to move
|
|
588
|
+
const selection = this._getEquivalentSelection(this.tracker.selections[0]);
|
|
589
|
+
// Make the move in the model, and reset the view so we can see the new
|
|
590
|
+
// arrangement
|
|
591
|
+
SmoOperation.moveStaffUpDown(this.storeScore, selection!, index);
|
|
592
|
+
this.viewAll();
|
|
593
|
+
await this.renderer.updatePromise();
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* Update the staff group for a score, which determines how the staves
|
|
597
|
+
* are justified and bracketed
|
|
598
|
+
* @param staffGroup
|
|
599
|
+
*/
|
|
600
|
+
async addOrUpdateStaffGroup(staffGroup: SmoSystemGroup): Promise<void> {
|
|
601
|
+
this._undoScore('group staves');
|
|
602
|
+
// Assume that the view is now set to full score
|
|
603
|
+
this.score.addOrReplaceSystemGroup(staffGroup);
|
|
604
|
+
this.storeScore.addOrReplaceSystemGroup(staffGroup);
|
|
605
|
+
this.renderer.setDirty();
|
|
606
|
+
await this.renderer.updatePromise();
|
|
607
|
+
}
|
|
608
|
+
async removeStaffGroup(staffGroup: SmoSystemGroup):Promise<void> {
|
|
609
|
+
this._undoScore('ungroup staves');
|
|
610
|
+
this.score.removeSystemGroup(staffGroup);
|
|
611
|
+
this.storeScore.removeSystemGroup(staffGroup);
|
|
612
|
+
this.renderer.setDirty();
|
|
613
|
+
await this.renderer.updatePromise();
|
|
614
|
+
}
|
|
615
|
+
async clearSystemGroups(): Promise<void>{
|
|
616
|
+
this._undoScore('clear staff groups');
|
|
617
|
+
this.score.clearSystemGroups();
|
|
618
|
+
this.storeScore.clearSystemGroups();
|
|
619
|
+
this.renderer.setDirty();
|
|
620
|
+
await this.renderer.updatePromise();
|
|
621
|
+
}
|
|
622
|
+
async updateTabStave(tabStave: SmoTabStave) {
|
|
623
|
+
const selections = SmoSelection.getMeasuresBetween(this.score, tabStave.startSelector, tabStave.endSelector);
|
|
624
|
+
const altSelections = this._getEquivalentSelections(selections);
|
|
625
|
+
if (selections.length === 0) {
|
|
626
|
+
return;
|
|
627
|
+
}
|
|
628
|
+
this._undoSelections('updateTabStave', selections);
|
|
629
|
+
const staff: number = selections[0].selector.staff;
|
|
630
|
+
const altStaff = altSelections[0].selector.staff;
|
|
631
|
+
const altTabStave = new SmoTabStave(tabStave.serialize());
|
|
632
|
+
altTabStave.startSelector.staff = altStaff;
|
|
633
|
+
altTabStave.endSelector.staff = altStaff;
|
|
634
|
+
altTabStave.attrs.id = tabStave.attrs.id;
|
|
635
|
+
this.score.staves[staff].updateTabStave(tabStave);
|
|
636
|
+
this.storeScore.staves[altStaff].updateTabStave(altTabStave);
|
|
637
|
+
this._renderChangedMeasures(SmoSelection.getMeasureList(this.tracker.selections));
|
|
638
|
+
await this.renderer.updatePromise();
|
|
639
|
+
}
|
|
640
|
+
async removeTabStave() {
|
|
641
|
+
const selections = this.tracker.selections;
|
|
642
|
+
const altSelections = this._getEquivalentSelections(selections);
|
|
643
|
+
if (selections.length === 0) {
|
|
644
|
+
return;
|
|
645
|
+
}
|
|
646
|
+
this._undoSelections('updateTabStave', selections);
|
|
647
|
+
const stavesToRemove: SmoTabStave[] = [];
|
|
648
|
+
const altStavesToRemove: SmoTabStave[] = [];
|
|
649
|
+
const added: Record<string, SmoTabStave> = {};
|
|
650
|
+
selections.forEach((sel, ix) => {
|
|
651
|
+
const altSel = altSelections[ix];
|
|
652
|
+
const tabStave = sel.staff.getTabStaveForMeasure(sel.selector);
|
|
653
|
+
const altTabStave = altSel.staff.getTabStaveForMeasure(altSel.selector);
|
|
654
|
+
if (tabStave && altTabStave) {
|
|
655
|
+
if (!added[tabStave.attrs.id]) {
|
|
656
|
+
added[tabStave.attrs.id] = tabStave;
|
|
657
|
+
stavesToRemove.push(tabStave);
|
|
658
|
+
altStavesToRemove.push(altTabStave);
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
});
|
|
662
|
+
selections[0].staff.removeTabStaves(stavesToRemove);
|
|
663
|
+
altSelections[0].staff.removeTabStaves(altStavesToRemove);
|
|
664
|
+
this._renderChangedMeasures(SmoSelection.getMeasureList(this.tracker.selections));
|
|
665
|
+
await this.renderer.updatePromise();
|
|
666
|
+
}
|
|
667
|
+
/**
|
|
668
|
+
* Update tempo for all or part of the score
|
|
669
|
+
* @param measure the measure with the tempo. Tempo is measure-wide parameter
|
|
670
|
+
* @param scoreMode if true, update whole score. Else selections
|
|
671
|
+
* @returns
|
|
672
|
+
*/
|
|
673
|
+
async updateTempoScore(measure: SmoMeasure, tempo: SmoTempo, scoreMode: boolean, selectionMode: boolean): Promise<void> {
|
|
674
|
+
let measureIndex = 0;
|
|
675
|
+
const originalTempo = new SmoTempo(measure.tempo);
|
|
676
|
+
this._undoColumn('update tempo', measure.measureNumber.measureIndex);
|
|
677
|
+
let startMeasure = measure.measureNumber.measureIndex;
|
|
678
|
+
let endMeasure = this.score.staves[0].measures.length;
|
|
679
|
+
let displayed = false;
|
|
680
|
+
if (selectionMode) {
|
|
681
|
+
const endSel = this.tracker.getExtremeSelection(1);
|
|
682
|
+
if (endSel.selector.measure > startMeasure) {
|
|
683
|
+
endMeasure = endSel.selector.measure;
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
// If we are only changing the position of the text, it only affects the tempo measure.
|
|
687
|
+
if (SmoTempo.eq(originalTempo, tempo) && tempo.yOffset !== originalTempo.yOffset && endMeasure > startMeasure) {
|
|
688
|
+
endMeasure = startMeasure + 1;
|
|
689
|
+
}
|
|
690
|
+
for (measureIndex = startMeasure; measureIndex < endMeasure; ++measureIndex) {
|
|
691
|
+
if (!scoreMode && !selectionMode) {
|
|
692
|
+
// If not whole score or selections, change until the tempo doesn't match previous measure's tempo (next tempo change)
|
|
693
|
+
const compMeasure = this.score.staves[0].measures[measureIndex];
|
|
694
|
+
if (SmoTempo.eq(originalTempo, compMeasure.tempo) || displayed === false) {
|
|
695
|
+
const sel = SmoSelection.measureSelection(this.score, 0, measureIndex);
|
|
696
|
+
const altSel = SmoSelection.measureSelection(this.storeScore, 0, measureIndex);
|
|
697
|
+
if (sel && sel.measure.tempo.display && !displayed) {
|
|
698
|
+
this.renderer.addToReplaceQueue(sel);
|
|
699
|
+
displayed = true;
|
|
700
|
+
}
|
|
701
|
+
if (sel) {
|
|
702
|
+
SmoOperation.addTempo(this.score, sel, tempo);
|
|
703
|
+
}
|
|
704
|
+
if (altSel) {
|
|
705
|
+
SmoOperation.addTempo(this.storeScore, altSel, tempo);
|
|
706
|
+
}
|
|
707
|
+
} else {
|
|
708
|
+
break;
|
|
709
|
+
}
|
|
710
|
+
} else {
|
|
711
|
+
const sel = SmoSelection.measureSelection(this.score, 0, measureIndex);
|
|
712
|
+
const altSel = SmoSelection.measureSelection(this.storeScore, 0, measureIndex);
|
|
713
|
+
if (sel) {
|
|
714
|
+
SmoOperation.addTempo(this.score, sel, tempo);
|
|
715
|
+
if (!displayed) {
|
|
716
|
+
this.renderer.addToReplaceQueue(sel);
|
|
717
|
+
displayed = true;
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
if (altSel) {
|
|
721
|
+
SmoOperation.addTempo(this.storeScore, altSel, tempo);
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
await this.renderer.updatePromise();
|
|
726
|
+
}
|
|
727
|
+
async updateTabNote(tabNote: SmoTabNote) {
|
|
728
|
+
const selections = SmoSelection.getMeasuresBetween(this.score,
|
|
729
|
+
this.tracker.getExtremeSelection(-1).selector, this.tracker.getExtremeSelection(1).selector);
|
|
730
|
+
const altSelections = this._getEquivalentSelections(selections);
|
|
731
|
+
this._undoSelections('updateTabNote', selections);
|
|
732
|
+
SmoOperation.updateTabNote(selections, tabNote);
|
|
733
|
+
SmoOperation.updateTabNote(altSelections, tabNote);
|
|
734
|
+
this.renderer.addToReplaceQueue(selections);
|
|
735
|
+
await this.renderer.updatePromise();
|
|
736
|
+
}
|
|
737
|
+
async removeTabNote() {
|
|
738
|
+
const selections = SmoSelection.getMeasuresBetween(this.score,
|
|
739
|
+
this.tracker.getExtremeSelection(-1).selector, this.tracker.getExtremeSelection(1).selector);
|
|
740
|
+
const altSelections = this._getEquivalentSelections(selections);
|
|
741
|
+
this._undoSelections('updateTabNote', selections);
|
|
742
|
+
SmoOperation.removeTabNote(selections);
|
|
743
|
+
SmoOperation.removeTabNote(altSelections);
|
|
744
|
+
this.renderer.addToReplaceQueue(selections);
|
|
745
|
+
await this.renderer.updatePromise();
|
|
746
|
+
}
|
|
747
|
+
/**
|
|
748
|
+
* 'remove' tempo, which means either setting the bars to the
|
|
749
|
+
* default tempo, or the previously-set tempo.
|
|
750
|
+
* @param scoreMode whether to reset entire score
|
|
751
|
+
*/
|
|
752
|
+
async removeTempo(measure: SmoMeasure, tempo: SmoTempo, scoreMode: boolean, selectionMode: boolean): Promise<void> {
|
|
753
|
+
const startSelection = this.tracker.selections[0];
|
|
754
|
+
if (startSelection.selector.measure > 0) {
|
|
755
|
+
const measureIx = startSelection.selector.measure - 1;
|
|
756
|
+
const target = startSelection.staff.measures[measureIx];
|
|
757
|
+
const tempo = target.getTempo();
|
|
758
|
+
const newTempo = new SmoTempo(tempo);
|
|
759
|
+
newTempo.display = false;
|
|
760
|
+
this.updateTempoScore(measure, newTempo, scoreMode, selectionMode);
|
|
761
|
+
} else {
|
|
762
|
+
this.updateTempoScore(measure, new SmoTempo(SmoTempo.defaults), scoreMode, selectionMode);
|
|
763
|
+
}
|
|
764
|
+
await this.renderer.updatePromise();
|
|
765
|
+
}
|
|
766
|
+
/**
|
|
767
|
+
* Add a grace note to the selected real notes.
|
|
768
|
+
*/
|
|
769
|
+
async addGraceNote(): Promise<void> {
|
|
770
|
+
const selections = this.tracker.selections;
|
|
771
|
+
const measureSelections = this.undoTrackerMeasureSelections('add grace note');
|
|
772
|
+
selections.forEach((selection) => {
|
|
773
|
+
const index = selection.note!.getGraceNotes().length;
|
|
774
|
+
const pitches = JSON.parse(JSON.stringify(selection.note!.pitches));
|
|
775
|
+
const grace = new SmoGraceNote({
|
|
776
|
+
pitches, ticks:
|
|
777
|
+
{ numerator: 2048, denominator: 1, remainder: 0 }
|
|
778
|
+
});
|
|
779
|
+
SmoOperation.addGraceNote(selection, grace, index);
|
|
780
|
+
|
|
781
|
+
const altPitches = JSON.parse(JSON.stringify(selection.note!.pitches));
|
|
782
|
+
const altGrace = new SmoGraceNote({
|
|
783
|
+
pitches: altPitches, ticks:
|
|
784
|
+
{ numerator: 2048, denominator: 1, remainder: 0 }
|
|
785
|
+
});
|
|
786
|
+
altGrace.attrs.id = grace.attrs.id;
|
|
787
|
+
const altSelection = this._getEquivalentSelection(selection);
|
|
788
|
+
SmoOperation.addGraceNote(altSelection!, altGrace, index);
|
|
789
|
+
});
|
|
790
|
+
this._renderChangedMeasures(measureSelections);
|
|
791
|
+
await this.renderer.updatePromise();
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
/**
|
|
795
|
+
* remove selected grace note
|
|
796
|
+
* @returns
|
|
797
|
+
*/
|
|
798
|
+
async removeGraceNote(): Promise<void> {
|
|
799
|
+
const selections = this.tracker.selections;
|
|
800
|
+
const measureSelections = this.undoTrackerMeasureSelections('remove grace note');
|
|
801
|
+
selections.forEach((selection) => {
|
|
802
|
+
// TODO: get the correct offset
|
|
803
|
+
SmoOperation.removeGraceNote(selection, 0);
|
|
804
|
+
const altSel = (this._getEquivalentSelection(selection));
|
|
805
|
+
SmoOperation.removeGraceNote(altSel!, 0);
|
|
806
|
+
});
|
|
807
|
+
this._renderChangedMeasures(measureSelections);
|
|
808
|
+
await this.renderer.updatePromise();
|
|
809
|
+
}
|
|
810
|
+
/**
|
|
811
|
+
* Toggle slash in stem of grace note
|
|
812
|
+
*/
|
|
813
|
+
async slashGraceNotes(): Promise<void> {
|
|
814
|
+
const grace = this.tracker.getSelectedGraceNotes();
|
|
815
|
+
const measureSelections = this.undoTrackerMeasureSelections('slash grace note toggle');
|
|
816
|
+
grace.forEach((gn) => {
|
|
817
|
+
SmoOperation.slashGraceNotes(gn);
|
|
818
|
+
if (gn.selection !== null) {
|
|
819
|
+
const altSelection = this._getEquivalentSelection(gn.selection);
|
|
820
|
+
const altGn = this._getEquivalentGraceNote(altSelection!, gn.modifier as SmoGraceNote);
|
|
821
|
+
SmoOperation.slashGraceNotes({
|
|
822
|
+
selection: altSelection, modifier: altGn as any,
|
|
823
|
+
box: SvgBox.default, index: 0
|
|
824
|
+
});
|
|
825
|
+
}
|
|
826
|
+
});
|
|
827
|
+
this._renderChangedMeasures(measureSelections);
|
|
828
|
+
await this.renderer.updatePromise();
|
|
829
|
+
}
|
|
830
|
+
async transposeScore(offset: number): Promise<void> {
|
|
831
|
+
this._undoScore('transpose score');
|
|
832
|
+
SmoOperation.transposeScore(this.score, offset);
|
|
833
|
+
SmoOperation.transposeScore(this.storeScore, offset);
|
|
834
|
+
this.renderer.rerenderAll();
|
|
835
|
+
await this.renderer.updatePromise();
|
|
836
|
+
}
|
|
837
|
+
/**
|
|
838
|
+
* transpose selected notes
|
|
839
|
+
* @param offset 1/2 steps
|
|
840
|
+
* @returns
|
|
841
|
+
*/
|
|
842
|
+
async transposeSelections(offset: number): Promise<void> {
|
|
843
|
+
const selections = this.tracker.selections;
|
|
844
|
+
const measureSelections = this.undoTrackerMeasureSelections('transpose');
|
|
845
|
+
const grace = this.tracker.getSelectedGraceNotes();
|
|
846
|
+
if (grace.length) {
|
|
847
|
+
grace.forEach((artifact) => {
|
|
848
|
+
if (artifact.selection !== null && artifact.selection.note !== null) {
|
|
849
|
+
const gn1 = artifact.modifier as SmoGraceNote;
|
|
850
|
+
const index = artifact.selection.note.graceNotes.findIndex((x) => x.attrs.id === gn1.attrs.id);
|
|
851
|
+
const altSelection = this._getEquivalentSelection(artifact.selection);
|
|
852
|
+
if (altSelection && altSelection.note !== null) {
|
|
853
|
+
const gn2 = altSelection.note.graceNotes[index];
|
|
854
|
+
SmoOperation.transposeGraceNotes(altSelection!, [gn2], offset);
|
|
855
|
+
}
|
|
856
|
+
SmoOperation.transposeGraceNotes(artifact.selection, [gn1], offset);
|
|
857
|
+
}
|
|
858
|
+
});
|
|
859
|
+
|
|
860
|
+
} else {
|
|
861
|
+
let isPercussion = false;
|
|
862
|
+
selections.forEach((selected) => {
|
|
863
|
+
SmoOperation.transpose(selected, offset);
|
|
864
|
+
if (selected.staff.getStaffInstrument(selected.selector.measure).isPercussion) {
|
|
865
|
+
isPercussion = true;
|
|
866
|
+
}
|
|
867
|
+
const altSel = this._getEquivalentSelection(selected);
|
|
868
|
+
SmoOperation.transpose(altSel!, offset);
|
|
869
|
+
});
|
|
870
|
+
// if this is percussion, set that property
|
|
871
|
+
if (isPercussion) {
|
|
872
|
+
this.score.setNoteInstrumentProperties();
|
|
873
|
+
this.storeScore.setNoteInstrumentProperties()
|
|
874
|
+
}
|
|
875
|
+
if (selections.length === 1 && this.score.preferences.autoPlay) {
|
|
876
|
+
SuiOscillator.playSelectionNow(selections[0], this.score, 1);
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
this._renderChangedMeasures(measureSelections);
|
|
880
|
+
await this.renderer.updatePromise();
|
|
881
|
+
}
|
|
882
|
+
/**
|
|
883
|
+
* toggle the accidental spelling of the selected notes
|
|
884
|
+
* @returns
|
|
885
|
+
*/
|
|
886
|
+
async toggleEnharmonic(): Promise<void> {
|
|
887
|
+
const selections = this.tracker.selections;
|
|
888
|
+
const measureSelections = this.undoTrackerMeasureSelections('toggle enharmonic');
|
|
889
|
+
const grace = this.tracker.getSelectedGraceNotes();
|
|
890
|
+
if (grace.length) {
|
|
891
|
+
grace.forEach((artifact) => {
|
|
892
|
+
SmoOperation.toggleGraceNoteEnharmonic(artifact.selection!, [artifact.modifier as SmoGraceNote]);
|
|
893
|
+
const altSelection = this._getEquivalentSelection(artifact.selection!);
|
|
894
|
+
const altGr = this._getEquivalentGraceNote(altSelection!, artifact.modifier as SmoGraceNote);
|
|
895
|
+
SmoOperation.toggleGraceNoteEnharmonic(altSelection!,
|
|
896
|
+
[altGr]);
|
|
897
|
+
});
|
|
898
|
+
} else {
|
|
899
|
+
selections.forEach((selected) => {
|
|
900
|
+
if (typeof (selected.selector.pitches) === 'undefined') {
|
|
901
|
+
selected.selector.pitches = [];
|
|
902
|
+
}
|
|
903
|
+
SmoOperation.toggleEnharmonic(selected);
|
|
904
|
+
const altSel = this._getEquivalentSelection(selected);
|
|
905
|
+
SmoOperation.toggleEnharmonic(altSel!);
|
|
906
|
+
});
|
|
907
|
+
}
|
|
908
|
+
this._renderChangedMeasures(measureSelections);
|
|
909
|
+
await this.renderer.updatePromise();
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
/**
|
|
913
|
+
* Toggle cautionary/courtesy accidentals
|
|
914
|
+
*/
|
|
915
|
+
async toggleCourtesyAccidentals(): Promise<void> {
|
|
916
|
+
const selections = this.tracker.selections;
|
|
917
|
+
const measureSelections = this.undoTrackerMeasureSelections('toggle courtesy accidental');
|
|
918
|
+
const grace = this.tracker.getSelectedGraceNotes();
|
|
919
|
+
if (grace.length) {
|
|
920
|
+
grace.forEach((artifact) => {
|
|
921
|
+
const gn1 = [artifact.modifier] as SmoGraceNote[];
|
|
922
|
+
SmoOperation.toggleGraceNoteCourtesy(artifact.selection, gn1);
|
|
923
|
+
const altSel = this._getEquivalentSelection(artifact.selection!);
|
|
924
|
+
const gn2 = this._getEquivalentGraceNote(altSel!, gn1[0]);
|
|
925
|
+
SmoOperation.toggleGraceNoteCourtesy(altSel!, [gn2]);
|
|
926
|
+
});
|
|
927
|
+
} else {
|
|
928
|
+
selections.forEach((selection) => {
|
|
929
|
+
SmoOperation.toggleCourtesyAccidental(selection);
|
|
930
|
+
const altSel = this._getEquivalentSelection(selection);
|
|
931
|
+
SmoOperation.toggleCourtesyAccidental(altSel!);
|
|
932
|
+
});
|
|
933
|
+
}
|
|
934
|
+
this._renderChangedMeasures(measureSelections);
|
|
935
|
+
await this.renderer.updatePromise();
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
/**
|
|
939
|
+
* change the duration of notes for selected, creating more
|
|
940
|
+
* or fewer notes.
|
|
941
|
+
* After the change, reset the selection so it's as close as possible
|
|
942
|
+
* to the original length
|
|
943
|
+
* @param operation
|
|
944
|
+
* @returns
|
|
945
|
+
*/
|
|
946
|
+
async batchDurationOperation(operation: BatchSelectionOperation): Promise<void> {
|
|
947
|
+
const selections = this.tracker.selections;
|
|
948
|
+
const measureSelections = this.undoTrackerMeasureSelections('change duration');
|
|
949
|
+
const grace = this.tracker.getSelectedGraceNotes();
|
|
950
|
+
const graceMap: Record<string, BatchSelectionOperation> = {
|
|
951
|
+
doubleDuration: 'doubleGraceNoteDuration',
|
|
952
|
+
halveDuration: 'halveGraceNoteDuration'
|
|
953
|
+
};
|
|
954
|
+
if (grace.length && typeof (graceMap[operation]) !== 'undefined') {
|
|
955
|
+
operation = graceMap[operation];
|
|
956
|
+
grace.forEach((artifact) => {
|
|
957
|
+
(SmoOperation as any)[operation](artifact.selection, artifact.modifier);
|
|
958
|
+
const altSelection = this._getEquivalentSelection(artifact.selection!);
|
|
959
|
+
const gn2 = this._getEquivalentGraceNote(altSelection!, artifact.modifier as SmoGraceNote);
|
|
960
|
+
(SmoOperation as any)[operation](altSelection!, gn2);
|
|
961
|
+
});
|
|
962
|
+
} else {
|
|
963
|
+
const altAr = this._getEquivalentSelections(selections);
|
|
964
|
+
SmoOperation.batchSelectionOperation(this.score, selections, operation);
|
|
965
|
+
SmoOperation.batchSelectionOperation(this.storeScore, altAr, operation);
|
|
966
|
+
}
|
|
967
|
+
this._renderChangedMeasures(measureSelections);
|
|
968
|
+
await this.renderer.updatePromise();
|
|
969
|
+
}
|
|
970
|
+
/**
|
|
971
|
+
* Toggle selected modifier on selected notes
|
|
972
|
+
* @param modifier
|
|
973
|
+
* @param ctor parent class constructor (e.g. SmoOrnament)
|
|
974
|
+
* @returns
|
|
975
|
+
*/
|
|
976
|
+
async toggleArticulation(modifier: string, ctor: string): Promise<void> {
|
|
977
|
+
const measureSelections = this.undoTrackerMeasureSelections('toggle articulation');
|
|
978
|
+
this.tracker.selections.forEach((sel) => {
|
|
979
|
+
if (ctor === 'SmoArticulation') {
|
|
980
|
+
const aa = new SmoArticulation({ articulation: modifier });
|
|
981
|
+
const altAa = new SmoArticulation({ articulation: modifier });
|
|
982
|
+
altAa.attrs.id = aa.attrs.id;
|
|
983
|
+
if (sel.note) {
|
|
984
|
+
sel.note.toggleArticulation(aa);
|
|
985
|
+
}
|
|
986
|
+
const altSelection = this._getEquivalentSelection(sel);
|
|
987
|
+
if (altSelection && altSelection.note) {
|
|
988
|
+
altSelection.note.toggleArticulation(altAa);
|
|
989
|
+
}
|
|
990
|
+
} else {
|
|
991
|
+
const aa = new SmoOrnament({ ornament: modifier });
|
|
992
|
+
const altAa = new SmoOrnament({ ornament: modifier });
|
|
993
|
+
altAa.attrs.id = aa.attrs.id;
|
|
994
|
+
const altSelection = this._getEquivalentSelection(sel!);
|
|
995
|
+
if (sel.note) {
|
|
996
|
+
sel.note.toggleOrnament(aa);
|
|
997
|
+
}
|
|
998
|
+
if (altSelection && altSelection.note) {
|
|
999
|
+
altSelection.note.toggleOrnament(altAa);
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
});
|
|
1003
|
+
this._renderChangedMeasures(measureSelections);
|
|
1004
|
+
await this.renderer.updatePromise();
|
|
1005
|
+
}
|
|
1006
|
+
async setArticulation(modifier: SmoArticulation, set: boolean): Promise<void> {
|
|
1007
|
+
const measureSelections = this.undoTrackerMeasureSelections('set articulation');
|
|
1008
|
+
this.tracker.selections.forEach((sel) => {
|
|
1009
|
+
const altAa = new SmoArticulation(modifier);
|
|
1010
|
+
if (sel.note) {
|
|
1011
|
+
sel.note.setArticulation(modifier, set);
|
|
1012
|
+
}
|
|
1013
|
+
const altSelection = this._getEquivalentSelection(sel);
|
|
1014
|
+
if (altSelection && altSelection.note) {
|
|
1015
|
+
altSelection.note.toggleArticulation(altAa);
|
|
1016
|
+
}
|
|
1017
|
+
});
|
|
1018
|
+
this._renderChangedMeasures(measureSelections);
|
|
1019
|
+
await this.renderer.updatePromise();
|
|
1020
|
+
}
|
|
1021
|
+
async setOrnament(modifier: SmoOrnament, set: boolean): Promise<void> {
|
|
1022
|
+
const measureSelections = this.undoTrackerMeasureSelections('set articulation');
|
|
1023
|
+
this.tracker.selections.forEach((sel) => {
|
|
1024
|
+
const altAa = new SmoOrnament(modifier);
|
|
1025
|
+
if (sel.note) {
|
|
1026
|
+
sel.note.setOrnament(modifier, set);
|
|
1027
|
+
}
|
|
1028
|
+
const altSelection = this._getEquivalentSelection(sel);
|
|
1029
|
+
if (altSelection && altSelection.note) {
|
|
1030
|
+
altSelection.note.setOrnament(altAa, set);
|
|
1031
|
+
}
|
|
1032
|
+
});
|
|
1033
|
+
this._renderChangedMeasures(measureSelections);
|
|
1034
|
+
await this.renderer.updatePromise();
|
|
1035
|
+
}
|
|
1036
|
+
/**
|
|
1037
|
+
* convert non-tuplet not to a tuplet
|
|
1038
|
+
* @param params
|
|
1039
|
+
*/
|
|
1040
|
+
async makeTuplet(params: MakeTupletOperation): Promise<void> {
|
|
1041
|
+
const selection = this.tracker.selections[0];
|
|
1042
|
+
const measureSelections = this.undoTrackerMeasureSelections('make tuplet');
|
|
1043
|
+
SmoOperation.makeTuplet(selection, params);
|
|
1044
|
+
const altSelection = this._getEquivalentSelection(selection!);
|
|
1045
|
+
SmoOperation.makeTuplet(altSelection!, params);
|
|
1046
|
+
this._renderChangedMeasures(measureSelections);
|
|
1047
|
+
await this.renderer.updatePromise();
|
|
1048
|
+
}
|
|
1049
|
+
/**
|
|
1050
|
+
* Convert selected tuplet to a single (if possible) non-tuplet
|
|
1051
|
+
*/
|
|
1052
|
+
async unmakeTuplet(): Promise<void> {
|
|
1053
|
+
const selection = this.tracker.selections[0];
|
|
1054
|
+
const measureSelections = this.undoTrackerMeasureSelections('unmake tuplet');
|
|
1055
|
+
SmoOperation.unmakeTuplet(selection);
|
|
1056
|
+
const altSelection = this._getEquivalentSelection(selection);
|
|
1057
|
+
SmoOperation.unmakeTuplet(altSelection!);
|
|
1058
|
+
this._renderChangedMeasures(measureSelections);
|
|
1059
|
+
await this.renderer.updatePromise();
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
/**
|
|
1063
|
+
* Create a chord by adding an interval to selected note
|
|
1064
|
+
* @param interval 1/2 steps
|
|
1065
|
+
* @returns
|
|
1066
|
+
*/
|
|
1067
|
+
async setInterval(interval: number): Promise<void> {
|
|
1068
|
+
const selections = this.tracker.selections;
|
|
1069
|
+
const measureSelections = this.undoTrackerMeasureSelections('set interval');
|
|
1070
|
+
selections.forEach((selected) => {
|
|
1071
|
+
SmoOperation.interval(selected, interval);
|
|
1072
|
+
const altSelection = this._getEquivalentSelection(selected);
|
|
1073
|
+
SmoOperation.interval(altSelection!, interval);
|
|
1074
|
+
});
|
|
1075
|
+
this._renderChangedMeasures(measureSelections);
|
|
1076
|
+
await this.renderer.updatePromise();
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
/**
|
|
1080
|
+
* change the selected chord into a single note
|
|
1081
|
+
* @returns
|
|
1082
|
+
*/
|
|
1083
|
+
async collapseChord(): Promise<void> {
|
|
1084
|
+
const selections = this.tracker.selections;
|
|
1085
|
+
const measureSelections = this.undoTrackerMeasureSelections('collapse chord');
|
|
1086
|
+
selections.forEach((selected) => {
|
|
1087
|
+
const note: SmoNote | null = selected.note;
|
|
1088
|
+
if (note) {
|
|
1089
|
+
const pp = JSON.parse(JSON.stringify(note.pitches[0]));
|
|
1090
|
+
const altpp = JSON.parse(JSON.stringify(note.pitches[0]));
|
|
1091
|
+
// No operation for this?
|
|
1092
|
+
note.pitches = [pp];
|
|
1093
|
+
const altSelection = this._getEquivalentSelection(selected);
|
|
1094
|
+
altSelection!.note!.pitches = [altpp];
|
|
1095
|
+
}
|
|
1096
|
+
});
|
|
1097
|
+
this._renderChangedMeasures(measureSelections);
|
|
1098
|
+
await this.renderer.updatePromise();
|
|
1099
|
+
}
|
|
1100
|
+
/**
|
|
1101
|
+
* Toggle chicken-scratches, for jazz improv, comping etc.
|
|
1102
|
+
*/
|
|
1103
|
+
async toggleSlash(): Promise<void> {
|
|
1104
|
+
const selections = this.tracker.selections;
|
|
1105
|
+
const measureSelections = this.undoTrackerMeasureSelections('make slash');
|
|
1106
|
+
selections.forEach((selection) => {
|
|
1107
|
+
SmoOperation.toggleSlash(selection);
|
|
1108
|
+
const altSel = this._getEquivalentSelection(selection);
|
|
1109
|
+
SmoOperation.toggleSlash(altSel!);
|
|
1110
|
+
});
|
|
1111
|
+
this._renderChangedMeasures(measureSelections);
|
|
1112
|
+
await this.renderer.updatePromise();
|
|
1113
|
+
}
|
|
1114
|
+
/**
|
|
1115
|
+
* make selected notes into a rest, or visa-versa
|
|
1116
|
+
* @returns
|
|
1117
|
+
*/
|
|
1118
|
+
async makeRest(): Promise<void> {
|
|
1119
|
+
const selections = this.tracker.selections;
|
|
1120
|
+
const measureSelections = this.undoTrackerMeasureSelections('make rest');
|
|
1121
|
+
selections.forEach((selection) => {
|
|
1122
|
+
SmoOperation.toggleRest(selection);
|
|
1123
|
+
const altSel = this._getEquivalentSelection(selection);
|
|
1124
|
+
SmoOperation.toggleRest(altSel!);
|
|
1125
|
+
});
|
|
1126
|
+
this._renderChangedMeasures(measureSelections);
|
|
1127
|
+
await this.renderer.updatePromise();
|
|
1128
|
+
}
|
|
1129
|
+
async clearAllBeams(): Promise<void> {
|
|
1130
|
+
this._undoScore('clearAllBeams');
|
|
1131
|
+
SmoOperation.clearAllBeamGroups(this.score);
|
|
1132
|
+
SmoOperation.clearAllBeamGroups(this.storeScore);
|
|
1133
|
+
await this.awaitRender();
|
|
1134
|
+
}
|
|
1135
|
+
async clearSelectedBeams() {
|
|
1136
|
+
const selections = this.tracker.selections;
|
|
1137
|
+
const measures = SmoSelection.getMeasureList(selections);
|
|
1138
|
+
const altSelections = this._getEquivalentSelections(selections);
|
|
1139
|
+
SmoOperation.clearBeamGroups(this.score, selections);
|
|
1140
|
+
SmoOperation.clearBeamGroups(this.storeScore, altSelections);
|
|
1141
|
+
this._renderChangedMeasures(measures);
|
|
1142
|
+
await this.renderer.updatePromise();
|
|
1143
|
+
}
|
|
1144
|
+
/**
|
|
1145
|
+
* toggle the 'end beam' flag for selected notes
|
|
1146
|
+
* @returns
|
|
1147
|
+
*/
|
|
1148
|
+
async unbeamSelections(): Promise<void> {
|
|
1149
|
+
const selections = this.tracker.selections;
|
|
1150
|
+
const measureSelections = this.undoTrackerMeasureSelections('toggle beam group');
|
|
1151
|
+
selections.forEach((selection) => {
|
|
1152
|
+
SmoOperation.unbeamSelections(selection);
|
|
1153
|
+
const altSel = this._getEquivalentSelection(selection);
|
|
1154
|
+
SmoOperation.unbeamSelections(altSel!);
|
|
1155
|
+
});
|
|
1156
|
+
this._renderChangedMeasures(measureSelections);
|
|
1157
|
+
await this.renderer.updatePromise();
|
|
1158
|
+
}
|
|
1159
|
+
async toggleCue() {
|
|
1160
|
+
const measureSelections = this.undoTrackerMeasureSelections('toggle note cue');
|
|
1161
|
+
this.tracker.selections.forEach((selection) => {
|
|
1162
|
+
const altSelection = this._getEquivalentSelection(selection);
|
|
1163
|
+
if (selection.note && selection.note.isRest() === false) {
|
|
1164
|
+
selection.note.isCue = !selection.note.isCue;
|
|
1165
|
+
if (altSelection && altSelection.note) {
|
|
1166
|
+
altSelection.note.isCue = selection.note.isCue;
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
});
|
|
1170
|
+
this._renderChangedMeasures(measureSelections);
|
|
1171
|
+
await this.renderer.updatePromise();
|
|
1172
|
+
}
|
|
1173
|
+
/**
|
|
1174
|
+
* up or down
|
|
1175
|
+
* @returns
|
|
1176
|
+
*/
|
|
1177
|
+
async toggleBeamDirection(): Promise<void> {
|
|
1178
|
+
const selections = this.tracker.selections;
|
|
1179
|
+
if (selections.length < 1) {
|
|
1180
|
+
return;
|
|
1181
|
+
}
|
|
1182
|
+
const measureSelections = this.undoTrackerMeasureSelections('toggle beam direction');
|
|
1183
|
+
SmoOperation.toggleBeamDirection(selections);
|
|
1184
|
+
SmoOperation.toggleBeamDirection(this._getEquivalentSelections(selections));
|
|
1185
|
+
this._renderChangedMeasures(measureSelections);
|
|
1186
|
+
await this.renderer.updatePromise();
|
|
1187
|
+
}
|
|
1188
|
+
/**
|
|
1189
|
+
* Add the selected notes to a beam group
|
|
1190
|
+
*/
|
|
1191
|
+
async beamSelections(): Promise<void> {
|
|
1192
|
+
const selections = this.tracker.selections;
|
|
1193
|
+
const measureSelections = this.undoTrackerMeasureSelections('beam selections');
|
|
1194
|
+
SmoOperation.beamSelections(this.score, selections);
|
|
1195
|
+
SmoOperation.beamSelections(this.storeScore, this._getEquivalentSelections(selections));
|
|
1196
|
+
this._renderChangedMeasures(measureSelections);
|
|
1197
|
+
await this.renderer.updatePromise();
|
|
1198
|
+
}
|
|
1199
|
+
/**
|
|
1200
|
+
* change key signature for selected measures
|
|
1201
|
+
* @param keySignature vex key signature
|
|
1202
|
+
*/
|
|
1203
|
+
async addKeySignature(keySignature: string): Promise<void> {
|
|
1204
|
+
const measureSelections = this.undoTrackerMeasureSelections('set key signature ' + keySignature);
|
|
1205
|
+
measureSelections.forEach((sel) => {
|
|
1206
|
+
SmoOperation.addKeySignature(this.score, sel, keySignature);
|
|
1207
|
+
const altSel = this._getEquivalentSelection(sel);
|
|
1208
|
+
SmoOperation.addKeySignature(this.storeScore, altSel!, keySignature);
|
|
1209
|
+
});
|
|
1210
|
+
this._renderChangedMeasures(measureSelections);
|
|
1211
|
+
await this.renderer.updatePromise();
|
|
1212
|
+
}
|
|
1213
|
+
/**
|
|
1214
|
+
* Sets a pitch from the piano widget.
|
|
1215
|
+
* @param pitch {Pitch}
|
|
1216
|
+
* @param chordPedal {boolean} - indicates we are adding to a chord
|
|
1217
|
+
*/
|
|
1218
|
+
async setPitchPiano(pitch: Pitch, chordPedal: boolean): Promise<void> {
|
|
1219
|
+
const measureSelections = this.undoTrackerMeasureSelections(
|
|
1220
|
+
'setAbsolutePitch ' + pitch.letter + '/' + pitch.accidental);
|
|
1221
|
+
this.tracker.selections.forEach((selected) => {
|
|
1222
|
+
const npitch: Pitch = {
|
|
1223
|
+
letter: pitch.letter,
|
|
1224
|
+
accidental: pitch.accidental, octave: pitch.octave
|
|
1225
|
+
};
|
|
1226
|
+
const octave = SmoMeasure.defaultPitchForClef[selected.measure.clef].octave;
|
|
1227
|
+
npitch.octave += octave;
|
|
1228
|
+
const altSel = this._getEquivalentSelection(selected);
|
|
1229
|
+
if (chordPedal && selected.note) {
|
|
1230
|
+
selected.note.toggleAddPitch(npitch);
|
|
1231
|
+
altSel!.note!.toggleAddPitch(npitch);
|
|
1232
|
+
} else {
|
|
1233
|
+
SmoOperation.setPitch(selected, [npitch]);
|
|
1234
|
+
SmoOperation.setPitch(altSel!, [npitch]);
|
|
1235
|
+
}
|
|
1236
|
+
});
|
|
1237
|
+
this._renderChangedMeasures(measureSelections);
|
|
1238
|
+
await this.renderer.updatePromise();
|
|
1239
|
+
}
|
|
1240
|
+
/**
|
|
1241
|
+
* show or hide the piano widget
|
|
1242
|
+
* @param value to show it
|
|
1243
|
+
*/
|
|
1244
|
+
async showPiano(value: boolean): Promise<void> {
|
|
1245
|
+
this.score.preferences.showPiano = value;
|
|
1246
|
+
this.storeScore.preferences.showPiano = value;
|
|
1247
|
+
if (value) {
|
|
1248
|
+
SuiPiano.showPiano();
|
|
1249
|
+
} else {
|
|
1250
|
+
SuiPiano.hidePiano();
|
|
1251
|
+
}
|
|
1252
|
+
await this.renderer.updatePromise();
|
|
1253
|
+
}
|
|
1254
|
+
/**
|
|
1255
|
+
* Render a pitch for each letter name-pitch in the string,
|
|
1256
|
+
* @param pitches letter names for pitches
|
|
1257
|
+
* @returns promise, resolved when all pitches rendered
|
|
1258
|
+
* @see setPitch
|
|
1259
|
+
*/
|
|
1260
|
+
async setPitchesPromise(pitches: PitchLetter[]): Promise<any> {
|
|
1261
|
+
const self = this;
|
|
1262
|
+
const promise = new Promise((resolve: any) => {
|
|
1263
|
+
const fc = async (index: number) => {
|
|
1264
|
+
if (index >= pitches.length) {
|
|
1265
|
+
resolve();
|
|
1266
|
+
} else {
|
|
1267
|
+
await self.setPitch(pitches[index]);
|
|
1268
|
+
fc(index + 1);
|
|
1269
|
+
}
|
|
1270
|
+
};
|
|
1271
|
+
fc(0);
|
|
1272
|
+
});
|
|
1273
|
+
await promise;
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1276
|
+
async setPitches(pitches: Pitch[]): Promise<void> {
|
|
1277
|
+
const selections = this.tracker.selections;
|
|
1278
|
+
const measureSelections = this.undoTrackerMeasureSelections('set pitches');
|
|
1279
|
+
const graceNotes = this.tracker.getSelectedGraceNotes();
|
|
1280
|
+
if (graceNotes.length === 1 && graceNotes[0].selection !== null && graceNotes[0].selection?.note !== null) {
|
|
1281
|
+
const grace1 = graceNotes[0].modifier as SmoGraceNote;
|
|
1282
|
+
const index = graceNotes[0].selection.note.graceNotes.findIndex((x) => x.attrs.id === grace1.attrs.id);
|
|
1283
|
+
|
|
1284
|
+
const altSel = this._getEquivalentSelection(graceNotes[0].selection);
|
|
1285
|
+
if (altSel && altSel.note !== null) {
|
|
1286
|
+
const grace2 = altSel.note.graceNotes[index];
|
|
1287
|
+
grace2.pitches = pitches;
|
|
1288
|
+
}
|
|
1289
|
+
grace1.pitches = pitches;
|
|
1290
|
+
} else if( selections.length === 1) {
|
|
1291
|
+
const selected = selections[0];
|
|
1292
|
+
SmoOperation.setPitch(selected, pitches);
|
|
1293
|
+
const altSel = this._getEquivalentSelection(selected);
|
|
1294
|
+
SmoOperation.setPitch(altSel!, pitches);
|
|
1295
|
+
if (this.score.preferences.autoAdvance) {
|
|
1296
|
+
// Don't play the next note and the added pitch at the same time.
|
|
1297
|
+
this.tracker.deferNextAutoPlay();
|
|
1298
|
+
this.tracker.moveSelectionRight();
|
|
1299
|
+
}
|
|
1300
|
+
SuiOscillator.playSelectionNow(selected, this.score, 1);
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
this._renderChangedMeasures(measureSelections);
|
|
1304
|
+
await this.renderer.updatePromise();
|
|
1305
|
+
}
|
|
1306
|
+
/**
|
|
1307
|
+
* Add a pitch to the score at the cursor. This tries to find the best pitch
|
|
1308
|
+
* to match the letter key (F vs F# for instance) based on key and surrounding notes
|
|
1309
|
+
* @param letter string
|
|
1310
|
+
*/
|
|
1311
|
+
async setPitch(letter: PitchLetter): Promise<void> {
|
|
1312
|
+
const selections = this.tracker.selections;
|
|
1313
|
+
const measureSelections = this.undoTrackerMeasureSelections('set pitch ' + letter);
|
|
1314
|
+
let isPercussion = false;
|
|
1315
|
+
selections.forEach((selected) => {
|
|
1316
|
+
const selector = selected.selector;
|
|
1317
|
+
if (selected.staff.getStaffInstrument(selected.selector.measure).isPercussion) {
|
|
1318
|
+
isPercussion = true;
|
|
1319
|
+
}
|
|
1320
|
+
let hintSel = SmoSelection.lastNoteSelectionNonRest(this.score,
|
|
1321
|
+
selector.staff, selector.measure, selector.voice, selector.tick);
|
|
1322
|
+
if (!hintSel) {
|
|
1323
|
+
hintSel = SmoSelection.nextNoteSelectionNonRest(this.score,
|
|
1324
|
+
selector.staff, selector.measure, selector.voice, selector.tick);
|
|
1325
|
+
}
|
|
1326
|
+
// The selection no longer exists, possibly deleted
|
|
1327
|
+
if (hintSel === null || hintSel.note === null) {
|
|
1328
|
+
return;
|
|
1329
|
+
}
|
|
1330
|
+
const pitch = SmoMusic.getLetterNotePitch(hintSel.note.pitches[0],
|
|
1331
|
+
letter, hintSel.measure.keySignature);
|
|
1332
|
+
SmoOperation.setPitch(selected, [pitch]);
|
|
1333
|
+
const altSel = this._getEquivalentSelection(selected);
|
|
1334
|
+
SmoOperation.setPitch(altSel!, [pitch]);
|
|
1335
|
+
if (this.score.preferences.autoAdvance) {
|
|
1336
|
+
// Don't play the next note and the added pitch at the same time.
|
|
1337
|
+
this.tracker.deferNextAutoPlay();
|
|
1338
|
+
this.tracker.moveSelectionRight();
|
|
1339
|
+
}
|
|
1340
|
+
});
|
|
1341
|
+
if (isPercussion) {
|
|
1342
|
+
this.score.setNoteInstrumentProperties();
|
|
1343
|
+
this.storeScore.setNoteInstrumentProperties()
|
|
1344
|
+
}
|
|
1345
|
+
if (selections.length === 1 && this.score.preferences.autoPlay) {
|
|
1346
|
+
SuiOscillator.playSelectionNow(selections[0], this.score, 1);
|
|
1347
|
+
}
|
|
1348
|
+
this._renderChangedMeasures(measureSelections);
|
|
1349
|
+
await this.renderer.updatePromise();
|
|
1350
|
+
}
|
|
1351
|
+
/**
|
|
1352
|
+
* Generic clipboard copy action
|
|
1353
|
+
*/
|
|
1354
|
+
async copy(): Promise<void> {
|
|
1355
|
+
const altAr: SmoSelection[] = [];
|
|
1356
|
+
this.tracker.selections.forEach((sel) => {
|
|
1357
|
+
const noteSelection = this._getEquivalentSelection(sel);
|
|
1358
|
+
if (noteSelection !== null) {
|
|
1359
|
+
altAr.push(noteSelection);
|
|
1360
|
+
}
|
|
1361
|
+
});
|
|
1362
|
+
this.storePaste.setSelections(this.storeScore, altAr);
|
|
1363
|
+
await this.renderer.updatePromise();
|
|
1364
|
+
}
|
|
1365
|
+
/**
|
|
1366
|
+
* The voices that Select Voice can offer for the current selection: empty unless some selected
|
|
1367
|
+
* measure has more than one voice.
|
|
1368
|
+
*/
|
|
1369
|
+
getSelectVoiceChoices(): number[] {
|
|
1370
|
+
return SmoSelection.voiceChoices(this.score, this.tracker.selections);
|
|
1371
|
+
}
|
|
1372
|
+
/**
|
|
1373
|
+
* Select all the notes of a voice in the measures that currently have a selection. Only the
|
|
1374
|
+
* selection changes: no edit is made and no undo is recorded.
|
|
1375
|
+
* @param voice the voice to select (0-3)
|
|
1376
|
+
*/
|
|
1377
|
+
async selectVoice(voice: number): Promise<void> {
|
|
1378
|
+
this.tracker.selectVoice(voice);
|
|
1379
|
+
}
|
|
1380
|
+
/**
|
|
1381
|
+
* The most voices any of the selected measures has, for the Copy Voices menu
|
|
1382
|
+
*/
|
|
1383
|
+
getSelectionVoiceCount(): number {
|
|
1384
|
+
let rv = 0;
|
|
1385
|
+
this.tracker.getSelectedMeasures().forEach((sel) => {
|
|
1386
|
+
rv = Math.max(rv, sel.measure.voices.length);
|
|
1387
|
+
});
|
|
1388
|
+
return rv;
|
|
1389
|
+
}
|
|
1390
|
+
/**
|
|
1391
|
+
* Where a voice paste would go, in the full score: the selected staff and measure, and the
|
|
1392
|
+
* measures from there that the copied voices cover (adding up measure lengths until the copy fits,
|
|
1393
|
+
* but not past the last measure). Null if nothing is selected or no voices are copied.
|
|
1394
|
+
*/
|
|
1395
|
+
private _getVoicePasteRange(): { staff: number, firstMeasure: number, lastMeasure: number } | null {
|
|
1396
|
+
if (!this.storePaste.hasVoiceCopy() || this.tracker.selections.length < 1) {
|
|
1397
|
+
return null;
|
|
1398
|
+
}
|
|
1399
|
+
const altSelection = this._getEquivalentSelection(this.tracker.selections[0]);
|
|
1400
|
+
if (altSelection === null) {
|
|
1401
|
+
return null;
|
|
1402
|
+
}
|
|
1403
|
+
const staff = altSelection.selector.staff;
|
|
1404
|
+
const measures = this.storeScore.staves[staff].measures;
|
|
1405
|
+
const firstMeasure = altSelection.selector.measure;
|
|
1406
|
+
const ticksToPaste = this.storePaste.getVoiceCopyTickCount();
|
|
1407
|
+
let lastMeasure = firstMeasure;
|
|
1408
|
+
let covered = measures[firstMeasure].getTicksFromThisOrAnyVoice(0);
|
|
1409
|
+
while (covered < ticksToPaste && lastMeasure + 1 < measures.length) {
|
|
1410
|
+
lastMeasure += 1;
|
|
1411
|
+
covered += measures[lastMeasure].getTicksFromThisOrAnyVoice(0);
|
|
1412
|
+
}
|
|
1413
|
+
return { staff, firstMeasure, lastMeasure };
|
|
1414
|
+
}
|
|
1415
|
+
/**
|
|
1416
|
+
* The number of voices at the paste destination, for the Paste Voice menu: the most voices in
|
|
1417
|
+
* any measure the paste would cover, on the staves it would cover. A voice number at or above
|
|
1418
|
+
* this count is empty everywhere in the destination.
|
|
1419
|
+
*/
|
|
1420
|
+
getDestinationVoiceCount(): number {
|
|
1421
|
+
const range = this._getVoicePasteRange();
|
|
1422
|
+
if (range === null) {
|
|
1423
|
+
const measures = this.tracker.getSelectedMeasures();
|
|
1424
|
+
return measures.length > 0 ? measures[0].measure.voices.length : 0;
|
|
1425
|
+
}
|
|
1426
|
+
const copy = this.storePaste.voiceCopy!;
|
|
1427
|
+
let rv = 0;
|
|
1428
|
+
for (let k = 0; k < copy.staffCount; ++k) {
|
|
1429
|
+
const staff = this.storeScore.staves[range.staff + k];
|
|
1430
|
+
if (!staff) {
|
|
1431
|
+
break;
|
|
1432
|
+
}
|
|
1433
|
+
for (let m = range.firstMeasure; m <= range.lastMeasure; ++m) {
|
|
1434
|
+
rv = Math.max(rv, staff.measures[m].voices.length);
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
return rv;
|
|
1438
|
+
}
|
|
1439
|
+
/**
|
|
1440
|
+
* Copy a voice, or all the voices, of the selected measures. The copy always covers whole
|
|
1441
|
+
* measures, from the start of the first selected measure to the end of the last.
|
|
1442
|
+
* @param voice the voice to copy (0-3), or 'all'
|
|
1443
|
+
*/
|
|
1444
|
+
async copyVoices(voice: number | 'all'): Promise<void> {
|
|
1445
|
+
const altAr: SmoSelection[] = [];
|
|
1446
|
+
this.tracker.selections.forEach((sel) => {
|
|
1447
|
+
const noteSelection = this._getEquivalentSelection(sel);
|
|
1448
|
+
if (noteSelection !== null) {
|
|
1449
|
+
altAr.push(noteSelection);
|
|
1450
|
+
}
|
|
1451
|
+
});
|
|
1452
|
+
this.storePaste.setVoiceSelections(this.storeScore, altAr, voice);
|
|
1453
|
+
await this.renderer.updatePromise();
|
|
1454
|
+
}
|
|
1455
|
+
/**
|
|
1456
|
+
* Paste the voices copied with copyVoices, starting at the beginning of the first selected
|
|
1457
|
+
* measure. A voice that doesn't exist in a measure is created there first.
|
|
1458
|
+
* @param voice the voice to paste into (0-3) for a single copied voice; 'new' to paste a single
|
|
1459
|
+
* copied voice into a new voice after the existing ones; or 'all' to paste every copied voice
|
|
1460
|
+
* into the voice with the same number
|
|
1461
|
+
*/
|
|
1462
|
+
async pasteVoices(voice: number | 'all' | 'new'): Promise<void> {
|
|
1463
|
+
const range = this._getVoicePasteRange();
|
|
1464
|
+
if (range === null) {
|
|
1465
|
+
return;
|
|
1466
|
+
}
|
|
1467
|
+
let destVoice: number | 'all' = voice === 'new' ? this.getDestinationVoiceCount() : voice;
|
|
1468
|
+
if (destVoice !== 'all' && (destVoice < 0 || destVoice > 3)) {
|
|
1469
|
+
// 'new' with all the voices already in use
|
|
1470
|
+
return;
|
|
1471
|
+
}
|
|
1472
|
+
this.renderer.preserveScroll();
|
|
1473
|
+
// The paste always begins at the start of the measure
|
|
1474
|
+
const target: SmoSelector = { staff: range.staff, measure: range.firstMeasure, voice: 0, tick: 0, pitches: [] };
|
|
1475
|
+
const measureRange = [range.firstMeasure, range.lastMeasure];
|
|
1476
|
+
// One undo for the whole paste, including any voices it creates
|
|
1477
|
+
this.storeUndo.grouping = true;
|
|
1478
|
+
for (let i = measureRange[0]; i <= measureRange[1]; ++i) {
|
|
1479
|
+
this._undoColumn('paste voices', i);
|
|
1480
|
+
this.renderer.unrenderColumn(this.score.staves[0].measures[i]);
|
|
1481
|
+
}
|
|
1482
|
+
this.storeUndo.grouping = false;
|
|
1483
|
+
if (destVoice === 'all') {
|
|
1484
|
+
this.storePaste.pasteAllVoices(target);
|
|
1485
|
+
} else {
|
|
1486
|
+
this.storePaste.pasteVoice(target, destVoice);
|
|
1487
|
+
}
|
|
1488
|
+
this.replaceMeasureView(measureRange);
|
|
1489
|
+
await this.renderer.updatePromise();
|
|
1490
|
+
}
|
|
1491
|
+
/**
|
|
1492
|
+
* clipboard paste action
|
|
1493
|
+
* @returns
|
|
1494
|
+
*/
|
|
1495
|
+
async paste(): Promise<void> {
|
|
1496
|
+
// We undo the whole score on a paste, since we don't yet know the
|
|
1497
|
+
// extent of the overlap
|
|
1498
|
+
this.renderer.preserveScroll();
|
|
1499
|
+
const selections: SmoSelection[] = this.getPasteMeasureList();
|
|
1500
|
+
const firstSelection = selections[0];
|
|
1501
|
+
const measureEnd = selections[selections.length - 1].selector.measure;
|
|
1502
|
+
const measureRange = [firstSelection.selector.measure, measureEnd];
|
|
1503
|
+
this.storeUndo.grouping = true;
|
|
1504
|
+
// Undo the paste by selecting all the affected measures
|
|
1505
|
+
for (let i = measureRange[0]; i <= measureRange[1]; ++i) {
|
|
1506
|
+
this._undoColumn('paste', i);
|
|
1507
|
+
this.renderer.unrenderColumn(this.score.staves[0].measures[i]);
|
|
1508
|
+
}
|
|
1509
|
+
this.storeUndo.grouping = false;
|
|
1510
|
+
const altSelection = this._getEquivalentSelection(firstSelection);
|
|
1511
|
+
const altTarget = altSelection!.selector;
|
|
1512
|
+
altTarget.tick = this.tracker.selections[0].selector.tick;
|
|
1513
|
+
// paste the clipboard into the destination
|
|
1514
|
+
this.storePaste.pasteSelections(altTarget);
|
|
1515
|
+
// Refresh those measures.
|
|
1516
|
+
this.replaceMeasureView(measureRange);
|
|
1517
|
+
await this.renderer.updatePromise();
|
|
1518
|
+
}
|
|
1519
|
+
/**
|
|
1520
|
+
* Paste only the chords.
|
|
1521
|
+
*/
|
|
1522
|
+
async pasteChords(): Promise<void> {
|
|
1523
|
+
// We undo the whole score on a paste, since we don't yet know the
|
|
1524
|
+
// extent of the overlap
|
|
1525
|
+
this.renderer.preserveScroll();
|
|
1526
|
+
const selections: SmoSelection[] = this.getPasteMeasureList();
|
|
1527
|
+
const firstSelection = selections[0];
|
|
1528
|
+
const measureEnd = selections[selections.length - 1].selector.measure;
|
|
1529
|
+
const measureRange = [firstSelection.selector.measure, measureEnd];
|
|
1530
|
+
this.storeUndo.grouping = true;
|
|
1531
|
+
// Undo the paste by selecting all the affected measures
|
|
1532
|
+
for (let i = measureRange[0]; i <= measureRange[1]; ++i) {
|
|
1533
|
+
this._undoColumn('paste', i);
|
|
1534
|
+
this.renderer.unrenderColumn(this.score.staves[0].measures[i]);
|
|
1535
|
+
}
|
|
1536
|
+
this.storeUndo.grouping = false;
|
|
1537
|
+
const altSelection = this._getEquivalentSelection(firstSelection);
|
|
1538
|
+
const altTarget = altSelection!.selector;
|
|
1539
|
+
altTarget.tick = this.tracker.selections[0].selector.tick;
|
|
1540
|
+
this.storePaste.pasteChords(altTarget);
|
|
1541
|
+
// Refresh those measures.
|
|
1542
|
+
this.replaceMeasureView(measureRange);
|
|
1543
|
+
await this.renderer.updatePromise();
|
|
1544
|
+
}
|
|
1545
|
+
/**
|
|
1546
|
+
* specify a note head other than the default for the duration
|
|
1547
|
+
* @param head
|
|
1548
|
+
*/
|
|
1549
|
+
async setNoteHead(head: string): Promise<void> {
|
|
1550
|
+
await this.modifyCurrentSelections('set note head', (score, selections) => {
|
|
1551
|
+
SmoOperation.setNoteHead(selections, head);
|
|
1552
|
+
});
|
|
1553
|
+
}
|
|
1554
|
+
|
|
1555
|
+
/**
|
|
1556
|
+
* Add a volta for selected measures
|
|
1557
|
+
*/
|
|
1558
|
+
async addEnding(): Promise<void> {
|
|
1559
|
+
// TODO: we should have undo for columns
|
|
1560
|
+
this._undoScore('Add Volta');
|
|
1561
|
+
const ft = this.tracker.getExtremeSelection(-1);
|
|
1562
|
+
const tt = this.tracker.getExtremeSelection(1);
|
|
1563
|
+
const params = SmoVolta.defaults;
|
|
1564
|
+
params.startBar = ft.selector.measure;
|
|
1565
|
+
params.endBar = tt.selector.measure;
|
|
1566
|
+
params.number = 1;
|
|
1567
|
+
const volta = new SmoVolta(params);
|
|
1568
|
+
const altVolta = new SmoVolta(params);
|
|
1569
|
+
this._renderChangedMeasures([ft, tt]);
|
|
1570
|
+
SmoOperation.addEnding(this.storeScore, altVolta);
|
|
1571
|
+
SmoOperation.addEnding(this.score, volta);
|
|
1572
|
+
this.renderer.setRefresh();
|
|
1573
|
+
return this.renderer.updatePromise();
|
|
1574
|
+
}
|
|
1575
|
+
/**
|
|
1576
|
+
* @param ending volta settings
|
|
1577
|
+
* @returns
|
|
1578
|
+
*/
|
|
1579
|
+
async updateEnding(ending: SmoVolta): Promise<void> {
|
|
1580
|
+
this._undoScore('Change Volta');
|
|
1581
|
+
ending.elements.forEach((el) => {
|
|
1582
|
+
$(el).find('g.' + ending.attrs.id).remove();
|
|
1583
|
+
});
|
|
1584
|
+
ending.elements = [];
|
|
1585
|
+
SmoOperation.removeEnding(this.storeScore, ending);
|
|
1586
|
+
SmoOperation.removeEnding(this.score, ending);
|
|
1587
|
+
const altVolta = new SmoVolta(ending);
|
|
1588
|
+
SmoOperation.addEnding(this.storeScore, altVolta);
|
|
1589
|
+
SmoOperation.addEnding(this.score, ending);
|
|
1590
|
+
this.renderer.setRefresh();
|
|
1591
|
+
return this.renderer.updatePromise();
|
|
1592
|
+
}
|
|
1593
|
+
/**
|
|
1594
|
+
*
|
|
1595
|
+
* @param ending volta to remove
|
|
1596
|
+
* @returns
|
|
1597
|
+
*/
|
|
1598
|
+
async removeEnding(ending: SmoVolta): Promise<void> {
|
|
1599
|
+
this._undoScore('Remove Volta');
|
|
1600
|
+
ending.elements.forEach((el) => {
|
|
1601
|
+
$(el).find('g.' + ending.attrs.id).remove();
|
|
1602
|
+
});
|
|
1603
|
+
ending.elements = [];
|
|
1604
|
+
SmoOperation.removeEnding(this.storeScore, ending);
|
|
1605
|
+
SmoOperation.removeEnding(this.score, ending);
|
|
1606
|
+
this.renderer.setRefresh();
|
|
1607
|
+
return this.renderer.updatePromise();
|
|
1608
|
+
}
|
|
1609
|
+
/**
|
|
1610
|
+
*
|
|
1611
|
+
* @param position begin or end
|
|
1612
|
+
* @param barline barline type
|
|
1613
|
+
* @returns
|
|
1614
|
+
*/
|
|
1615
|
+
async setBarline(position: number, barline: number, bracket: number): Promise<void> {
|
|
1616
|
+
const obj = new SmoBarline({ position, barline, repeatBracket: bracket });
|
|
1617
|
+
const altObj = new SmoBarline({ position, barline, repeatBracket: bracket });
|
|
1618
|
+
const selection = this.tracker.selections[0];
|
|
1619
|
+
this._undoColumn('set barline', selection.selector.measure);
|
|
1620
|
+
SmoOperation.setMeasureBarline(this.score, selection, obj);
|
|
1621
|
+
const altSel = this._getEquivalentSelection(selection);
|
|
1622
|
+
SmoOperation.setMeasureBarline(this.storeScore, altSel!, altObj);
|
|
1623
|
+
this._renderChangedMeasures([selection]);
|
|
1624
|
+
return this.renderer.updatePromise();
|
|
1625
|
+
}
|
|
1626
|
+
/**
|
|
1627
|
+
*
|
|
1628
|
+
* @param position start or end
|
|
1629
|
+
* @param symbol coda, etc.
|
|
1630
|
+
*/
|
|
1631
|
+
async setRepeatSymbol(position: number, symbol: number): Promise<void> {
|
|
1632
|
+
const params = SmoRepeatSymbol.defaults;
|
|
1633
|
+
params.position = position;
|
|
1634
|
+
params.symbol = symbol;
|
|
1635
|
+
const obj = new SmoRepeatSymbol(params);
|
|
1636
|
+
const altObj = new SmoRepeatSymbol(params);
|
|
1637
|
+
const selection = this.tracker.selections[0];
|
|
1638
|
+
this._undoColumn('set repeat symbol', selection.selector.measure);
|
|
1639
|
+
SmoOperation.setRepeatSymbol(this.score, selection, obj);
|
|
1640
|
+
const altSel = this._getEquivalentSelection(selection);
|
|
1641
|
+
SmoOperation.setRepeatSymbol(this.storeScore, altSel!, altObj);
|
|
1642
|
+
this._renderChangedMeasures([selection]);
|
|
1643
|
+
return this.renderer.updatePromise();
|
|
1644
|
+
}
|
|
1645
|
+
/**
|
|
1646
|
+
* toggle rehearsal mark on first selected measure
|
|
1647
|
+
* @returns
|
|
1648
|
+
*/
|
|
1649
|
+
async toggleRehearsalMark(): Promise<void> {
|
|
1650
|
+
const selection = this.tracker.getExtremeSelection(-1);
|
|
1651
|
+
const altSelection = this._getEquivalentSelection(selection);
|
|
1652
|
+
const cmd = selection.measure.getRehearsalMark() ? 'removeRehearsalMark' : 'addRehearsalMark';
|
|
1653
|
+
SmoOperation[cmd](this.score, selection, new SmoRehearsalMark(SmoRehearsalMark.defaults));
|
|
1654
|
+
SmoOperation[cmd](this.storeScore, altSelection!, new SmoRehearsalMark(SmoRehearsalMark.defaults));
|
|
1655
|
+
this._renderChangedMeasures([selection]);
|
|
1656
|
+
return this.renderer.updatePromise();
|
|
1657
|
+
}
|
|
1658
|
+
/**
|
|
1659
|
+
* Finds the measure whose rehearsal mark has the given id, as a selection on the live score.
|
|
1660
|
+
* Rehearsal marks are column-wide, so the first staff holding it identifies the measure.
|
|
1661
|
+
* See specs/025-rehearsal-mark-dialog.
|
|
1662
|
+
*/
|
|
1663
|
+
_findRehearsalMarkSelection(id: string): SmoSelection | null {
|
|
1664
|
+
for (let i = 0; i < this.score.staves.length; ++i) {
|
|
1665
|
+
const staff = this.score.staves[i];
|
|
1666
|
+
for (let j = 0; j < staff.measures.length; ++j) {
|
|
1667
|
+
const measure = staff.measures[j];
|
|
1668
|
+
if (measure.getRehearsalMark()?.attrs.id === id) {
|
|
1669
|
+
return SmoSelection.measureSelection(this.score, staff.staffId, measure.measureNumber.measureIndex);
|
|
1670
|
+
}
|
|
1671
|
+
}
|
|
1672
|
+
}
|
|
1673
|
+
return null;
|
|
1674
|
+
}
|
|
1675
|
+
/**
|
|
1676
|
+
* Replaces an existing rehearsal mark's settings on its measure, on every staff and in the
|
|
1677
|
+
* undo-copy store. Does nothing if the mark is no longer present (e.g. removed while its dialog
|
|
1678
|
+
* was open). See specs/025-rehearsal-mark-dialog.
|
|
1679
|
+
* @param mark the edited rehearsal mark
|
|
1680
|
+
*/
|
|
1681
|
+
async updateRehearsalMark(mark: SmoRehearsalMark): Promise<void> {
|
|
1682
|
+
const selection = this._findRehearsalMarkSelection(mark.attrs.id);
|
|
1683
|
+
if (!selection) {
|
|
1684
|
+
return;
|
|
1685
|
+
}
|
|
1686
|
+
const altSelection = this._getEquivalentSelection(selection);
|
|
1687
|
+
this._undoColumn('Change Rehearsal Mark', selection.selector.measure);
|
|
1688
|
+
SmoOperation.removeRehearsalMark(this.score, selection);
|
|
1689
|
+
SmoOperation.addRehearsalMark(this.score, selection, mark);
|
|
1690
|
+
SmoOperation.removeRehearsalMark(this.storeScore, altSelection!);
|
|
1691
|
+
SmoOperation.addRehearsalMark(this.storeScore, altSelection!, mark);
|
|
1692
|
+
this._renderChangedMeasures([selection]);
|
|
1693
|
+
return this.renderer.updatePromise();
|
|
1694
|
+
}
|
|
1695
|
+
/**
|
|
1696
|
+
* Removes an existing rehearsal mark from its measure on every staff and in the undo-copy store.
|
|
1697
|
+
* Does nothing if the mark is no longer present. See specs/025-rehearsal-mark-dialog.
|
|
1698
|
+
* @param mark the rehearsal mark to remove
|
|
1699
|
+
*/
|
|
1700
|
+
async removeRehearsalMark(mark: SmoRehearsalMark): Promise<void> {
|
|
1701
|
+
const selection = this._findRehearsalMarkSelection(mark.attrs.id);
|
|
1702
|
+
if (!selection) {
|
|
1703
|
+
return;
|
|
1704
|
+
}
|
|
1705
|
+
const altSelection = this._getEquivalentSelection(selection);
|
|
1706
|
+
this._undoColumn('Remove Rehearsal Mark', selection.selector.measure);
|
|
1707
|
+
SmoOperation.removeRehearsalMark(this.score, selection);
|
|
1708
|
+
SmoOperation.removeRehearsalMark(this.storeScore, altSelection!);
|
|
1709
|
+
this._renderChangedMeasures([selection]);
|
|
1710
|
+
return this.renderer.updatePromise();
|
|
1711
|
+
}
|
|
1712
|
+
_removeStaffModifier(modifier: StaffModifierBase) {
|
|
1713
|
+
this.score.staves[modifier.associatedStaff].removeStaffModifier(modifier);
|
|
1714
|
+
const altModifier = StaffModifierBase.deserialize(modifier.serialize());
|
|
1715
|
+
altModifier.attrs.id = modifier.attrs.id;
|
|
1716
|
+
altModifier.startSelector = this._getEquivalentSelector(altModifier.startSelector);
|
|
1717
|
+
altModifier.endSelector = this._getEquivalentSelector(altModifier.endSelector);
|
|
1718
|
+
this.storeScore.staves[this._getEquivalentStaff(modifier.associatedStaff)].removeStaffModifier(altModifier);
|
|
1719
|
+
}
|
|
1720
|
+
/**
|
|
1721
|
+
* Remove selected modifier
|
|
1722
|
+
* @param modifier slur, hairpin, etc.
|
|
1723
|
+
* @returns
|
|
1724
|
+
*/
|
|
1725
|
+
async removeStaffModifier(modifier: StaffModifierBase): Promise<void> {
|
|
1726
|
+
this.undoStaffModifier('Set measure proportion', modifier,
|
|
1727
|
+
UndoBuffer.bufferSubtypes.REMOVE);
|
|
1728
|
+
this._removeStaffModifier(modifier);
|
|
1729
|
+
this._renderRectangle(modifier.startSelector, modifier.endSelector);
|
|
1730
|
+
return this.renderer.updatePromise();
|
|
1731
|
+
}
|
|
1732
|
+
/**
|
|
1733
|
+
* Change a staff modifier
|
|
1734
|
+
* @param original original version
|
|
1735
|
+
* @param modifier modified version
|
|
1736
|
+
* @returns
|
|
1737
|
+
*/
|
|
1738
|
+
async addOrUpdateStaffModifier(original: StaffModifierBase, modifier: StaffModifierBase): Promise<void> {
|
|
1739
|
+
if (!modifier) {
|
|
1740
|
+
if (original) {
|
|
1741
|
+
// Handle legacy API changed
|
|
1742
|
+
modifier = StaffModifierBase.deserialize(original);
|
|
1743
|
+
} else {
|
|
1744
|
+
console.warn('update modifier: bad modifier');
|
|
1745
|
+
return;
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
const existing = this.score.staves[modifier.startSelector.staff]
|
|
1749
|
+
.getModifier(modifier);
|
|
1750
|
+
const subtype = existing === null ? UndoBuffer.bufferSubtypes.ADD :
|
|
1751
|
+
UndoBuffer.bufferSubtypes.UPDATE;
|
|
1752
|
+
this.undoStaffModifier('Set measure proportion', original,
|
|
1753
|
+
subtype);
|
|
1754
|
+
this._removeStaffModifier(modifier);
|
|
1755
|
+
const copy = StaffModifierBase.deserialize(modifier.serialize());
|
|
1756
|
+
copy.startSelector = this._getEquivalentSelector(copy.startSelector);
|
|
1757
|
+
copy.endSelector = this._getEquivalentSelector(copy.endSelector);
|
|
1758
|
+
const sel = SmoSelection.noteFromSelector(this.score, modifier.startSelector);
|
|
1759
|
+
if (sel !== null) {
|
|
1760
|
+
const altSel = this._getEquivalentSelection(sel);
|
|
1761
|
+
SmoOperation.addStaffModifier(sel, modifier);
|
|
1762
|
+
SmoOperation.addStaffModifier(altSel!, copy);
|
|
1763
|
+
const modId = 'mod-' + sel.selector.staff + '-' + sel.selector.measure;
|
|
1764
|
+
const context = this.renderer.renderer.getRenderer(sel.measure.svg.logicalBox);
|
|
1765
|
+
if (context) {
|
|
1766
|
+
SvgHelpers.removeElementsByClass(context.svg, modId);
|
|
1767
|
+
}
|
|
1768
|
+
}
|
|
1769
|
+
this._renderRectangle(modifier.startSelector, modifier.endSelector);
|
|
1770
|
+
return this.renderer.updatePromise();
|
|
1771
|
+
}
|
|
1772
|
+
lineOperation(op: createStaffModifierType<StaffModifierBase>) {
|
|
1773
|
+
// if (this.tracker.selections.length < 2) {
|
|
1774
|
+
// return;
|
|
1775
|
+
// }
|
|
1776
|
+
const measureSelections = this.undoTrackerMeasureSelections('create staff modifier');
|
|
1777
|
+
const ft = this.tracker.getExtremeSelection(-1);
|
|
1778
|
+
const tt = this.tracker.getExtremeSelection(1);
|
|
1779
|
+
const ftAlt = this._getEquivalentSelection(ft);
|
|
1780
|
+
const ttAlt = this._getEquivalentSelection(tt);
|
|
1781
|
+
const modifier = op(ft, tt);
|
|
1782
|
+
const altModifier = op(ftAlt!, ttAlt!);
|
|
1783
|
+
altModifier.attrs.id = modifier.attrs.id;
|
|
1784
|
+
ft.staff.addStaffModifier(modifier);
|
|
1785
|
+
ftAlt?.staff.addStaffModifier(altModifier);
|
|
1786
|
+
this.undoStaffModifier('add ' + op, modifier, UndoBuffer.bufferSubtypes.ADD);
|
|
1787
|
+
this._renderChangedMeasures(measureSelections);
|
|
1788
|
+
}
|
|
1789
|
+
/**
|
|
1790
|
+
* Add crescendo to selection
|
|
1791
|
+
*/
|
|
1792
|
+
async crescendo(): Promise<void> {
|
|
1793
|
+
this.lineOperation(SmoOperation.createCrescendo);
|
|
1794
|
+
return this.renderer.updatePromise();
|
|
1795
|
+
}
|
|
1796
|
+
/**
|
|
1797
|
+
* Add crescendo to selection
|
|
1798
|
+
*/
|
|
1799
|
+
async crescendoBracket(): Promise<void> {
|
|
1800
|
+
this.lineOperation(SmoOperation.createCrescendoBracket);
|
|
1801
|
+
return this.renderer.updatePromise();
|
|
1802
|
+
}
|
|
1803
|
+
/**
|
|
1804
|
+
* Add crescendo to selection
|
|
1805
|
+
*/
|
|
1806
|
+
async dimenuendo(): Promise<void> {
|
|
1807
|
+
this.lineOperation(SmoOperation.createDimenuendoBracket);
|
|
1808
|
+
return this.renderer.updatePromise();
|
|
1809
|
+
}
|
|
1810
|
+
/**
|
|
1811
|
+
* Add crescendo to selection
|
|
1812
|
+
*/
|
|
1813
|
+
async accelerando(): Promise<void> {
|
|
1814
|
+
this.lineOperation(SmoOperation.createAccelerandoBracket);
|
|
1815
|
+
return this.renderer.updatePromise();
|
|
1816
|
+
}
|
|
1817
|
+
/**
|
|
1818
|
+
* Add crescendo to selection
|
|
1819
|
+
*/
|
|
1820
|
+
async ritard(): Promise<void> {
|
|
1821
|
+
this.lineOperation(SmoOperation.createRitardBracket);
|
|
1822
|
+
return this.renderer.updatePromise();
|
|
1823
|
+
}
|
|
1824
|
+
/**
|
|
1825
|
+
* diminuendo hairpin
|
|
1826
|
+
* @returns
|
|
1827
|
+
*/
|
|
1828
|
+
async decrescendo(): Promise<void> {
|
|
1829
|
+
this.lineOperation(SmoOperation.createDecrescendo);
|
|
1830
|
+
return this.renderer.updatePromise();
|
|
1831
|
+
}
|
|
1832
|
+
async removeTextBracket(bracket: SmoStaffTextBracket): Promise<void> {
|
|
1833
|
+
return this.removeStaffModifier(bracket);
|
|
1834
|
+
}
|
|
1835
|
+
async addOrReplaceStaffModifier(callback: updateStaffModifierFunc, modifier: StaffModifierBase): Promise<void> {
|
|
1836
|
+
const from1 = SmoSelection.noteFromSelector(this.score, modifier.startSelector);
|
|
1837
|
+
const to1 = SmoSelection.noteFromSelector(this.score, modifier.endSelector);
|
|
1838
|
+
if (from1 === null || to1 === null) {
|
|
1839
|
+
return;
|
|
1840
|
+
}
|
|
1841
|
+
const altFrom = this._getEquivalentSelection(from1);
|
|
1842
|
+
const altTo = this._getEquivalentSelection(to1);
|
|
1843
|
+
if (altFrom === null || altTo === null) {
|
|
1844
|
+
return;
|
|
1845
|
+
}
|
|
1846
|
+
callback(this.score, from1, to1);
|
|
1847
|
+
callback(this.storeScore, altFrom, altTo);
|
|
1848
|
+
const redraw = SmoSelection.getMeasuresBetween(this.score, from1.selector, to1.selector);
|
|
1849
|
+
this.undoStaffModifier('add repl text bracket', modifier, UndoBuffer.bufferSubtypes.ADD);
|
|
1850
|
+
this._renderChangedMeasures(redraw);
|
|
1851
|
+
return this.renderer.updatePromise();
|
|
1852
|
+
}
|
|
1853
|
+
async addOrReplaceTextBracket(modifier: SmoStaffTextBracket) {
|
|
1854
|
+
const from1 = SmoSelection.noteFromSelector(this.score, modifier.startSelector);
|
|
1855
|
+
const to1 = SmoSelection.noteFromSelector(this.score, modifier.endSelector);
|
|
1856
|
+
if (from1 === null || to1 === null) {
|
|
1857
|
+
return;
|
|
1858
|
+
}
|
|
1859
|
+
const altFrom = this._getEquivalentSelection(from1);
|
|
1860
|
+
const altTo = this._getEquivalentSelection(to1);
|
|
1861
|
+
if (altFrom === null || altTo === null) {
|
|
1862
|
+
return;
|
|
1863
|
+
}
|
|
1864
|
+
SmoOperation.addOrReplaceBracket(modifier, from1, to1);
|
|
1865
|
+
SmoOperation.addOrReplaceBracket(modifier, altFrom, altTo);
|
|
1866
|
+
const redraw = SmoSelection.getMeasuresBetween(this.score, from1.selector, to1.selector);
|
|
1867
|
+
this.undoStaffModifier('add repl text bracket', modifier, UndoBuffer.bufferSubtypes.ADD);
|
|
1868
|
+
this._renderChangedMeasures(redraw);
|
|
1869
|
+
return this.renderer.updatePromise();
|
|
1870
|
+
}
|
|
1871
|
+
/**
|
|
1872
|
+
* Slur selected notes
|
|
1873
|
+
* @returns
|
|
1874
|
+
*/
|
|
1875
|
+
async addSlur(): Promise<void> {
|
|
1876
|
+
const measureSelections = SmoSelection.getMeasureList(this.tracker.selections);
|
|
1877
|
+
const ft = this.tracker.getExtremeSelection(-1);
|
|
1878
|
+
const tt = this.tracker.getExtremeSelection(1);
|
|
1879
|
+
const ftAlt = this._getEquivalentSelection(ft);
|
|
1880
|
+
const ttAlt = this._getEquivalentSelection(tt);
|
|
1881
|
+
const modifier = SmoOperation.createSlur(this.score, ft, tt);
|
|
1882
|
+
ft.staff.addStaffModifier(modifier);
|
|
1883
|
+
// make sure score and backup have same ID for undo.
|
|
1884
|
+
const altModifier = SmoOperation.createSlur(this.storeScore, ftAlt!, ttAlt!);
|
|
1885
|
+
altModifier.attrs.id = modifier.attrs.id;
|
|
1886
|
+
ftAlt?.staff.addStaffModifier(altModifier);
|
|
1887
|
+
this.undoStaffModifier('add slur', modifier, UndoBuffer.bufferSubtypes.ADD);
|
|
1888
|
+
this._renderChangedMeasures(measureSelections);
|
|
1889
|
+
return this.renderer.updatePromise();
|
|
1890
|
+
}
|
|
1891
|
+
/**
|
|
1892
|
+
* tie selected notes
|
|
1893
|
+
* @returns
|
|
1894
|
+
*/
|
|
1895
|
+
async tie(): Promise<void> {
|
|
1896
|
+
this.lineOperation(SmoOperation.createTie);
|
|
1897
|
+
return this.renderer.updatePromise();
|
|
1898
|
+
}
|
|
1899
|
+
async updateZoom(zoomFactor: number): Promise<void> {
|
|
1900
|
+
const original = this.score.layoutManager!.getGlobalLayout();
|
|
1901
|
+
original.zoomScale = zoomFactor;
|
|
1902
|
+
this.score.layoutManager!.globalLayout.zoomScale = zoomFactor;
|
|
1903
|
+
this.renderer.pageMap.updateZoom(zoomFactor);
|
|
1904
|
+
this.renderer.pageMap.updateContainerOffset(this.scroller.scrollState);
|
|
1905
|
+
}
|
|
1906
|
+
/**
|
|
1907
|
+
* Keep text groups in the same visual position when a layout changes: rescale by the
|
|
1908
|
+
* svg scale ratio, and by the page width/height ratios. Groups are de-duplicated by
|
|
1909
|
+
* identity, since a part's staves (and the view and store copies, after a part update)
|
|
1910
|
+
* can share the same text group objects, and scaling one twice would double-apply it.
|
|
1911
|
+
* @param textGroups groups to adjust
|
|
1912
|
+
* @param previousLayout layout before the change
|
|
1913
|
+
* @param layout layout after the change
|
|
1914
|
+
*/
|
|
1915
|
+
static repositionTextGroups(textGroups: SmoTextGroup[], previousLayout: SmoGlobalLayout, layout: SmoGlobalLayout) {
|
|
1916
|
+
const scaleChanged = previousLayout.svgScale !== layout.svgScale;
|
|
1917
|
+
const widthChanged = previousLayout.pageWidth !== layout.pageWidth;
|
|
1918
|
+
const heightChanged = previousLayout.pageHeight !== layout.pageHeight;
|
|
1919
|
+
const scaleRatio = previousLayout.svgScale / layout.svgScale;
|
|
1920
|
+
const widthRatio = widthChanged ? layout.pageWidth / previousLayout.pageWidth : 1;
|
|
1921
|
+
const heightRatio = heightChanged ? layout.pageHeight / previousLayout.pageHeight : 1;
|
|
1922
|
+
const unique = new Set<SmoTextGroup>();
|
|
1923
|
+
textGroups.forEach((tg) => unique.add(toRaw(tg)));
|
|
1924
|
+
unique.forEach((tg) => {
|
|
1925
|
+
if (scaleChanged) {
|
|
1926
|
+
tg.scaleText(scaleRatio);
|
|
1927
|
+
}
|
|
1928
|
+
if (widthChanged || heightChanged) {
|
|
1929
|
+
tg.rescalePosition(widthRatio, heightRatio);
|
|
1930
|
+
}
|
|
1931
|
+
});
|
|
1932
|
+
}
|
|
1933
|
+
/**
|
|
1934
|
+
* set global page for score, zoom etc.
|
|
1935
|
+
* @param layout global SVG settings
|
|
1936
|
+
* @param previousLayout the layout as it was immediately before this change. Callers must
|
|
1937
|
+
* pass a snapshot taken before `layout` was mutated -- `this.score.layoutManager`'s current
|
|
1938
|
+
* value cannot be used for this, because dialogs (e.g. globalLayout.ts) bind directly to that
|
|
1939
|
+
* live object, so by the time this method runs it may already equal `layout`.
|
|
1940
|
+
* @returns
|
|
1941
|
+
*/
|
|
1942
|
+
async setGlobalLayout(layout: SmoGlobalLayout, previousLayout: SmoGlobalLayout): Promise<void> {
|
|
1943
|
+
const scaleChanged = previousLayout.svgScale !== layout.svgScale;
|
|
1944
|
+
const widthChanged = previousLayout.pageWidth !== layout.pageWidth;
|
|
1945
|
+
const heightChanged = previousLayout.pageHeight !== layout.pageHeight;
|
|
1946
|
+
if (!scaleChanged && !widthChanged && !heightChanged) {
|
|
1947
|
+
return;
|
|
1948
|
+
}
|
|
1949
|
+
this._undoScore('Set Global Layout');
|
|
1950
|
+
const repositionGroups = (textGroups: SmoTextGroup[]) => {
|
|
1951
|
+
SuiScoreViewOperations.repositionTextGroups(textGroups, previousLayout, layout);
|
|
1952
|
+
};
|
|
1953
|
+
if (this.isPartExposed()) {
|
|
1954
|
+
// A part has its own layoutManager/textGroups (see SuiScoreView._mapPartFormatting,
|
|
1955
|
+
// which aliases this.score.layoutManager/textGroups to staves[0].partInfo's copies), so
|
|
1956
|
+
// only the exposed part's text is repositioned here -- the score's own text groups and
|
|
1957
|
+
// other parts' text groups are untouched.
|
|
1958
|
+
this.score.staves.forEach((staff, staffIx) => {
|
|
1959
|
+
staff.partInfo.layoutManager.updateGlobalLayout(layout);
|
|
1960
|
+
repositionGroups(staff.partInfo.textGroups);
|
|
1961
|
+
const altStaff = this.storeScore.staves[this.staffMap[staffIx]];
|
|
1962
|
+
altStaff.partInfo.layoutManager.updateGlobalLayout(layout);
|
|
1963
|
+
repositionGroups(altStaff.partInfo.textGroups);
|
|
1964
|
+
});
|
|
1965
|
+
} else {
|
|
1966
|
+
this.score.layoutManager!.updateGlobalLayout(layout);
|
|
1967
|
+
repositionGroups(this.score.textGroups);
|
|
1968
|
+
this.storeScore.layoutManager!.updateGlobalLayout(layout);
|
|
1969
|
+
repositionGroups(this.storeScore.textGroups);
|
|
1970
|
+
}
|
|
1971
|
+
this.renderer.rerenderAll();
|
|
1972
|
+
return this.renderer.preserveScroll();
|
|
1973
|
+
}
|
|
1974
|
+
/**
|
|
1975
|
+
* Set the layout of a single page
|
|
1976
|
+
* @param layout page layout
|
|
1977
|
+
* @param pageIndex which page to change
|
|
1978
|
+
* @returns
|
|
1979
|
+
*/
|
|
1980
|
+
async setPageLayout(layout: SmoPageLayout, pageIndex: number) {
|
|
1981
|
+
this.score.layoutManager!.updatePage(layout, pageIndex);
|
|
1982
|
+
this.storeScore.layoutManager!.updatePage(layout, pageIndex);
|
|
1983
|
+
// If we are in part mode, save the page layout in the part so it is there next time
|
|
1984
|
+
// the part is exposed.
|
|
1985
|
+
if (this.isPartExposed()) {
|
|
1986
|
+
this.score.staves.forEach((staff, staffIx) => {
|
|
1987
|
+
staff.partInfo.layoutManager.updatePage(layout, pageIndex);
|
|
1988
|
+
const altStaff = this.storeScore.staves[this.staffMap[staffIx]];
|
|
1989
|
+
altStaff.partInfo.layoutManager.updatePage(layout, pageIndex);
|
|
1990
|
+
});
|
|
1991
|
+
}
|
|
1992
|
+
await this.refreshViewport();
|
|
1993
|
+
}
|
|
1994
|
+
async setPageLayouts(layout: SmoPageLayout, startIndex: number, endIndex: number) {
|
|
1995
|
+
this._undoScore('Set Page Layout');
|
|
1996
|
+
let i = 0;
|
|
1997
|
+
for (i = startIndex; i <= endIndex; ++i) {
|
|
1998
|
+
this.setPageLayout(layout, i);
|
|
1999
|
+
}
|
|
2000
|
+
this.renderer.rerenderAll();
|
|
2001
|
+
return this.renderer.updatePromise();
|
|
2002
|
+
}
|
|
2003
|
+
/**
|
|
2004
|
+
* Update the music font
|
|
2005
|
+
* @param family
|
|
2006
|
+
* @returns
|
|
2007
|
+
*/
|
|
2008
|
+
async setEngravingFontFamily(family: engravingFontType): Promise<void> {
|
|
2009
|
+
this.score.engravingFont = family;
|
|
2010
|
+
this.storeScore.engravingFont = family;
|
|
2011
|
+
this.renderer.notifyFontChange();
|
|
2012
|
+
this.renderer.setRefresh();
|
|
2013
|
+
return this.renderer.updatePromise();
|
|
2014
|
+
}
|
|
2015
|
+
/**
|
|
2016
|
+
* Upate global font used for chord changes
|
|
2017
|
+
* @param fontInfo
|
|
2018
|
+
* @returns
|
|
2019
|
+
*/
|
|
2020
|
+
async setChordFont(fontInfo: FontInfo): Promise<void> {
|
|
2021
|
+
this._undoScore('Set Chord Font');
|
|
2022
|
+
this.score.setChordFont(fontInfo);
|
|
2023
|
+
this.storeScore.setChordFont(fontInfo);
|
|
2024
|
+
this.renderer.setRefresh();
|
|
2025
|
+
return this.renderer.updatePromise();
|
|
2026
|
+
}
|
|
2027
|
+
/**
|
|
2028
|
+
* Update font used for lyrics
|
|
2029
|
+
* @param fontInfo
|
|
2030
|
+
* @returns
|
|
2031
|
+
*/
|
|
2032
|
+
async setLyricFont(fontInfo: FontInfo): Promise<void> {
|
|
2033
|
+
this._undoScore('Set Lyric Font');
|
|
2034
|
+
this.score.setLyricFont(fontInfo);
|
|
2035
|
+
this.storeScore.setLyricFont(fontInfo);
|
|
2036
|
+
this.renderer.setRefresh();
|
|
2037
|
+
return this.renderer.updatePromise();
|
|
2038
|
+
}
|
|
2039
|
+
/**
|
|
2040
|
+
* @param value if false, lyric widths don't affect measure width
|
|
2041
|
+
* @returns
|
|
2042
|
+
*/
|
|
2043
|
+
async setLyricAdjustWidth(value: boolean): Promise<void> {
|
|
2044
|
+
this._undoScore('Set Lyric Adj Width');
|
|
2045
|
+
this.score.setLyricAdjustWidth(value);
|
|
2046
|
+
this.storeScore.setLyricAdjustWidth(value);
|
|
2047
|
+
this.renderer.setRefresh();
|
|
2048
|
+
return this.renderer.updatePromise();
|
|
2049
|
+
}
|
|
2050
|
+
/**
|
|
2051
|
+
* delete selected measures
|
|
2052
|
+
* @returns
|
|
2053
|
+
*/
|
|
2054
|
+
async deleteMeasure(): Promise<void> {
|
|
2055
|
+
this._undoScore('Delete Measure');
|
|
2056
|
+
if (this.storeScore.staves[0].measures.length < 2) {
|
|
2057
|
+
return;
|
|
2058
|
+
}
|
|
2059
|
+
const selections = SmoSelection.getMeasureList(this.tracker.selections);
|
|
2060
|
+
// THe measures get renumbered, so keep the index at 0
|
|
2061
|
+
const index = selections[0].selector.measure;
|
|
2062
|
+
for (var i = 0; i < selections.length; ++i) {
|
|
2063
|
+
// Unrender the deleted measure
|
|
2064
|
+
this.score.staves.forEach((staff) => {
|
|
2065
|
+
this.tracker.clearMeasureMap(staff.measures[index]);
|
|
2066
|
+
this.renderer.unrenderMeasure(staff.measures[index]);
|
|
2067
|
+
this.renderer.unrenderMeasure(staff.measures[staff.measures.length - 1]);
|
|
2068
|
+
// A little hacky - delete the modifiers if they start or end on
|
|
2069
|
+
// the measure
|
|
2070
|
+
staff.renderableModifiers.forEach((modifier) => {
|
|
2071
|
+
if (modifier.startSelector.measure === index || modifier.endSelector.measure === index) {
|
|
2072
|
+
if (modifier.logicalBox) {
|
|
2073
|
+
const context = this.renderer.renderer.getRenderer(modifier.logicalBox);
|
|
2074
|
+
if (context) {
|
|
2075
|
+
$(context.svg).find('g.' + modifier.attrs.id).remove();
|
|
2076
|
+
}
|
|
2077
|
+
}
|
|
2078
|
+
}
|
|
2079
|
+
});
|
|
2080
|
+
});
|
|
2081
|
+
// Remove the SVG artifacts mapped to this measure.
|
|
2082
|
+
this.score.deleteMeasure(index);
|
|
2083
|
+
this.storeScore.deleteMeasure(index);
|
|
2084
|
+
// Note: index doesn't increment since there are now 1 fewer measures
|
|
2085
|
+
};
|
|
2086
|
+
this.renderer.setRefresh();
|
|
2087
|
+
return this.renderer.updatePromise();
|
|
2088
|
+
}
|
|
2089
|
+
/**
|
|
2090
|
+
* add number of measures, with default notes selections
|
|
2091
|
+
* @param append
|
|
2092
|
+
* @param numberToAdd
|
|
2093
|
+
* @returns
|
|
2094
|
+
*/
|
|
2095
|
+
async addMeasures(append: boolean, numberToAdd: number): Promise<void> {
|
|
2096
|
+
let pos = 0;
|
|
2097
|
+
let ix = 0;
|
|
2098
|
+
this._undoScore('Add Measure');
|
|
2099
|
+
for (ix = 0; ix < numberToAdd; ++ix) {
|
|
2100
|
+
const measure = this.tracker.getFirstMeasureOfSelection();
|
|
2101
|
+
if (measure) {
|
|
2102
|
+
const nmeasure = SmoMeasure.getDefaultMeasureWithNotes(measure);
|
|
2103
|
+
pos = measure.measureNumber.measureIndex;
|
|
2104
|
+
if (append) {
|
|
2105
|
+
pos += 1;
|
|
2106
|
+
}
|
|
2107
|
+
nmeasure.measureNumber.measureIndex = pos;
|
|
2108
|
+
nmeasure.setActiveVoice(0);
|
|
2109
|
+
this.score.addMeasure(pos);
|
|
2110
|
+
this.storeScore.addMeasure(pos);
|
|
2111
|
+
}
|
|
2112
|
+
}
|
|
2113
|
+
const startMeasure = Math.max(pos - (ix - 1), 0);
|
|
2114
|
+
const startSelector = SmoSelector.default;
|
|
2115
|
+
const endSelector = SmoSelector.default;
|
|
2116
|
+
startSelector.measure = startMeasure;
|
|
2117
|
+
endSelector.measure = pos;
|
|
2118
|
+
this._renderRectangle(startSelector, endSelector);
|
|
2119
|
+
this.renderer.setRefresh();
|
|
2120
|
+
return this.renderer.updatePromise();
|
|
2121
|
+
}
|
|
2122
|
+
/**
|
|
2123
|
+
* add a single measure before or after selection
|
|
2124
|
+
* @param append
|
|
2125
|
+
* @returns
|
|
2126
|
+
*/
|
|
2127
|
+
async addMeasure(append: boolean): Promise<void> {
|
|
2128
|
+
this._undoScore('Add Measure');
|
|
2129
|
+
let pos = 0;
|
|
2130
|
+
const measure = this.tracker.getFirstMeasureOfSelection();
|
|
2131
|
+
if (!measure) {
|
|
2132
|
+
return;
|
|
2133
|
+
}
|
|
2134
|
+
const nmeasure = SmoMeasure.getDefaultMeasureWithNotes(measure);
|
|
2135
|
+
pos = measure.measureNumber.measureIndex;
|
|
2136
|
+
if (append) {
|
|
2137
|
+
pos += 1;
|
|
2138
|
+
}
|
|
2139
|
+
nmeasure.measureNumber.measureIndex = pos;
|
|
2140
|
+
nmeasure.setActiveVoice(0);
|
|
2141
|
+
this.score.addMeasure(pos);
|
|
2142
|
+
this.storeScore.addMeasure(pos);
|
|
2143
|
+
this.renderer.clearLine(measure);
|
|
2144
|
+
this.renderer.setRefresh();
|
|
2145
|
+
return this.renderer.updatePromise();
|
|
2146
|
+
}
|
|
2147
|
+
/**
|
|
2148
|
+
* remove an entire line of music
|
|
2149
|
+
* @returns
|
|
2150
|
+
*/
|
|
2151
|
+
async removeStaff(): Promise<void> {
|
|
2152
|
+
this._undoScore('Remove Instrument');
|
|
2153
|
+
if (this.storeScore.staves.length < 2 || this.score.staves.length < 2) {
|
|
2154
|
+
return;
|
|
2155
|
+
}
|
|
2156
|
+
// if we are looking at a subset of the score,
|
|
2157
|
+
// revert to the full score view before removing the staff.
|
|
2158
|
+
const toRemove: number[] = [];
|
|
2159
|
+
const selectedStaves: Record<number, boolean> = {};
|
|
2160
|
+
this.tracker.selections.forEach((sel) => {
|
|
2161
|
+
const scoreSel = this._getEquivalentSelection(sel);
|
|
2162
|
+
if (!selectedStaves[scoreSel!.selector.staff]) {
|
|
2163
|
+
selectedStaves[scoreSel!.selector.staff] = true;
|
|
2164
|
+
toRemove.push(scoreSel!.selector.staff);
|
|
2165
|
+
}
|
|
2166
|
+
});
|
|
2167
|
+
// Sort in descending order so we don't mess up the staff indices as we remove
|
|
2168
|
+
toRemove.sort((a, b) => b - a);
|
|
2169
|
+
toRemove.forEach((staffIndex) => {
|
|
2170
|
+
SmoOperation.removeStaff(this.storeScore, staffIndex);
|
|
2171
|
+
});
|
|
2172
|
+
this.viewAll();
|
|
2173
|
+
this.renderer.setRefresh();
|
|
2174
|
+
return this.renderer.updatePromise();
|
|
2175
|
+
}
|
|
2176
|
+
/**
|
|
2177
|
+
* Add a new staff to an existing score, with default instrument for the staff part.
|
|
2178
|
+
* We base the staff parameters on a stave that currently exists in the score.
|
|
2179
|
+
* @param instrument
|
|
2180
|
+
* @returns
|
|
2181
|
+
*/
|
|
2182
|
+
async addStaff(instrument: SmoSystemStaffParams): Promise<void> {
|
|
2183
|
+
this._undoScore('Add Instrument');
|
|
2184
|
+
// if we are looking at a subset of the score, we won't see the new staff. So
|
|
2185
|
+
// revert to the full view
|
|
2186
|
+
const entry = instrument.measureInstrumentMap[0];
|
|
2187
|
+
entry.startSelector.measure = 0;
|
|
2188
|
+
entry.endSelector.measure = this.storeScore.staves[0].measures.length - 1;
|
|
2189
|
+
const staff = SmoOperation.addStaff(this.storeScore, instrument);
|
|
2190
|
+
staff.updateInstrumentOffsets();
|
|
2191
|
+
this.storeScore.setNoteInstrumentProperties();
|
|
2192
|
+
|
|
2193
|
+
if (instrument.staffId > 0) {
|
|
2194
|
+
const selection = SmoSelection.measureSelection(this.storeScore, instrument.staffId - 1, 0);
|
|
2195
|
+
const sel = SmoSelector.default;
|
|
2196
|
+
sel.staff = instrument.staffId - 1;
|
|
2197
|
+
if (selection) {
|
|
2198
|
+
let grp = this.storeScore.getSystemGroupForStaff(selection);
|
|
2199
|
+
if (grp) {
|
|
2200
|
+
grp.endSelector.staff = instrument.staffId;
|
|
2201
|
+
} else {
|
|
2202
|
+
let grp = new SmoSystemGroup(SmoSystemGroup.defaults);
|
|
2203
|
+
grp.startSelector.staff = instrument.staffId - 1;
|
|
2204
|
+
grp.endSelector.staff = instrument.staffId;
|
|
2205
|
+
this.storeScore.systemGroups.push(grp);
|
|
2206
|
+
}
|
|
2207
|
+
}
|
|
2208
|
+
}
|
|
2209
|
+
this.viewAll();
|
|
2210
|
+
return this.renderer.updatePromise();
|
|
2211
|
+
}
|
|
2212
|
+
/**
|
|
2213
|
+
* Update part info assumes that the part is currently exposed - that
|
|
2214
|
+
* staff 0 is the first staff in the part prior to editing.
|
|
2215
|
+
* @param info
|
|
2216
|
+
*/
|
|
2217
|
+
async updatePartInfo(info: SmoPartInfo): Promise<void> {
|
|
2218
|
+
let i: number = 0;
|
|
2219
|
+
this._undoScore('Update part info');
|
|
2220
|
+
const storeStaff = this.staffMap[0] - info.stavesBefore;
|
|
2221
|
+
const partLength = info.stavesBefore + info.stavesAfter + 1;
|
|
2222
|
+
const resetView = !SmoLayoutManager.areLayoutsEqual(info.layoutManager.getGlobalLayout(), this.score.layoutManager!.getGlobalLayout());
|
|
2223
|
+
const restChange = this.score.staves[0].partInfo.expandMultimeasureRests != info.expandMultimeasureRests;
|
|
2224
|
+
const stavesChange = this.score.staves[0].partInfo.stavesAfter !== info.stavesAfter;
|
|
2225
|
+
// The displayed part's layout has not been replaced yet, so it is the 'before' value.
|
|
2226
|
+
// Reposition the part's text groups the same way setGlobalLayout does for the score.
|
|
2227
|
+
const previousLayout = this.score.layoutManager!.getGlobalLayout();
|
|
2228
|
+
const newLayout = info.layoutManager.getGlobalLayout();
|
|
2229
|
+
if (previousLayout.svgScale !== newLayout.svgScale || previousLayout.pageWidth !== newLayout.pageWidth ||
|
|
2230
|
+
previousLayout.pageHeight !== newLayout.pageHeight) {
|
|
2231
|
+
const partText: SmoTextGroup[] = [];
|
|
2232
|
+
for (i = 0; i < partLength; ++i) {
|
|
2233
|
+
partText.push(...(this.storeScore.staves[storeStaff + i]?.partInfo.textGroups ?? []));
|
|
2234
|
+
partText.push(...(this.score.staves[i]?.partInfo.textGroups ?? []));
|
|
2235
|
+
}
|
|
2236
|
+
SuiScoreViewOperations.repositionTextGroups(partText, previousLayout, newLayout);
|
|
2237
|
+
}
|
|
2238
|
+
this.PartName.value = info.partName;
|
|
2239
|
+
for (i = 0; i < partLength; ++i) {
|
|
2240
|
+
const nStaffIndex = storeStaff + i;
|
|
2241
|
+
const nInfo = new SmoPartInfo(info);
|
|
2242
|
+
nInfo.stavesBefore = i;
|
|
2243
|
+
nInfo.stavesAfter = partLength - i - 1;
|
|
2244
|
+
this.storeScore.staves[nStaffIndex].partInfo = nInfo;
|
|
2245
|
+
// Make sure that the next stave in the score has the correct 'staves before' setting
|
|
2246
|
+
if (this.storeScore.staves.length > nStaffIndex + 1) {
|
|
2247
|
+
if (nInfo.stavesAfter === 0) {
|
|
2248
|
+
const nextStaff = this.storeScore.staves[nStaffIndex + 1];
|
|
2249
|
+
nextStaff.partInfo.stavesBefore = 0;
|
|
2250
|
+
const nextStaffDisplayIndex = this.staffMap.findIndex((x) => x === nStaffIndex + 1);
|
|
2251
|
+
if (nextStaffDisplayIndex >= 0) {
|
|
2252
|
+
this.score.staves[nextStaffDisplayIndex].partInfo =
|
|
2253
|
+
new SmoPartInfo(nextStaff.partInfo);
|
|
2254
|
+
}
|
|
2255
|
+
}
|
|
2256
|
+
}
|
|
2257
|
+
// If the staff index is currently displayed,
|
|
2258
|
+
const displayedIndex = this.staffMap.findIndex((x) => x === nStaffIndex);
|
|
2259
|
+
if (displayedIndex >= 0) {
|
|
2260
|
+
this.score.staves[displayedIndex].partInfo = new SmoPartInfo(nInfo);
|
|
2261
|
+
this.score.layoutManager = nInfo.layoutManager;
|
|
2262
|
+
}
|
|
2263
|
+
}
|
|
2264
|
+
if (resetView || restChange || stavesChange) {
|
|
2265
|
+
SmoOperation.computeMultipartRest(this.score);
|
|
2266
|
+
// this.resetPartView();
|
|
2267
|
+
this.renderer.rerenderAll()
|
|
2268
|
+
}
|
|
2269
|
+
return this.renderer.updatePromise();
|
|
2270
|
+
}
|
|
2271
|
+
/**
|
|
2272
|
+
* A simpler API for applications to add a new staff to the score.
|
|
2273
|
+
* @param params - the instrument, which determines clef, etc.
|
|
2274
|
+
* @returns
|
|
2275
|
+
*/
|
|
2276
|
+
async addStaffSimple(params: Partial<SmoInstrumentParams>): Promise<void> {
|
|
2277
|
+
const instrumentParams = SmoInstrument.defaults;
|
|
2278
|
+
instrumentParams.startSelector.staff = instrumentParams.endSelector.staff = this.score.staves.length;
|
|
2279
|
+
instrumentParams.clef = params.clef ?? instrumentParams.clef;
|
|
2280
|
+
|
|
2281
|
+
const staffParams = SmoSystemStaff.defaults;
|
|
2282
|
+
staffParams.staffId = this.storeScore.staves.length; // add a staff
|
|
2283
|
+
staffParams.measureInstrumentMap[0] = new SmoInstrument(instrumentParams);
|
|
2284
|
+
this.addStaff(staffParams);
|
|
2285
|
+
return this.renderer.updatePromise();
|
|
2286
|
+
}
|
|
2287
|
+
/**
|
|
2288
|
+
* Save the score to local storage.
|
|
2289
|
+
*/
|
|
2290
|
+
quickSave() {
|
|
2291
|
+
const scoreStr = JSON.stringify(this.storeScore.serialize());
|
|
2292
|
+
localStorage.setItem(smoSerialize.localScore, scoreStr);
|
|
2293
|
+
this.markScoreSaved();
|
|
2294
|
+
}
|
|
2295
|
+
/**
|
|
2296
|
+
* Called when the user has saved the score to a file. Only a save in the full Smoosic
|
|
2297
|
+
* format counts: other formats (MusicXML, MIDI...) lose information, so the score still
|
|
2298
|
+
* has unsaved changes. The save dialog doesn't know which formats are lossy; we do.
|
|
2299
|
+
* @param extension the extension of the file that was saved, e.g. '.json'
|
|
2300
|
+
* @returns true if the score is now considered saved
|
|
2301
|
+
*/
|
|
2302
|
+
recordSave(extension: string): boolean {
|
|
2303
|
+
if (!isFullSaveFormat(extension)) {
|
|
2304
|
+
return false;
|
|
2305
|
+
}
|
|
2306
|
+
this.markScoreSaved();
|
|
2307
|
+
return true;
|
|
2308
|
+
}
|
|
2309
|
+
updateRepeatCount(count: number) {
|
|
2310
|
+
const measureSelections = this.undoTrackerMeasureSelections('repeat bar');
|
|
2311
|
+
const symbol = count > 0 ? true : false;
|
|
2312
|
+
measureSelections.forEach((ms) => {
|
|
2313
|
+
const store = this._getEquivalentSelection(ms);
|
|
2314
|
+
ms.measure.repeatCount = count;
|
|
2315
|
+
ms.measure.repeatSymbol = symbol;
|
|
2316
|
+
if (store) {
|
|
2317
|
+
store.measure.repeatCount = count;
|
|
2318
|
+
store.measure.repeatSymbol = symbol;
|
|
2319
|
+
}
|
|
2320
|
+
});
|
|
2321
|
+
this._renderChangedMeasures(measureSelections);
|
|
2322
|
+
return this.updatePromise();
|
|
2323
|
+
}
|
|
2324
|
+
/**
|
|
2325
|
+
* Update the measure formatting parameters for the current selection
|
|
2326
|
+
* @param format generic measure formatting parameters
|
|
2327
|
+
* @returns
|
|
2328
|
+
*/
|
|
2329
|
+
setMeasureFormat(format: SmoMeasureFormat): Promise<any> {
|
|
2330
|
+
const label = 'set measure format';
|
|
2331
|
+
const fromSelector = this.tracker.getExtremeSelection(-1).selector;
|
|
2332
|
+
const toSelector = this.tracker.getExtremeSelection(1).selector;
|
|
2333
|
+
const measureSelections = this.tracker.getSelectedMeasures();
|
|
2334
|
+
// If the formatting is on a part, preserve it in the part's info
|
|
2335
|
+
const isPart = this.isPartExposed();
|
|
2336
|
+
measureSelections.forEach((m) => {
|
|
2337
|
+
this._undoColumn(label, m.selector.measure);
|
|
2338
|
+
SmoOperation.setMeasureFormat(this.score, m, format);
|
|
2339
|
+
if (isPart) {
|
|
2340
|
+
m.staff.partInfo.measureFormatting[m.measure.measureNumber.measureIndex] = new SmoMeasureFormat(format);
|
|
2341
|
+
const alt = this._getEquivalentSelection(m);
|
|
2342
|
+
SmoOperation.setMeasureFormat(this.storeScore, alt!, format);
|
|
2343
|
+
} else {
|
|
2344
|
+
// If we are seeing some set of staves that is not a part, make sure the whole column in the
|
|
2345
|
+
// score is updated.
|
|
2346
|
+
const firstRow = SmoSelection.selectionFromSelector(
|
|
2347
|
+
this.storeScore, {
|
|
2348
|
+
staff: 0, measure: m.selector.measure, voice: m.selector.voice, tick: m.selector.tick, pitches: [] }
|
|
2349
|
+
)
|
|
2350
|
+
SmoOperation.setMeasureFormat(this.storeScore, firstRow!, format);
|
|
2351
|
+
}
|
|
2352
|
+
const alt = this._getEquivalentSelection(m);
|
|
2353
|
+
SmoOperation.setMeasureFormat(this.storeScore, alt!, format);
|
|
2354
|
+
if (isPart) {
|
|
2355
|
+
alt!.staff.partInfo.measureFormatting[m.measure.measureNumber.measureIndex] = new SmoMeasureFormat(format);
|
|
2356
|
+
}
|
|
2357
|
+
});
|
|
2358
|
+
this._renderRectangle(fromSelector, toSelector);
|
|
2359
|
+
return this.renderer.updatePromise();
|
|
2360
|
+
}
|
|
2361
|
+
/**
|
|
2362
|
+
* Remove system breaks from the measure formatting for selected measures
|
|
2363
|
+
* @returns
|
|
2364
|
+
*/
|
|
2365
|
+
removeSystemBreaks(): Promise<any> {
|
|
2366
|
+
const label = 'set measure format';
|
|
2367
|
+
const fromSelector = this.tracker.getExtremeSelection(-1).selector;
|
|
2368
|
+
const toSelector = this.tracker.getExtremeSelection(1).selector;
|
|
2369
|
+
const measureSelections = this.tracker.getSelectedMeasures();
|
|
2370
|
+
// If the formatting is on a part, preserve it in the part's info
|
|
2371
|
+
const isPart = this.isPartExposed();
|
|
2372
|
+
measureSelections.forEach((m) => {
|
|
2373
|
+
this._undoColumn(label, m.selector.measure);
|
|
2374
|
+
const format = new SmoMeasureFormat(m.measure.format);
|
|
2375
|
+
format.systemBreak = false;
|
|
2376
|
+
SmoOperation.setMeasureFormat(this.score, m, format);
|
|
2377
|
+
if (isPart) {
|
|
2378
|
+
m.staff.partInfo.measureFormatting[m.measure.measureNumber.measureIndex] = new SmoMeasureFormat(format);
|
|
2379
|
+
}
|
|
2380
|
+
const alt = this._getEquivalentSelection(m);
|
|
2381
|
+
SmoOperation.setMeasureFormat(this.storeScore, alt!, format);
|
|
2382
|
+
if (isPart) {
|
|
2383
|
+
alt!.staff.partInfo.measureFormatting[m.measure.measureNumber.measureIndex] = new SmoMeasureFormat(format);
|
|
2384
|
+
}
|
|
2385
|
+
});
|
|
2386
|
+
this._renderRectangle(fromSelector, toSelector);
|
|
2387
|
+
return this.renderer.updatePromise();
|
|
2388
|
+
}
|
|
2389
|
+
renumberMeasures(measureIndex: number, displayIndex: number) {
|
|
2390
|
+
this.score.updateRenumberingMap(measureIndex, displayIndex);
|
|
2391
|
+
this.storeScore.updateRenumberingMap(measureIndex, displayIndex);
|
|
2392
|
+
const mmsel = SmoSelection.measureSelection(this.score, 0, measureIndex);
|
|
2393
|
+
if (mmsel) {
|
|
2394
|
+
this._renderChangedMeasures([mmsel]);
|
|
2395
|
+
}
|
|
2396
|
+
return this.renderer.updatePromise();
|
|
2397
|
+
}
|
|
2398
|
+
/**
|
|
2399
|
+
* Play the music from the starting selection
|
|
2400
|
+
* @returns
|
|
2401
|
+
*/
|
|
2402
|
+
async playFromSelection() {
|
|
2403
|
+
var mm = this.tracker.getExtremeSelection(-1);
|
|
2404
|
+
if (SuiAudioPlayer.playingInstance && SuiAudioPlayer.playingInstance.paused) {
|
|
2405
|
+
SuiAudioPlayer.playingInstance.play();
|
|
2406
|
+
return;
|
|
2407
|
+
}
|
|
2408
|
+
if (SuiAudioPlayer.playing) {
|
|
2409
|
+
return;
|
|
2410
|
+
}
|
|
2411
|
+
new SuiAudioPlayer({ audioAnimation: this.audioAnimation, score: this.score, startIndex: mm.selector.measure, view: this }).play();
|
|
2412
|
+
}
|
|
2413
|
+
stopPlayer() {
|
|
2414
|
+
SuiAudioPlayer.stopPlayer();
|
|
2415
|
+
}
|
|
2416
|
+
pausePlayer() {
|
|
2417
|
+
SuiAudioPlayer.pausePlayer();
|
|
2418
|
+
}
|
|
2419
|
+
|
|
2420
|
+
/**
|
|
2421
|
+
* Proxy calls to move the tracker parameters according to the
|
|
2422
|
+
* rules of the 'Home' key (depending on shift/ctrl/alt)
|
|
2423
|
+
* @param ev
|
|
2424
|
+
* @returns
|
|
2425
|
+
*/
|
|
2426
|
+
async moveHome(ev: KeyEvent): Promise<any> {
|
|
2427
|
+
this.tracker.moveHome(ev);
|
|
2428
|
+
await this.renderer.updatePromise();
|
|
2429
|
+
}
|
|
2430
|
+
/**
|
|
2431
|
+
* Proxy calls to move the tracker parameters according to the
|
|
2432
|
+
* rules of the 'End' key (depending on shift/ctrl/alt)
|
|
2433
|
+
* @param ev
|
|
2434
|
+
* @returns
|
|
2435
|
+
*/
|
|
2436
|
+
async moveEnd(ev: KeyEvent): Promise<any> {
|
|
2437
|
+
this.tracker.moveEnd(ev);
|
|
2438
|
+
await this.renderer.updatePromise();
|
|
2439
|
+
}
|
|
2440
|
+
/**
|
|
2441
|
+
* Grow the current selection by one to the left, if possible
|
|
2442
|
+
* @param ev
|
|
2443
|
+
* @returns
|
|
2444
|
+
*/
|
|
2445
|
+
async growSelectionLeft(): Promise<any> {
|
|
2446
|
+
this.tracker.growSelectionLeft();
|
|
2447
|
+
await this.renderer.updatePromise();
|
|
2448
|
+
}
|
|
2449
|
+
/**
|
|
2450
|
+
* Grow the current selection by one to the right, if possible
|
|
2451
|
+
* @param ev
|
|
2452
|
+
* @returns
|
|
2453
|
+
*/
|
|
2454
|
+
async growSelectionRight(): Promise<any> {
|
|
2455
|
+
this.tracker.growSelectionRight();
|
|
2456
|
+
await this.renderer.updatePromise();
|
|
2457
|
+
}
|
|
2458
|
+
/**
|
|
2459
|
+
* Select the next tabbable modifier near one of the selected notes
|
|
2460
|
+
* @param keyEv
|
|
2461
|
+
* @returns
|
|
2462
|
+
*/
|
|
2463
|
+
async advanceModifierSelection(keyEv: KeyEvent): Promise<any> {
|
|
2464
|
+
this.tracker.advanceModifierSelection(keyEv);
|
|
2465
|
+
await this.renderer.updatePromise();
|
|
2466
|
+
}
|
|
2467
|
+
/**
|
|
2468
|
+
* Select the next entire measure, if possible
|
|
2469
|
+
* @returns
|
|
2470
|
+
*/
|
|
2471
|
+
async growSelectionRightMeasure(): Promise<any> {
|
|
2472
|
+
this.tracker.growSelectionRightMeasure();
|
|
2473
|
+
await this.renderer.updatePromise();
|
|
2474
|
+
}
|
|
2475
|
+
/**
|
|
2476
|
+
* Advance cursor forwards, if possible
|
|
2477
|
+
* @param ev
|
|
2478
|
+
* @returns
|
|
2479
|
+
*/
|
|
2480
|
+
async moveSelectionRight(): Promise<any> {
|
|
2481
|
+
this.tracker.moveSelectionRight();
|
|
2482
|
+
await this.renderer.updatePromise();
|
|
2483
|
+
}
|
|
2484
|
+
/**
|
|
2485
|
+
* Advance cursor backwards, if possible
|
|
2486
|
+
* @param ev
|
|
2487
|
+
* @returns
|
|
2488
|
+
*/
|
|
2489
|
+
async moveSelectionLeft(): Promise<any> {
|
|
2490
|
+
this.tracker.moveSelectionLeft();
|
|
2491
|
+
await this.renderer.updatePromise();
|
|
2492
|
+
}
|
|
2493
|
+
/**
|
|
2494
|
+
* Advance cursor back entire measure, if possible
|
|
2495
|
+
* @returns
|
|
2496
|
+
*/
|
|
2497
|
+
async moveSelectionLeftMeasure(): Promise<any> {
|
|
2498
|
+
this.tracker.moveSelectionLeftMeasure();
|
|
2499
|
+
await this.renderer.updatePromise();
|
|
2500
|
+
}
|
|
2501
|
+
/**
|
|
2502
|
+
* Advance cursor forward one measure, if possible
|
|
2503
|
+
* @returns
|
|
2504
|
+
*/
|
|
2505
|
+
async moveSelectionRightMeasure(): Promise<any> {
|
|
2506
|
+
this.tracker.moveSelectionRightMeasure();
|
|
2507
|
+
await this.renderer.updatePromise();
|
|
2508
|
+
}
|
|
2509
|
+
/**
|
|
2510
|
+
* Move cursor to a higher pitch in the current chord, with wrap
|
|
2511
|
+
* @returns
|
|
2512
|
+
*/
|
|
2513
|
+
async moveSelectionPitchUp(): Promise<any> {
|
|
2514
|
+
this.tracker.moveSelectionPitchUp();
|
|
2515
|
+
await this.renderer.updatePromise();
|
|
2516
|
+
}
|
|
2517
|
+
/**
|
|
2518
|
+
* Move cursor to a lower pitch in the current chord, with wrap
|
|
2519
|
+
*/
|
|
2520
|
+
async moveSelectionPitchDown(): Promise<any> {
|
|
2521
|
+
this.tracker.moveSelectionPitchDown();
|
|
2522
|
+
await this.renderer.updatePromise();
|
|
2523
|
+
}
|
|
2524
|
+
/**
|
|
2525
|
+
* Move cursor up a staff in the system, if possible
|
|
2526
|
+
* @returns
|
|
2527
|
+
*/
|
|
2528
|
+
async moveSelectionUp(): Promise<any> {
|
|
2529
|
+
this.tracker.moveSelectionUp();
|
|
2530
|
+
await this.renderer.updatePromise();
|
|
2531
|
+
}
|
|
2532
|
+
/**
|
|
2533
|
+
* Move cursor down a staff in the system, if possible
|
|
2534
|
+
* @returns
|
|
2535
|
+
*/
|
|
2536
|
+
async moveSelectionDown(): Promise<any> {
|
|
2537
|
+
this.tracker.moveSelectionDown();
|
|
2538
|
+
await this.renderer.updatePromise();
|
|
2539
|
+
}
|
|
2540
|
+
/**
|
|
2541
|
+
* Set the current suggestions (hover element) as the selection
|
|
2542
|
+
* @returns
|
|
2543
|
+
*/
|
|
2544
|
+
async selectSuggestion(evData: KeyEvent): Promise<any> {
|
|
2545
|
+
this.tracker.selectSuggestion(evData);
|
|
2546
|
+
await this.renderer.updatePromise();
|
|
2547
|
+
}
|
|
2548
|
+
/**
|
|
2549
|
+
* Find an element at the given box, and make it the current selection
|
|
2550
|
+
* */
|
|
2551
|
+
async intersectingArtifact(evData: SvgBox): Promise<any> {
|
|
2552
|
+
this.tracker.intersectingArtifact(evData);
|
|
2553
|
+
await this.renderer.updatePromise();
|
|
2554
|
+
}
|
|
2555
|
+
}
|