smoosic 2.0.4 → 2.0.5
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 +23 -12
- package/changes.md +10 -0
- package/package.json +100 -98
- package/release/smoosic.js +23 -12
- package/specs/042-preserve-music-time-signature/checklists/requirements.md +35 -0
- package/specs/042-preserve-music-time-signature/contracts/rebar-api.md +66 -0
- package/specs/042-preserve-music-time-signature/data-model.md +73 -0
- package/specs/042-preserve-music-time-signature/plan.md +93 -0
- package/specs/042-preserve-music-time-signature/quickstart.md +37 -0
- package/specs/042-preserve-music-time-signature/research.md +102 -0
- package/specs/042-preserve-music-time-signature/spec.md +153 -0
- package/specs/042-preserve-music-time-signature/tasks.md +104 -0
- package/src/application/exports.ts +1 -0
- package/src/render/sui/renderState.ts +4 -4
- package/src/render/sui/scoreViewOperations.ts +58 -3
- package/src/render/sui/tracker.ts +18 -23
- package/src/smo/data/score.ts +12 -5
- package/src/smo/xform/operations.ts +49 -0
- package/src/smo/xform/rebar.ts +490 -0
- package/src/smo/xform/selections.ts +66 -0
- package/src/ui/components/dialogs/timeSignature.vue +13 -3
- package/src/ui/dialogs/timeSignature.ts +27 -39
- package/tests/rebarMeasures.ts +492 -0
- package/tests/timeRangeSelect.ts +111 -0
- package/typedoc.ts +1 -0
- package/types/src/application/exports.d.ts +1 -0
- package/types/src/render/sui/scoreViewOperations.d.ts +19 -2
- package/types/src/smo/data/score.d.ts +5 -2
- package/types/src/smo/xform/operations.d.ts +24 -0
- package/types/src/smo/xform/rebar.d.ts +53 -0
- package/types/src/smo/xform/selections.d.ts +14 -0
- package/types/typedoc.d.ts +1 -0
|
@@ -10,6 +10,7 @@ import { SmoTextGroup } from '../../smo/data/scoreText';
|
|
|
10
10
|
import { SmoDynamicText, SmoArticulation, SmoOrnament, SmoLyric, SmoArpeggioType, SmoClefChange, SmoTabNote } from '../../smo/data/noteModifiers';
|
|
11
11
|
import { SmoTempo, SmoVolta, SmoRehearsalMark, SmoMeasureFormat, SmoTimeSignature } from '../../smo/data/measureModifiers';
|
|
12
12
|
import { UndoBuffer } from '../../smo/xform/undo';
|
|
13
|
+
import { TimeSignatureApplyTo } from '../../smo/xform/rebar';
|
|
13
14
|
import { createStaffModifierType, MakeTupletOperation } from '../../smo/xform/operations';
|
|
14
15
|
import { BatchSelectionOperation, AddPartParams, DeleteAttributeKind } from '../../smo/xform/operations';
|
|
15
16
|
import { MeasureFillType } from '../../smo/xform/measureFill';
|
|
@@ -18,6 +19,16 @@ import { PasteAttributeOptions } from '../../smo/xform/copypaste';
|
|
|
18
19
|
import { SmoSelection, SmoSelector } from '../../smo/xform/selections';
|
|
19
20
|
import { StaffModifierBase, SmoInstrument, SmoInstrumentParams, SmoStaffTextBracket, SmoTabStave } from '../../smo/data/staffModifiers';
|
|
20
21
|
import { AutosaveEntry } from './autosave';
|
|
22
|
+
/**
|
|
23
|
+
* How {@link SuiScoreViewOperations.setTimeSignature} chooses the measures and treats their music
|
|
24
|
+
* @category SuiRender
|
|
25
|
+
*/
|
|
26
|
+
export interface SetTimeSignatureOptions {
|
|
27
|
+
/** which measures to change. Default is the selected measures */
|
|
28
|
+
applyTo?: TimeSignatureApplyTo;
|
|
29
|
+
/** re-bar the music into the new time signature, adding measures if needed. Otherwise the music that fits is kept. */
|
|
30
|
+
preserveMusic?: boolean;
|
|
31
|
+
}
|
|
21
32
|
/**
|
|
22
33
|
* MVVM-like operations on the displayed score.
|
|
23
34
|
*
|
|
@@ -163,10 +174,16 @@ export declare class SuiScoreViewOperations extends SuiScoreView {
|
|
|
163
174
|
*/
|
|
164
175
|
changeInstrument(instrument: SmoInstrument, selections: SmoSelection[]): Promise<void>;
|
|
165
176
|
/**
|
|
166
|
-
* Set the time signature
|
|
177
|
+
* Set the time signature, in every staff. With no options, it is set on the selected measures and the music
|
|
178
|
+
* that fits in the new length is kept. With options, the measures are chosen by `applyTo`, and with
|
|
179
|
+
* `preserveMusic` the music of those measures is re-barred into the new time signature, adding measures if
|
|
180
|
+
* the new one holds less time, so that no music is lost. Nothing happens, and no undo step is made, if the
|
|
181
|
+
* measures already have this time signature. It is one undo step.
|
|
167
182
|
* @param timeSignature actual time signature
|
|
183
|
+
* @param options which measures, and whether to preserve the music
|
|
168
184
|
*/
|
|
169
|
-
setTimeSignature(timeSignature: SmoTimeSignature): Promise<void>;
|
|
185
|
+
setTimeSignature(timeSignature: SmoTimeSignature, options?: SetTimeSignatureOptions): Promise<void>;
|
|
186
|
+
private _setTimeSignatureInRange;
|
|
170
187
|
/**
|
|
171
188
|
* Move selected staff up or down in the score.
|
|
172
189
|
* @param index direction to move
|
|
@@ -384,15 +384,18 @@ export declare class SmoScore {
|
|
|
384
384
|
* of key, time signature etc.
|
|
385
385
|
* @param measureIndex
|
|
386
386
|
* @param staffIndex
|
|
387
|
+
* @param prototypeIndex
|
|
387
388
|
* @returns
|
|
388
389
|
*/
|
|
389
|
-
getPrototypeMeasure(measureIndex: number, staffIndex: number): SmoMeasure;
|
|
390
|
+
getPrototypeMeasure(measureIndex: number, staffIndex: number, prototypeIndex?: number): SmoMeasure;
|
|
390
391
|
/**
|
|
391
392
|
* Give a measure prototype, create a new measure and add it to each staff, with the
|
|
392
393
|
* correct settings for current time signature/clef.
|
|
393
394
|
* @param measureIndex
|
|
395
|
+
* @param prototypeIndex the measure the new one copies its settings from. By default, the measure
|
|
396
|
+
* that is at measureIndex now (or the last measure, if there is none).
|
|
394
397
|
*/
|
|
395
|
-
addMeasure(measureIndex: number): void;
|
|
398
|
+
addMeasure(measureIndex: number, prototypeIndex?: number): void;
|
|
396
399
|
/**
|
|
397
400
|
* Replace the measure at the given location. Probably due to an undo operation or paste.
|
|
398
401
|
* @param selector
|
|
@@ -9,6 +9,7 @@ import { SmoSystemGroup } from '../data/scoreModifiers';
|
|
|
9
9
|
import { SmoTextGroup } from '../data/scoreText';
|
|
10
10
|
import { SmoSelection, SmoSelector, ModifierTab } from './selections';
|
|
11
11
|
import { MeasureFillType } from './measureFill';
|
|
12
|
+
import { RebarResult } from './rebar';
|
|
12
13
|
/**
|
|
13
14
|
* supported operations for {@link SmoOperation.batchSelectionOperation} to change a note's duration
|
|
14
15
|
*/
|
|
@@ -97,6 +98,29 @@ export declare class SmoOperation {
|
|
|
97
98
|
static swapVoice(selections: SmoSelection[], voice1: number, voice2: number): void;
|
|
98
99
|
static setTabStave(score: SmoScore, tabStave: SmoTabStave): void;
|
|
99
100
|
static removeTabStave(score: SmoScore, tabStaves: SmoTabStave[]): void;
|
|
101
|
+
/**
|
|
102
|
+
* Re-bar the music of measures firstMeasure to lastMeasure (all staves) into a new time signature, adding
|
|
103
|
+
* measures if the new one holds less time. See {@link rebarMeasures}. Unlike {@link setTimeSignature}, no
|
|
104
|
+
* music is lost.
|
|
105
|
+
* @param score the score to change
|
|
106
|
+
* @param firstMeasure the first measure of the range
|
|
107
|
+
* @param lastMeasure the last measure of the range
|
|
108
|
+
* @param timeSignature the new time signature
|
|
109
|
+
*/
|
|
110
|
+
static rebarMeasures(score: SmoScore, firstMeasure: number, lastMeasure: number, timeSignature: SmoTimeSignature): RebarResult;
|
|
111
|
+
/**
|
|
112
|
+
* Would setting this time signature on measures firstMeasure to lastMeasure change anything? True if any
|
|
113
|
+
* of those measures, in any staff, has a time signature that is not equal to this one, display options included.
|
|
114
|
+
* Reads only.
|
|
115
|
+
*/
|
|
116
|
+
static timeSignatureChanges(score: SmoScore, firstMeasure: number, lastMeasure: number, timeSignature: SmoTimeSignature): boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Is every measure in the range, in every staff, already as long as the new time signature would make it?
|
|
119
|
+
* (2/2 for 4/4, or only a display option changed). If so the music does not need to move. The measure
|
|
120
|
+
* k places after the first has part k of a time signature that has several parts. Reads only.
|
|
121
|
+
*/
|
|
122
|
+
static timeSignatureKeepsLength(score: SmoScore, firstMeasure: number, lastMeasure: number, timeSignature: SmoTimeSignature): boolean;
|
|
123
|
+
private static rangeMeasures;
|
|
100
124
|
static setTimeSignature(score: SmoScore, selections: SmoSelection[], timeSignature: SmoTimeSignature): void;
|
|
101
125
|
static batchSelectionOperation(score: SmoScore, selections: SmoSelection[], operation: BatchSelectionOperation): void;
|
|
102
126
|
static doubleDuration(selection: SmoSelection): boolean;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { SmoScore } from '../data/score';
|
|
2
|
+
import { SmoTimeSignature } from '../data/measureModifiers';
|
|
3
|
+
/**
|
|
4
|
+
* What {@link rebarMeasures} did
|
|
5
|
+
* @category SmoTransform
|
|
6
|
+
*/
|
|
7
|
+
export interface RebarResult {
|
|
8
|
+
/** the first re-barred measure */
|
|
9
|
+
firstMeasure: number;
|
|
10
|
+
/** how many measures are now in the range: the ones it had, plus those that were added */
|
|
11
|
+
measureCount: number;
|
|
12
|
+
/** how many measures were added after the old last measure of the range */
|
|
13
|
+
added: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Which measures a time signature change applies to: only the selected ones, from the first selected one to the
|
|
17
|
+
* end of the score, or the whole score.
|
|
18
|
+
* @category SmoTransform
|
|
19
|
+
*/
|
|
20
|
+
export type TimeSignatureApplyTo = 'Selected' | 'Remaining' | 'Score';
|
|
21
|
+
/**
|
|
22
|
+
* The range of measures a time signature change applies to.
|
|
23
|
+
* @param applyTo which measures
|
|
24
|
+
* @param selectedMeasures the measure index of each selected note or measure, in any staff, in any order
|
|
25
|
+
* @param measureCount the number of measures in the score
|
|
26
|
+
* @returns the first and last measure, or null if there is no selection (and the choice is not the whole score) or no measures
|
|
27
|
+
*/
|
|
28
|
+
export declare const timeSignatureRange: (applyTo: TimeSignatureApplyTo, selectedMeasures: number[], measureCount: number) => {
|
|
29
|
+
firstMeasure: number;
|
|
30
|
+
lastMeasure: number;
|
|
31
|
+
} | null;
|
|
32
|
+
/**
|
|
33
|
+
* The length in ticks of the measure k places after the first of a range that gets a time signature. A time
|
|
34
|
+
* signature with several parts (3/4+2/4) alternates its parts from measure to measure.
|
|
35
|
+
* @param timeSignature the new time signature
|
|
36
|
+
* @param k how many measures after the first re-barred measure
|
|
37
|
+
* @param startIndex which part the first re-barred measure has
|
|
38
|
+
*/
|
|
39
|
+
export declare const rebarMeasureTicks: (timeSignature: SmoTimeSignature, k: number, startIndex: number) => number;
|
|
40
|
+
/**
|
|
41
|
+
* Re-bar the music of a range of measures into a new time signature, in every staff. The notes keep their order
|
|
42
|
+
* and their lengths. Where the new measures are not long enough, measures are added after the range (in every
|
|
43
|
+
* staff) so that all of the music fits; measures are never removed. A note that crosses a new bar line is split and
|
|
44
|
+
* tied. A tuplet is kept whole, starting the next measure if it does not fit. Things attached to a note stay with
|
|
45
|
+
* it; if the note is split they stay with the first part. Slurs, ties, hairpins and other things between notes
|
|
46
|
+
* follow their notes. Hand-placed beaming in the range is reset to automatic.
|
|
47
|
+
* @param score the score to change
|
|
48
|
+
* @param firstMeasure the first measure of the range
|
|
49
|
+
* @param lastMeasure the last measure of the range
|
|
50
|
+
* @param timeSignature the new time signature
|
|
51
|
+
* @returns what was done. Nothing is changed, and `added` is 0, if the range is not in the score.
|
|
52
|
+
*/
|
|
53
|
+
export declare const rebarMeasures: (score: SmoScore, firstMeasure: number, lastMeasure: number, timeSignature: SmoTimeSignature) => RebarResult;
|
|
@@ -137,6 +137,20 @@ export declare class SmoSelection {
|
|
|
137
137
|
* @returns
|
|
138
138
|
*/
|
|
139
139
|
static innerSelections(score: SmoScore, startSelector: SmoSelector, endSelector: SmoSelector): SmoSelection[];
|
|
140
|
+
/**
|
|
141
|
+
* Select the notes of one staff that sound between two notes, which may be in any staff. The notes are
|
|
142
|
+
* found by elapsed time within each measure, not by their index in the measure, so a staff with a
|
|
143
|
+
* different number of notes (or a different rhythm) than the staff of the selectors is selected correctly.
|
|
144
|
+
* A note is included if it sounds at any time from the start of the earlier note to the end of the later note.
|
|
145
|
+
* Measures are matched by index. The voice of the earlier selector is used, or the first voice if the
|
|
146
|
+
* measure has no such voice.
|
|
147
|
+
* @param score
|
|
148
|
+
* @param staffIndex the staff to select from
|
|
149
|
+
* @param s1 one end of the range
|
|
150
|
+
* @param s2 the other end of the range
|
|
151
|
+
* @returns the notes in the staff, in order. Empty if the selectors are not in the score.
|
|
152
|
+
*/
|
|
153
|
+
static timeRangeSelections(score: SmoScore, staffIndex: number, s1: SmoSelector, s2: SmoSelector): SmoSelection[];
|
|
140
154
|
static nextNoteSelectionFromSelector(score: SmoScore, selector: SmoSelector): SmoSelection | null;
|
|
141
155
|
static lastNoteSelectionFromSelector(score: SmoScore, selector: SmoSelector): SmoSelection | null;
|
|
142
156
|
static lastNoteSelection(score: SmoScore, staffIndex: number, measureIndex: number, voiceIndex: number, tickIndex: number): SmoSelection | null;
|
package/types/typedoc.d.ts
CHANGED
|
@@ -55,6 +55,7 @@ export * from './src/smo/mxml/xmlToSmo';
|
|
|
55
55
|
export * from './src/smo/xform/beamers';
|
|
56
56
|
export * from './src/smo/xform/copypaste';
|
|
57
57
|
export * from './src/smo/xform/operations';
|
|
58
|
+
export * from './src/smo/xform/rebar';
|
|
58
59
|
export * from './src/smo/xform/selections';
|
|
59
60
|
export * from './src/smo/xform/tickDuration';
|
|
60
61
|
export * from './src/smo/xform/tickMap';
|