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
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Specification Quality Checklist: Preserve Music When Changing Time Signature
|
|
2
|
+
|
|
3
|
+
**Purpose**: Validate specification completeness and quality before proceeding to planning
|
|
4
|
+
**Created**: 2026-11-24
|
|
5
|
+
**Feature**: [spec.md](../spec.md)
|
|
6
|
+
|
|
7
|
+
## Content Quality
|
|
8
|
+
|
|
9
|
+
- [X] No implementation details (languages, frameworks, APIs)
|
|
10
|
+
- [X] Focused on user value and business needs
|
|
11
|
+
- [X] Written for non-technical stakeholders
|
|
12
|
+
- [X] All mandatory sections completed
|
|
13
|
+
|
|
14
|
+
## Requirement Completeness
|
|
15
|
+
|
|
16
|
+
- [X] No [NEEDS CLARIFICATION] markers remain
|
|
17
|
+
- [X] Requirements are testable and unambiguous
|
|
18
|
+
- [X] Success criteria are measurable
|
|
19
|
+
- [X] Success criteria are technology-agnostic (no implementation details)
|
|
20
|
+
- [X] All acceptance scenarios are defined
|
|
21
|
+
- [X] Edge cases are identified
|
|
22
|
+
- [X] Scope is clearly bounded
|
|
23
|
+
- [X] Dependencies and assumptions identified
|
|
24
|
+
|
|
25
|
+
## Feature Readiness
|
|
26
|
+
|
|
27
|
+
- [X] All functional requirements have clear acceptance criteria
|
|
28
|
+
- [X] User scenarios cover primary flows
|
|
29
|
+
- [X] Feature meets measurable outcomes defined in Success Criteria
|
|
30
|
+
- [X] No implementation details leak into specification
|
|
31
|
+
|
|
32
|
+
## Notes
|
|
33
|
+
|
|
34
|
+
- Judgment calls recorded as assumptions rather than clarification markers: measures are never removed, added measures go directly after the re-barred set, and added measures copy the last re-barred measure's settings.
|
|
35
|
+
- Validated in one pass; no iterations needed.
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# Contract: Preserve Music API
|
|
2
|
+
|
|
3
|
+
Library surface. `SmoOperation`, `SuiScoreViewOperations` and the new smo module are exported from `src/application/exports.ts`.
|
|
4
|
+
|
|
5
|
+
## `src/smo/xform/rebar.ts` (new)
|
|
6
|
+
|
|
7
|
+
| Member | Signature | Behavior |
|
|
8
|
+
|--------|-----------|----------|
|
|
9
|
+
| `rebarMeasures` | `(score: SmoScore, firstMeasure: number, lastMeasure: number, timeSignature: SmoTimeSignature) => RebarResult` | Re-bars the music of measures `firstMeasure`..`lastMeasure` of **every** staff into measures of `timeSignature`, as described in [research.md](../research.md) R2 to R6. Adds measures after `lastMeasure`, in every staff, when needed. Sets `timeSignature` (a copy per measure) on every measure of the range and updates the compound-time indices. Remaps the staff modifiers. Returns the result. Does nothing and returns `added: 0` for an invalid range. |
|
|
10
|
+
| `RebarResult` | `{ firstMeasure: number, measureCount: number, added: number }` | See the data model. |
|
|
11
|
+
|
|
12
|
+
## `SmoOperation` (additions)
|
|
13
|
+
|
|
14
|
+
| Member | Signature | Behavior |
|
|
15
|
+
|--------|-----------|----------|
|
|
16
|
+
| `rebarMeasures` | same as above | Calls the function above. |
|
|
17
|
+
| `timeSignatureChanges` | `(score, firstMeasure, lastMeasure, timeSignature) => boolean` | True if any measure in the range, in any staff, has a time signature that is not equal (`equalIncludeAttributes`) to `timeSignature`. Reads only. |
|
|
18
|
+
| `timeSignatureKeepsLength` | `(score, firstMeasure, lastMeasure, timeSignature) => boolean` | True if every measure in the range has the same length in ticks as the new signature would give it. Reads only. |
|
|
19
|
+
| `setTimeSignature` | unchanged | Keeps what fits. |
|
|
20
|
+
|
|
21
|
+
## `SmoScore` (change)
|
|
22
|
+
|
|
23
|
+
| Member | Signature | Behavior |
|
|
24
|
+
|--------|-----------|----------|
|
|
25
|
+
| `addMeasure` | `(measureIndex: number, prototypeIndex?: number) => void` | New optional argument: the measure that the new measures copy their settings from. Without it, behavior is unchanged. |
|
|
26
|
+
| `getPrototypeMeasure` | `(measureIndex: number, staffIndex: number, prototypeIndex?: number)` | Same optional argument. |
|
|
27
|
+
|
|
28
|
+
## `SuiScoreViewOperations` (change)
|
|
29
|
+
|
|
30
|
+
| Member | Signature | Behavior |
|
|
31
|
+
|--------|-----------|----------|
|
|
32
|
+
| `setTimeSignature` | `(timeSignature: SmoTimeSignature, options?: SetTimeSignatureOptions) => Promise<void>` | Without options: as before (tracker selections, keep what fits). With options, finds the range from `applyTo`. Returns with no change, undo step or redraw if `timeSignatureChanges` is false. Uses the old path if `preserveMusic` is not true or `timeSignatureKeepsLength` is true; otherwise runs `rebarMeasures` on the displayed and the backing score. One undo step (`_undoScore`), one full redraw. |
|
|
33
|
+
|
|
34
|
+
## UI
|
|
35
|
+
|
|
36
|
+
| Item | Behavior |
|
|
37
|
+
|------|----------|
|
|
38
|
+
| Time Signature dialog | Editing any field, Apply To or Preserve music does not change the score. OK applies everything once, as one undo step. Cancel or dismiss changes nothing and records nothing. A **Preserve music** toggle, ticked each time the dialog opens. |
|
|
39
|
+
|
|
40
|
+
## Test cases (`tests/rebarMeasures.ts`)
|
|
41
|
+
|
|
42
|
+
| Id | Case | Expected |
|
|
43
|
+
|----|------|----------|
|
|
44
|
+
| B1 | 2 measures of 4/4, 8 quarters, to 3/4 (spec example) | 3 measures of 3/4; measures 1 and 2 hold 3 quarters; measure 3 holds 2 quarters and a quarter rest; the sequence of pitches is unchanged. |
|
|
45
|
+
| B2 | 3/4 to 4/4, 3 measures of 3 quarters | 3 measures remain; no loss; the last is padded with rests; no measure added when none is needed. |
|
|
46
|
+
| B3 | 4/4 to 6/8 and to 5/8 | Same pitches in order; measures added as needed. |
|
|
47
|
+
| B4 | Half note starting on beat 3 of 3/4 (crosses the new bar line) | Split in two tied notes; total length the same. |
|
|
48
|
+
| B5 | Dotted whole in 3/4 (crosses two bar lines) | Pieces from `gcdMap`, each tied to the next. |
|
|
49
|
+
| B6 | Rests that cross a bar line | Split into rests; no ties. |
|
|
50
|
+
| B7 | A quarter-note triplet that fits | Placed whole with correct indices. |
|
|
51
|
+
| B8 | A triplet that straddles the new bar line | Rest fills the bar; the tuplet starts the next measure; all notes kept. |
|
|
52
|
+
| B9 | A tuplet longer than the new measure | Plain notes, all kept, in order. |
|
|
53
|
+
| B10 | Two voices in the range | Each voice laid out on its own; voice 1 unchanged in order. |
|
|
54
|
+
| B11 | Two staves with different rhythms | Each re-barred; both have the same measure count. |
|
|
55
|
+
| B12 | Dynamics, lyrics, chords, articulations on notes, one of them split | Markings stay with the (first piece of the) same note. |
|
|
56
|
+
| B13 | A slur and a tie across the old bar line, and a hairpin | End selectors point at the same notes after the change; ties added for splits. |
|
|
57
|
+
| B14 | Alternating 3/4+2/4 | Measures alternate 3/4, 2/4, ...; all music fits. |
|
|
58
|
+
| B15 | Range in the middle, Remaining, Score | Measures before and after unchanged except their index; modifiers after the range shift by `added`. |
|
|
59
|
+
| B16 | Added measures | Copy the settings (key, clef, tempo) of the old last measure of the range. |
|
|
60
|
+
| B17 | Same-length meter (4/4 to 2/2) | `timeSignatureKeepsLength` is true; `timeSignatureChanges` is true. |
|
|
61
|
+
| B18 | `timeSignatureChanges` with an equal signature | False. |
|
|
62
|
+
| B19 | Fewer measures needed (3 measures of 3/4 to 6/4) | No measure removed; extra measures are rests. |
|
|
63
|
+
| B20 | Serialize (full form) and reload after a re-bar | Same music; measure count the same. |
|
|
64
|
+
| B21 | Invalid range | `added` is 0; score unchanged. |
|
|
65
|
+
| B22 | Old path regression: `SmoOperation.setTimeSignature` 4/4 to 3/4 | Keeps what fits; two measures; as before. |
|
|
66
|
+
| B23 | Copy buffer | `PasteBuffer` contents are unchanged by a re-bar. |
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Data Model: Preserve Music When Changing Time Signature
|
|
2
|
+
|
|
3
|
+
Nothing is added to the saved score. These are the in-memory shapes the transform and the dialog use.
|
|
4
|
+
|
|
5
|
+
## Dialog choices (not saved)
|
|
6
|
+
|
|
7
|
+
| Field | Type | Initial | Meaning |
|
|
8
|
+
|-------|------|---------|---------|
|
|
9
|
+
| `timeSignature` | `SmoTimeSignature` | copy of the first selected measure's | The signature to apply, including `times` (compound), `display`, `displayString` and `useSymbol`. Editing it changes only this copy. |
|
|
10
|
+
| `applyTo` | `'Selected' \| 'Remaining' \| 'Score'` | `'Selected'` | Which measures change. Read when OK is clicked. |
|
|
11
|
+
| `preserveMusic` | `boolean` | `true` | Re-bar the music (true) or keep what fits (false). |
|
|
12
|
+
|
|
13
|
+
## `TimeSignatureApplyTo` and `SetTimeSignatureOptions` (`src/render/sui/scoreViewOperations.ts`)
|
|
14
|
+
|
|
15
|
+
```text
|
|
16
|
+
TimeSignatureApplyTo = 'Selected' | 'Remaining' | 'Score'
|
|
17
|
+
SetTimeSignatureOptions { applyTo?: TimeSignatureApplyTo, preserveMusic?: boolean }
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
With no options, `setTimeSignature` applies to the tracker's selections and keeps what fits, as before.
|
|
21
|
+
|
|
22
|
+
## The chosen range
|
|
23
|
+
|
|
24
|
+
`firstMeasure`..`lastMeasure` (indices, inclusive), the same in every staff, found from the tracker's selections and `applyTo`:
|
|
25
|
+
|
|
26
|
+
| `applyTo` | firstMeasure | lastMeasure |
|
|
27
|
+
|-----------|--------------|-------------|
|
|
28
|
+
| Selected | lowest selected measure | highest selected measure |
|
|
29
|
+
| Remaining | lowest selected measure | last measure of the score |
|
|
30
|
+
| Score | 0 | last measure of the score |
|
|
31
|
+
|
|
32
|
+
## Layout unit
|
|
33
|
+
|
|
34
|
+
What the layout places, one at a time, for one voice of one staff:
|
|
35
|
+
|
|
36
|
+
| Field | Meaning |
|
|
37
|
+
|-------|---------|
|
|
38
|
+
| `notes` | The source notes of the unit: one note or rest, or all the notes of one tuplet tree. |
|
|
39
|
+
| `ticks` | Total length of the unit. |
|
|
40
|
+
| `tuplet` | The source `SmoTupletTree` for a tuplet unit, otherwise none. |
|
|
41
|
+
| `sources` | The old selector of each source note (staff, measure, voice, tick). |
|
|
42
|
+
|
|
43
|
+
## Placement map
|
|
44
|
+
|
|
45
|
+
For each source note, where it ended up. Built during the layout and used to fix the staff modifiers.
|
|
46
|
+
|
|
47
|
+
| Field | Meaning |
|
|
48
|
+
|-------|---------|
|
|
49
|
+
| key | The old selector of the note (`SmoSelector.getNoteKey`). |
|
|
50
|
+
| `firstPiece` | New selector of the first (or only) piece of the note. |
|
|
51
|
+
| `lastPiece` | New selector of the last piece. The same as `firstPiece` if the note was not split. |
|
|
52
|
+
|
|
53
|
+
## `RebarResult` (`src/smo/xform/rebar.ts`)
|
|
54
|
+
|
|
55
|
+
| Field | Meaning |
|
|
56
|
+
|-------|---------|
|
|
57
|
+
| `firstMeasure` | First re-barred measure. |
|
|
58
|
+
| `measureCount` | Number of measures now in the range (existing plus added). |
|
|
59
|
+
| `added` | How many measures were added after the old last measure. 0 if none were needed. |
|
|
60
|
+
|
|
61
|
+
## Rules for the numbers
|
|
62
|
+
|
|
63
|
+
- Measure length for the k-th measure of the range (k from 0): `SmoMusic.timeSignatureToTicks(actualBeats, beatDuration)` of the part at position `(startIndex + k) mod times.length`. `startIndex` is the `index` of the measure before the range if its time signature equals the new one (and that measure has more than one part), else 0.
|
|
64
|
+
- `needed` (measures needed) for a voice: the number of measures that its layout fills. Overall `needed` is the maximum over all staves and voices.
|
|
65
|
+
- Final range size: `max(existing, needed)`. `added = size - existing`.
|
|
66
|
+
- Total sounding time of a voice (ticks of all its units) is the same before and after, except for the rests that fill the end of the last measure.
|
|
67
|
+
|
|
68
|
+
## Invariants
|
|
69
|
+
|
|
70
|
+
1. For every staff and voice, the sequence of pitched notes, read with tied pieces joined, is the same before and after (spec SC-002).
|
|
71
|
+
2. Every staff has the same number of measures before and after the transform, plus `added`.
|
|
72
|
+
3. Measures outside the range keep their notes, signatures and settings; only their index and the modifier selectors that point at them move.
|
|
73
|
+
4. A measure is never removed.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Implementation Plan: Preserve Music When Changing Time Signature
|
|
2
|
+
|
|
3
|
+
**Branch**: `042-preserve-music-time-signature` (work is on `main`; no feature branch was created) | **Date**: 2026-11-24 | **Spec**: [spec.md](spec.md)
|
|
4
|
+
|
|
5
|
+
**Input**: Feature specification from `/specs/042-preserve-music-time-signature/spec.md`
|
|
6
|
+
|
|
7
|
+
## Summary
|
|
8
|
+
|
|
9
|
+
Two changes to the Time Signature dialog:
|
|
10
|
+
|
|
11
|
+
1. **Commit on OK.** The dialog stops changing the score as fields are edited. It keeps its choices locally and applies them once, when OK is clicked. Cancel does nothing. The existing "change, then put the backup back on Cancel" logic is removed.
|
|
12
|
+
2. **Preserve music** checkbox, ticked by default. Ticked: the music of the chosen measures is re-barred into the new meter, in order, with extra measures added so nothing is lost. Unticked: today's behavior (`SmoOperation.setTimeSignature`, keep what fits).
|
|
13
|
+
|
|
14
|
+
The re-bar is a new, headless transform in the smo layer. It works on each staff and voice separately: it flattens the music of the chosen measures into one ordered list, lays that list out again measure by measure at the new lengths (splitting and tying notes that cross a bar line, keeping a tuplet whole), adds the measures that are needed, and then remaps the slurs, ties and hairpins that pointed at the old note positions. It does **not** use the clipboard (see [research.md](research.md) R1). The view runs it on the displayed and the backing score as one undo step.
|
|
15
|
+
|
|
16
|
+
No file format change. Scores that were re-barred are ordinary scores with different measures.
|
|
17
|
+
|
|
18
|
+
## Technical Context
|
|
19
|
+
|
|
20
|
+
**Language/Version**: TypeScript; Vue 3 single-file component for the dialog. Tests run with `ts-node`.
|
|
21
|
+
|
|
22
|
+
**Primary Dependencies**: None new. Reuses `SmoMusic.gcdMap`, `SmoNote.cloneWithDuration`, `SmoTupletTree`, `SmoTie`/`SmoOperation.createTie`, `SmoScore.addMeasure`, `SmoTimeSignature`, `SuiScoreView._undoScore`.
|
|
23
|
+
|
|
24
|
+
**Storage**: No change.
|
|
25
|
+
|
|
26
|
+
**Testing**: Headless `ts-node` script `tests/rebarMeasures.ts` (npm script `test:rebar-measures`): the cases in [contracts/rebar-api.md](contracts/rebar-api.md) (the spec's 4/4 to 3/4 example, larger and equal meters, split and tied notes, rests, tuplets, voices, staves, markings, slurs and ties remapped, alternating meters, pickups, apply ranges, and a serialize and reload). The view method needs the DOM, so its undo and redraw wiring is checked by `tsc` and the manual steps in [quickstart.md](quickstart.md). The `.vue` file is compiled with `@vue/compiler-sfc`. The constitution says rendering and UI need not be tested.
|
|
27
|
+
|
|
28
|
+
**Target Platform**: Browser application and library.
|
|
29
|
+
|
|
30
|
+
**Project Type**: Single project.
|
|
31
|
+
|
|
32
|
+
**Performance Goals**: One pass over the chosen measures, then one full redraw (the measure count changes). Spec SC-007: 100 measures in under 2 seconds.
|
|
33
|
+
|
|
34
|
+
**Constraints**: The smo layer must not import UI code. The transform must lose no note, in any case ([spec FR-006](spec.md)). It must not touch the user's copy buffer.
|
|
35
|
+
|
|
36
|
+
**Scale/Scope**: One new smo file (about 300 lines), a small additive change to `SmoScore.addMeasure`, two small `SmoOperation` helpers, one view method change, a rewrite of `timeSignature.ts` and a few additions to `timeSignature.vue`, hand-edited declarations, one test file.
|
|
37
|
+
|
|
38
|
+
## Constitution Check
|
|
39
|
+
|
|
40
|
+
*GATE: Must pass before Phase 0 research. Re-check after Phase 1 design.*
|
|
41
|
+
|
|
42
|
+
| Principle | Assessment |
|
|
43
|
+
|-----------|------------|
|
|
44
|
+
| #1 Serialization | Pass. No new persisted field. A test serializes and reloads a re-barred score and compares the music. Legacy scores need no handling. |
|
|
45
|
+
| #2 Editing and transformation logic regression tested | Pass. The re-bar is a pure smo transform with a headless test file covering each rule in the spec. The old keep-what-fits path is covered by a regression case. |
|
|
46
|
+
| #3 Rendering performance | Pass. The change is applied once, then the score is redrawn once (`rerenderAll`), which is the existing path for structural changes. The dialog no longer redraws the score on each edit, which removes repeated renders. |
|
|
47
|
+
| #4 Logical dependencies | Pass. The transform is in `src/smo/xform/rebar.ts` with no UI or renderer imports. The view calls it; the dialog only collects choices. |
|
|
48
|
+
|
|
49
|
+
Re-check after Phase 1 design: still passes. No complexity violations.
|
|
50
|
+
|
|
51
|
+
## Project Structure
|
|
52
|
+
|
|
53
|
+
### Documentation (this feature)
|
|
54
|
+
|
|
55
|
+
```text
|
|
56
|
+
specs/042-preserve-music-time-signature/
|
|
57
|
+
├── plan.md # This file
|
|
58
|
+
├── research.md # Phase 0 output
|
|
59
|
+
├── data-model.md # Phase 1 output
|
|
60
|
+
├── quickstart.md # Phase 1 output
|
|
61
|
+
├── contracts/
|
|
62
|
+
│ └── rebar-api.md # Phase 1 output: library API and test cases
|
|
63
|
+
├── checklists/
|
|
64
|
+
│ └── requirements.md
|
|
65
|
+
└── tasks.md # Phase 2 output (/speckit-tasks, not created here)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Source Code (repository root)
|
|
69
|
+
|
|
70
|
+
```text
|
|
71
|
+
src/
|
|
72
|
+
├── smo/
|
|
73
|
+
│ ├── data/score.ts # addMeasure/getPrototypeMeasure: optional prototype index
|
|
74
|
+
│ └── xform/
|
|
75
|
+
│ ├── rebar.ts # NEW: rebarMeasures and its helpers
|
|
76
|
+
│ └── operations.ts # SmoOperation.rebarMeasures, timeSignatureChanges (thin wrappers)
|
|
77
|
+
├── render/sui/scoreViewOperations.ts # setTimeSignature(ts, options): decide range, undo, run, redraw
|
|
78
|
+
├── application/exports.ts # export the new smo module
|
|
79
|
+
└── ui/
|
|
80
|
+
├── dialogs/timeSignature.ts # collect choices, commit on OK, no live updates
|
|
81
|
+
└── components/dialogs/timeSignature.vue # Preserve music checkbox; remove live updates
|
|
82
|
+
|
|
83
|
+
types/src/... # hand-edited declarations for the above
|
|
84
|
+
tests/rebarMeasures.ts # NEW headless test
|
|
85
|
+
package.json # "test:rebar-measures" script
|
|
86
|
+
changes.md # release note
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**Structure Decision**: Single project. The new transform lives beside the other `smo/xform` edit logic so it can be tested without a browser; the view and dialog are thin.
|
|
90
|
+
|
|
91
|
+
## Complexity Tracking
|
|
92
|
+
|
|
93
|
+
No constitution violations to justify.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Quickstart: Preserve Music When Changing Time Signature
|
|
2
|
+
|
|
3
|
+
Validation guide. The API is in the [contract](contracts/rebar-api.md) and the shapes are in the [data model](data-model.md).
|
|
4
|
+
|
|
5
|
+
## 1. Automated checks
|
|
6
|
+
|
|
7
|
+
```text
|
|
8
|
+
npx tsc --noEmit -p .
|
|
9
|
+
npm run test:rebar-measures
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Expected: no compiler errors, and every case B1 to B23 in `tests/rebarMeasures.ts` prints `PASS`. Also re-run the suites that share code with this change: `test:paste-special`, `test:voice-copy-paste`, `test:measure-fill`, `test:beam-groups`, `test:score-archive`, `test:time-signature-display`.
|
|
13
|
+
|
|
14
|
+
## 2. The dialog component compiles
|
|
15
|
+
|
|
16
|
+
Compile `src/ui/components/dialogs/timeSignature.vue` with `@vue/compiler-sfc` (parse errors 0, compiles).
|
|
17
|
+
|
|
18
|
+
## 3. Search proves the wiring
|
|
19
|
+
|
|
20
|
+
- `rebarMeasures` is exported from `src/application/exports.ts` and declared in `types/src/smo/xform/rebar.d.ts`.
|
|
21
|
+
- `timeSignature.ts` no longer calls `view.setTimeSignature` from `updateTimeSignatureCb` or `updateApplyTo`; it calls it once, from `commitCb`.
|
|
22
|
+
|
|
23
|
+
## 4. In the running application (manual)
|
|
24
|
+
|
|
25
|
+
1. New score, 4/4. Enter eight quarter notes across two measures. Select the first measure.
|
|
26
|
+
2. Edit > Time Signature. Change it to 3/4. **The score does not change while the dialog is open.** Preserve music is ticked.
|
|
27
|
+
3. Click Cancel. The score is unchanged; Undo has nothing new to undo.
|
|
28
|
+
4. Open it again, choose 3/4, click OK. There are three measures of 3/4, the eight quarter notes in order, the last measure two quarters and a quarter rest.
|
|
29
|
+
5. Undo once. The two 4/4 measures are back.
|
|
30
|
+
6. Repeat with Preserve music unticked. Two measures of 3/4 with three quarters each; the fourth quarter of each is gone.
|
|
31
|
+
7. Enter a half note on beat 3 of a 4/4 measure, change to 3/4 with Preserve music ticked. It becomes two tied notes.
|
|
32
|
+
8. In a six-measure score, select measures 3 and 4 and change to 3/4 with **Selected Measures**; measures 1, 2, 5 and 6 are untouched (5 and 6 are now later).
|
|
33
|
+
9. Add a dynamic and a lyric to a note, a slur across a bar line, and re-bar. They stay on the same notes.
|
|
34
|
+
10. Open the dialog on a two-staff score and re-bar. Both staves have the same number of measures.
|
|
35
|
+
11. Change only **Display Time Signature**, click OK: nothing moves.
|
|
36
|
+
12. Click OK with nothing changed: no undo step is added.
|
|
37
|
+
13. Copy some notes, re-bar a time signature, then Paste: the copied notes are still what was copied.
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Research: Preserve Music When Changing Time Signature
|
|
2
|
+
|
|
3
|
+
All unknowns from the Technical Context are resolved below. No `NEEDS CLARIFICATION` items remain.
|
|
4
|
+
|
|
5
|
+
## R1: Copy and paste, or a dedicated re-bar?
|
|
6
|
+
|
|
7
|
+
**Finding**: The request describes the re-bar as "copy the music, paste it into the destination". `PasteBuffer` (`src/smo/xform/copypaste.ts`) already lays a list of notes across measures, so it was the first candidate. Four things stop it from being used as is:
|
|
8
|
+
|
|
9
|
+
1. It uses the user's copy buffer (`scoreView.storePaste`). A time signature change would silently replace what the user had copied.
|
|
10
|
+
2. A note that crosses a bar line is split but **not tied** (`copypaste.ts:900`, "TODO: tie the last note to this one"). Spec FR-010 needs ties.
|
|
11
|
+
3. It pastes into measures that already exist, and stops at the end of the score (`copypaste.ts:646`, "TODO: add a measure in this case"). Spec FR-007 needs measures added.
|
|
12
|
+
4. `_populatePost` keeps the destination's old notes after the end of a paste, so the destination measures would have to be emptied first. It pastes one voice per call, and staff modifiers are placed afterwards by note count, which breaks when notes are split.
|
|
13
|
+
|
|
14
|
+
**Decision**: A dedicated transform, `rebarMeasures` in `src/smo/xform/rebar.ts`. It works in place on each staff, from the notes themselves, with no clipboard.
|
|
15
|
+
|
|
16
|
+
**Rationale**: It does what the request means (the same notes in the same order, in the new meter) without the four problems. It does reuse the pieces paste uses: `SmoMusic.gcdMap` for splitting a duration into legal note lengths, `SmoNote.cloneWithDuration`, and `SmoTupletTree` for tuplet indices.
|
|
17
|
+
|
|
18
|
+
**Alternatives considered**: (a) Use `PasteBuffer.setVoiceSelections('all')` and `pasteAllVoices`. Rejected for the four reasons above; fixing them would change the behavior of ordinary paste for everyone. (b) Fix paste to tie and to add measures, then call it. Rejected as a larger, riskier change to a shared feature than this request needs.
|
|
19
|
+
|
|
20
|
+
## R2: What "the same notes in the same order" means for each case
|
|
21
|
+
|
|
22
|
+
Each staff and voice is handled on its own. The music of the chosen measures is read as one list of **units** in time order, then laid out again into measures whose lengths come from the new time signature.
|
|
23
|
+
|
|
24
|
+
| Unit | Layout rule |
|
|
25
|
+
|------|-------------|
|
|
26
|
+
| A note or rest that fits in what is left of the measure | Placed as it is. |
|
|
27
|
+
| A note that does not fit | Split at the bar line into pieces whose lengths come from `SmoMusic.gcdMap`; continues into the next measure(s) until its whole length is placed. Pitched pieces are tied to each other; rest pieces are not. Only the first piece keeps the note's markings (spec FR-011); later pieces keep the pitches only. |
|
|
28
|
+
| A rest that does not fit | Split the same way, without ties. |
|
|
29
|
+
| A tuplet (the whole tree, as one unit) that fits | Placed whole, with its indices adjusted to the new position. |
|
|
30
|
+
| A tuplet that does not fit in what is left, but would fit in an empty measure | The rest of the measure is filled with rests, and the tuplet starts the next measure. All its notes are kept. |
|
|
31
|
+
| A tuplet longer than an empty measure | Turned back into plain notes (the existing `SmoUnmakeTupletActor` logic: each note keeps its written length), then laid out as plain notes. All its notes are kept. |
|
|
32
|
+
| The end of the music | The rest of the last measure is filled with rests. |
|
|
33
|
+
|
|
34
|
+
**Decision**: These rules.
|
|
35
|
+
|
|
36
|
+
**Rationale**: They keep every note and the order of the notes (the request's wording). The only case that moves music in time is the middle one (a tuplet that would straddle a bar line), which is the standard engraving choice; the alternative, a tuplet broken at the bar line, cannot be written in notation. The last case changes the written length of a tuplet's notes but never drops one, and happens only when the tuplet is longer than a whole measure.
|
|
37
|
+
|
|
38
|
+
**Alternatives considered**: Dropping a straddling tuplet (violates "nothing lost"); splitting tuplet notes at the bar line (tuplet durations are not whole tick counts, so there are no legal pieces).
|
|
39
|
+
|
|
40
|
+
## R3: How many measures, and where they go
|
|
41
|
+
|
|
42
|
+
**Finding**: Different voices and staves can need different numbers of measures after the layout (a staff with many short rests may need fewer, for example).
|
|
43
|
+
|
|
44
|
+
**Decision**: The layout is run per staff and voice first and only counts measures. Let `needed` be the largest count over all staves and voices, and `existing` the number of measures in the chosen range. The range grows to `max(existing, needed)` measures, so measures are only ever added (spec FR-008). The added measures are inserted directly after the last chosen measure, in every staff (spec FR-013). Measures in the range that the layout does not reach are filled with rests.
|
|
45
|
+
|
|
46
|
+
**Rationale**: Every staff keeps the same number of measures. Never removing a measure means that nothing can be lost by accident and that measure numbers after the range only move later.
|
|
47
|
+
|
|
48
|
+
## R4: Measure lengths for alternating (compound) time signatures
|
|
49
|
+
|
|
50
|
+
**Finding**: A `SmoTimeSignature` with several `times` (3/4+2/4) makes consecutive measures alternate between its parts. `SmoScore.updateCompoundTimeSignature` sets `measure.timeSignature.index` so that each measure has one part, and `actualBeats` and `beatDuration` return that part. The measure length is `SmoMusic.timeSignatureToTicks(actualBeats, beatDuration)` for that part. It is not the sum. (This corrected the first draft of the spec, which said the sum.)
|
|
51
|
+
|
|
52
|
+
**Decision**: The layout takes the length of the k-th re-barred measure from the part at position `(startIndex + k) mod parts`. `startIndex` is 0 unless the measure just before the range has an equal time signature, in which case the pattern continues from it, the same rule `updateCompoundTimeSignature` uses. After the measures are laid out, `updateCompoundTimeSignature` is called to set the indices for real.
|
|
53
|
+
|
|
54
|
+
**Rationale**: Uses the application's own definition of a measure's length and keeps the layout and the measures' stored indices in agreement.
|
|
55
|
+
|
|
56
|
+
## R5: Adding measures with the right settings
|
|
57
|
+
|
|
58
|
+
**Finding**: `SmoScore.addMeasure(index)` creates the new measure from `getPrototypeMeasure(index, staff)`, which is the measure currently *at* `index`, that is, the first measure after the range, whose key, clef and tempo can differ. The spec (Assumptions) says added measures take the settings of the last re-barred measure.
|
|
59
|
+
|
|
60
|
+
**Decision**: Give `SmoScore.addMeasure` and `getPrototypeMeasure` an optional `prototypeIndex` argument. When given, that measure is the prototype. Existing callers pass nothing and behave as before. `rebarMeasures` calls `addMeasure(last + 1, last)`.
|
|
61
|
+
|
|
62
|
+
**Rationale**: Small, additive, and reuses everything `addMeasure` already does (inserting in every staff, shifting staff modifiers and attached text, renumbering).
|
|
63
|
+
|
|
64
|
+
**Alternatives considered**: Building the measures in `rebar.ts` and splicing them into each staff (would duplicate the shifting and renumbering in `addMeasure`).
|
|
65
|
+
|
|
66
|
+
## R6: Slurs, ties, hairpins and other staff modifiers
|
|
67
|
+
|
|
68
|
+
**Finding**: Staff modifiers store their ends as note selectors (staff, measure, voice, tick), so re-barring invalidates them (spec FR-017). `SystemStaff.addMeasure` shifts only the modifiers that start at or after the inserted index; `removeModifiersInMeasure` (used by Fill Measures) removes them.
|
|
69
|
+
|
|
70
|
+
**Decision**: While laying out each voice, record where each source note went: `{ firstPiece, lastPiece }` as new selectors, keyed by the note's old selector. Afterwards, for every staff modifier with an end inside the range, rewrite the end selectors from this map (an end that starts a modifier uses `firstPiece`; an end that finishes one uses `lastPiece`; for a `SmoTie`, the start uses `lastPiece` and the end uses `firstPiece`). A modifier end after the range is moved later by the number of measures added. New ties are added between the pieces of a split note.
|
|
71
|
+
|
|
72
|
+
**Rationale**: Nothing is dropped, and each modifier stays on the same notes. The remap runs before the added measures are inserted so that the two shifts cannot be applied twice.
|
|
73
|
+
|
|
74
|
+
## R7: When to use the old path
|
|
75
|
+
|
|
76
|
+
**Finding**: Spec FR-018 and FR-019: a display-only change, or a new meter with the same measure length, must not move music, and spec FR-014 keeps the old behavior for the unticked box.
|
|
77
|
+
|
|
78
|
+
**Decision**: `SuiScoreViewOperations.setTimeSignature` uses the old `SmoOperation.setTimeSignature` when Preserve music is unticked, or when every chosen measure already has the same length as the new signature. It uses `rebarMeasures` otherwise. Before either, it checks `SmoOperation.timeSignatureChanges(score, firstMeasure, lastMeasure, ts)` (any chosen measure with a different signature, display options included); if nothing differs, it returns without touching the score or the undo stack (spec FR-004).
|
|
79
|
+
|
|
80
|
+
**Rationale**: The old behavior is kept bit for bit for the cases where it is correct, and the new code only runs when it is needed.
|
|
81
|
+
|
|
82
|
+
## R8: Undo, redraw, and the backing score
|
|
83
|
+
|
|
84
|
+
**Finding**: `_undoScore(label)` stores a snapshot of the whole backing score, which is what is needed when measures are added (`addMeasures` and `deleteMeasure` do the same). The displayed score (`this.score`) can be a part view of the stored score (`this.storeScore`). The existing `setTimeSignature` already applies to both. Structural changes (transpose score, global layout, add and delete measure) redraw with `renderer.rerenderAll()` or `setRefresh()`.
|
|
85
|
+
|
|
86
|
+
**Decision**: The view method calls `_undoScore('Set time signature')`, runs the operation on `this.score` and on `this.storeScore` with the same measure range, then redraws with `renderer.rerenderAll()` and waits for `updatePromise()`. One undo step restores everything, including removing the added measures.
|
|
87
|
+
|
|
88
|
+
**Rationale**: Same wiring as the other whole-score structural edits. The measure range is by index, which is the same in both scores.
|
|
89
|
+
|
|
90
|
+
## R9: The dialog
|
|
91
|
+
|
|
92
|
+
**Finding**: `timeSignature.ts` calls `view.setTimeSignature` on every change and on Apply To (which also replaces `tracker.selections`), and `cancelCb` sets the old signature back (leaving an undo step behind). `timeSignature.vue` watches each field and calls `updateTimeSignatureCb`. The `commitCb` is empty.
|
|
93
|
+
|
|
94
|
+
**Decision**: Rewrite the creation function to hold the choices in local state (`timeSignature`, `applyTo`, `preserveMusic`) and to call `view.setTimeSignature(timeSignature, { applyTo, preserveMusic })` once in `commitCb`. `cancelCb` does nothing. `updateTimeSignatureCb` now only updates the local `timeSignature` ref (no score change). The component adds a `toggle` for Preserve music (ticked at first) and its `updateApplyTo` and the new `updatePreserve` callbacks only store the values. `setTimeSignature(ts)` with no options keeps its old meaning for library callers: apply to the tracker's selections and keep what fits.
|
|
95
|
+
|
|
96
|
+
**Rationale**: Meets spec FR-001 to FR-005, and gives one undo step. Library callers of the old signature are unaffected.
|
|
97
|
+
|
|
98
|
+
## R10: Declarations and exports
|
|
99
|
+
|
|
100
|
+
**Finding**: Declarations in `types/` are hand-edited in this repository, and `src/application/exports.ts` lists what the library exports.
|
|
101
|
+
|
|
102
|
+
**Decision**: Hand-edit the declaration for `rebar.ts`, `operations.d.ts`, `score.d.ts`, `scoreViewOperations.d.ts` and `exports.d.ts`; export the new module from `exports.ts`.
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# Feature Specification: Preserve Music When Changing Time Signature
|
|
2
|
+
|
|
3
|
+
**Feature Branch**: `042-preserve-music-time-signature`
|
|
4
|
+
|
|
5
|
+
**Created**: 2026-11-24
|
|
6
|
+
|
|
7
|
+
**Status**: Draft
|
|
8
|
+
|
|
9
|
+
**Input**: User description: "preserve music when changing time signature. 1. For the time signature dialog, change the logic when the time signature changes - do not commit the change until the user clicks OK. 2. Add a checkbox for 'preserve music', checked by default. If checked: a. make sure there is no less time represented in the new time signature, by adding additional measure if required. For instance, if there are 2 4/4 measures, and the time signature changes to 3/4, we would add a 3rd 3/4 measure. b. copy all the music from the original set of selected measures, and paste it into the destination. So it will have the same notes in the same order. c. if the checkbox is unchecked, just preserve as much music as fits in a measure, as it is today."
|
|
10
|
+
|
|
11
|
+
## User Scenarios & Testing *(mandatory)*
|
|
12
|
+
|
|
13
|
+
### User Story 1 - Change the meter without losing notes (Priority: P1)
|
|
14
|
+
|
|
15
|
+
A composer has written music in one meter and decides it should be in another: two measures of 4/4 that should be 3/4. Today, changing the time signature keeps only as much music as fits in each measure and the rest is thrown away. With the new **Preserve music** option (on by default), the same notes in the same order are re-barred into the new meter, and extra measures are added so nothing is lost.
|
|
16
|
+
|
|
17
|
+
**Why this priority**: Losing notes silently is the one outcome of the current behavior that cannot be undone by the user's own judgment, and it is the reason for the whole feature. Everything else supports it.
|
|
18
|
+
|
|
19
|
+
**Independent Test**: Take a score with two 4/4 measures of eight quarter notes, open the Time Signature dialog, choose 3/4, leave **Preserve music** ticked, and click OK. The score has three 3/4 measures holding the same eight quarter notes in the same order (the last measure is two quarters and a quarter rest).
|
|
20
|
+
|
|
21
|
+
**Acceptance Scenarios**:
|
|
22
|
+
|
|
23
|
+
1. **Given** two 4/4 measures of eight quarter notes selected, **When** the user changes the time signature to 3/4 with Preserve music ticked and clicks OK, **Then** there are three 3/4 measures, the first two holding three quarter notes each and the third holding the last two quarter notes followed by a quarter rest.
|
|
24
|
+
2. **Given** the same selection, **When** the new meter holds *more* time per measure (3/4 changed to 4/4, or 4/4 changed to 6/4), **Then** the music is re-barred into the larger measures, no notes are lost, and no extra measures are added beyond those that already exist unless needed.
|
|
25
|
+
3. **Given** a note that would cross a new bar line (a half note starting on the third beat of a 3/4 measure), **When** the change is applied with Preserve music ticked, **Then** the note is split at the bar line into two tied notes whose total duration is unchanged.
|
|
26
|
+
4. **Given** measures with two voices, **When** the meter is changed with Preserve music ticked, **Then** each voice keeps its own notes in order in the new measures.
|
|
27
|
+
5. **Given** notes carrying dynamics, lyrics, articulations, ornaments, chords or other markings, **When** the meter is changed with Preserve music ticked, **Then** each marking stays with the note it was on.
|
|
28
|
+
6. **Given** a score with several staves, **When** the meter is changed with Preserve music ticked, **Then** every staff is re-barred, each keeping its own music, and every staff gets the same number of measures.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
### User Story 2 - Change takes effect only on OK (Priority: P1)
|
|
33
|
+
|
|
34
|
+
Today the time signature dialog changes the score immediately, as each field is edited, and Cancel puts the old signature back. Because re-barring music and adding measures is a large change, the dialog now only collects the choices. The score is not touched until the user clicks OK, and Cancel leaves the score exactly as it was.
|
|
35
|
+
|
|
36
|
+
**Why this priority**: Re-barring cannot safely run on every keystroke or arrow click, and the half-typed values that the live updates produce are a source of bugs. A single apply step is also what makes the change one undo step. Preserve music is not workable without it.
|
|
37
|
+
|
|
38
|
+
**Independent Test**: Open the dialog on a score, change the time signature, the Apply To choice and the Preserve music box, then click Cancel. The score, its measure count and its undo history are the same as before the dialog was opened. Open it again, make the same changes, click OK: the score changes, and one Undo restores it.
|
|
39
|
+
|
|
40
|
+
**Acceptance Scenarios**:
|
|
41
|
+
|
|
42
|
+
1. **Given** the dialog is open, **When** the user edits the beats, beat value, compound signature, display options or Apply To, **Then** the score does not change.
|
|
43
|
+
2. **Given** the user has made changes in the dialog, **When** they click Cancel (or dismiss the dialog), **Then** the score is unchanged and no undo step is recorded.
|
|
44
|
+
3. **Given** the user has made changes, **When** they click OK, **Then** all of the changes are applied together as one undo step, and a single Undo restores the score to what it was before the dialog opened, including removing any measures that were added.
|
|
45
|
+
4. **Given** the user has changed nothing, **When** they click OK, **Then** the score is unchanged and no undo step is recorded.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
### User Story 3 - Keep only what fits, as it is today (Priority: P2)
|
|
50
|
+
|
|
51
|
+
Sometimes the composer does want the old behavior: the music is a sketch, or they want to trim a pasted passage to a shorter meter. Unticking **Preserve music** applies the new time signature to the selected measures in place, keeping as much of each measure's music as fits and dropping the rest, with no measures added.
|
|
52
|
+
|
|
53
|
+
**Why this priority**: It is the existing behavior and must remain available, but it is not the new value.
|
|
54
|
+
|
|
55
|
+
**Independent Test**: With two 4/4 measures of quarter notes, change to 3/4 with Preserve music unticked and click OK. There are still two measures, each holding three quarter notes; the fourth quarter of each measure is gone.
|
|
56
|
+
|
|
57
|
+
**Acceptance Scenarios**:
|
|
58
|
+
|
|
59
|
+
1. **Given** Preserve music is unticked, **When** the user clicks OK, **Then** each selected measure keeps the music that fits in the new time signature, in order, and the music that does not fit is removed, exactly as time signature changes behave today.
|
|
60
|
+
2. **Given** Preserve music is unticked, **When** the user clicks OK, **Then** no measures are added or removed.
|
|
61
|
+
3. **Given** Preserve music is unticked and the new meter is longer than the old, **When** the user clicks OK, **Then** the remaining time in each measure is filled with rests, as today.
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
### User Story 4 - Choose which measures change (Priority: P2)
|
|
66
|
+
|
|
67
|
+
The dialog's **Apply To** choice (Selected Measures, Remaining Measures, Score) decides which measures change, and therefore which music is preserved. Preserve music works on whichever set of measures is chosen, and what follows that set in the score is left as it was, moved later if measures were added.
|
|
68
|
+
|
|
69
|
+
**Why this priority**: Without this, Preserve music would only be usable for whole-score changes, and a meter change in the middle of a piece is common.
|
|
70
|
+
|
|
71
|
+
**Independent Test**: In a six-measure score of 4/4, select measures 3 and 4, choose Selected Measures, change to 3/4 with Preserve music ticked, and click OK. Measures 1 and 2 and the old measures 5 and 6 are unchanged; measures 3 onward are re-barred, with a new measure inserted so that all of the old measures 3 and 4 music is kept, and the old measures 5 and 6 now follow.
|
|
72
|
+
|
|
73
|
+
**Acceptance Scenarios**:
|
|
74
|
+
|
|
75
|
+
1. **Given** Selected Measures, **When** the change is applied with Preserve music ticked, **Then** only the selected measures are re-barred; measures before them are untouched and measures after them keep their own time signature and music, now later in the score if measures were added.
|
|
76
|
+
2. **Given** Remaining Measures (from the selected measure to the end), **When** applied, **Then** the music from that measure to the end of the score is re-barred and any extra measures are added at the end.
|
|
77
|
+
3. **Given** Score, **When** applied, **Then** the whole score is re-barred.
|
|
78
|
+
4. **Given** the user switches Apply To in the dialog, **When** they click OK, **Then** the choice in effect at OK is the one applied.
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
### Edge Cases
|
|
83
|
+
|
|
84
|
+
- **Meter holds the same time per measure** (4/4 to 2/2, 3/4 to 6/8): the music already fits, so nothing is lost and no measures are added with Preserve music either ticked or unticked; the notes keep their order and durations.
|
|
85
|
+
- **A new meter that needs fewer measures**: measures are never removed. The measures that are not needed end up empty (rests), so no music is removed by accident.
|
|
86
|
+
- **Notes crossing a new bar line**: split into tied notes (see Story 1); a rest that crosses a bar line is split into rests.
|
|
87
|
+
- **Tuplets that would cross a new bar line**: a tuplet is kept whole where it can be. If it cannot be kept whole, the music in it is still preserved, in duration, in tied notes or rests, and nothing is dropped.
|
|
88
|
+
- **Ties across the old bar lines**: ties between notes that are re-barred stay with the notes. Ties split by the new bar lines are added as needed.
|
|
89
|
+
- **Pickup (partial) measures**: the music in a pickup measure is preserved at its actual duration, in the same way as any other music.
|
|
90
|
+
- **Grace notes**: kept with their notes.
|
|
91
|
+
- **Measure markings** (tempo, key signature, clef changes, repeats, endings, barlines, text): measures that exist already keep theirs. A measure added to hold the overflow takes the settings of the last measure of the selected set, except that repeat, ending and double-bar markings stay with the last measure of the set.
|
|
92
|
+
- **Other staves have different music or different voices**: each staff and voice is re-barred independently; all staves end up with the same number of measures.
|
|
93
|
+
- **A score with a single measure selected** (the common case): the music is re-barred from that measure and the extra measures are added immediately after it.
|
|
94
|
+
- **Changing only display options** (Use Symbol, Display Time Signature, the alternate display string): there is no change to durations, so no music is moved and no measures are added, regardless of the Preserve music box.
|
|
95
|
+
- **Music that does not fit even after adding measures**: cannot happen with Preserve music ticked; the number of measures added is enough to hold all of the music.
|
|
96
|
+
- **Compound (alternating) time signatures** (such as 3/4+2/4): the measures alternate between the parts, 3/4 then 2/4 then 3/4 and so on. Preserve music fills each measure to its own length in that pattern, starting with the first part at the first re-barred measure, and adds measures until all of the music fits.
|
|
97
|
+
- **Very large selections**: the change is still applied once, on OK, and the user sees one screen update.
|
|
98
|
+
|
|
99
|
+
## Requirements *(mandatory)*
|
|
100
|
+
|
|
101
|
+
### Functional Requirements
|
|
102
|
+
|
|
103
|
+
- **FR-001**: The Time Signature dialog MUST NOT change the score while it is open. Editing the time signature, the compound option, the display options, the alternate display string, Apply To or Preserve music MUST have no effect on the score until OK is clicked.
|
|
104
|
+
- **FR-002**: Clicking Cancel, or closing the dialog without OK, MUST leave the score, the selection and the undo history exactly as they were before the dialog was opened.
|
|
105
|
+
- **FR-003**: Clicking OK MUST apply all of the dialog's choices together as one undo step. A single Undo MUST restore the score to its state before the dialog opened, including removing every measure that was added.
|
|
106
|
+
- **FR-004**: Clicking OK when nothing in the dialog was changed MUST leave the score unchanged and MUST NOT record an undo step.
|
|
107
|
+
- **FR-005**: The dialog MUST have a **Preserve music** checkbox, ticked each time the dialog is opened.
|
|
108
|
+
- **FR-006**: With Preserve music ticked, the music of the selected measures (as set by Apply To) MUST be kept, in the same order with the same durations, pitches and markings, in measures of the new time signature, with no music lost.
|
|
109
|
+
- **FR-007**: With Preserve music ticked, if the new time signature would represent less total time than the music in the selected measures, the system MUST add as many measures as needed so that the total time of the new measures is at least the total time of the music being preserved. The added measures MUST be placed directly after the last re-barred measure, before the measures that followed the selected set.
|
|
110
|
+
- **FR-008**: With Preserve music ticked, the system MUST NOT remove measures. If fewer measures are needed, the unneeded ones MUST remain, filled with rests.
|
|
111
|
+
- **FR-009**: With Preserve music ticked, if the last re-barred measure is not full, the rest of it MUST be filled with rests.
|
|
112
|
+
- **FR-010**: With Preserve music ticked, a note or rest that crosses a new bar line MUST be split at the bar line. Split notes MUST be tied so that they sound the same; split rests MUST add up to the original duration.
|
|
113
|
+
- **FR-011**: With Preserve music ticked, markings attached to notes (dynamics, lyrics, annotations, chords, articulations, ornaments, grace notes, arpeggios, microtones) MUST stay with the notes they were on. For a note split by a bar line, the markings stay with the first part.
|
|
114
|
+
- **FR-012**: With Preserve music ticked, every voice in the selected measures MUST be preserved separately, in its own voice.
|
|
115
|
+
- **FR-013**: With Preserve music ticked in a score with several staves, every staff MUST be re-barred with its own music and every staff MUST end up with the same number of measures, so the staves stay aligned.
|
|
116
|
+
- **FR-014**: With Preserve music unticked, the time signature MUST be applied to the selected measures in place, keeping the music that fits in each measure and removing the rest, exactly as time signature changes behave before this feature. No measures MUST be added.
|
|
117
|
+
- **FR-015**: The Apply To choice (Selected Measures, Remaining Measures, Score) MUST decide which measures are changed, with both settings of Preserve music. The choice in effect when OK is clicked is the one used.
|
|
118
|
+
- **FR-016**: Measures before the selected set, and measures after it, MUST keep their own time signatures, music and markings. Measures after the set MUST be moved later by the number of measures added.
|
|
119
|
+
- **FR-017**: Slurs, ties, hairpins, text and other things that join music across measures in the selected set MUST stay attached to the same notes after the change, wherever those notes end up.
|
|
120
|
+
- **FR-018**: A change to the display options only (Use Symbol, Display Time Signature, alternate display string) MUST not move any music or add measures.
|
|
121
|
+
- **FR-019**: Where the new time signature has the same total time per measure as the old, the music MUST be unchanged, whether Preserve music is ticked or not.
|
|
122
|
+
- **FR-020**: Scores saved before this change MUST open and behave as before, and scores that have been changed with Preserve music MUST save and reload with the same music.
|
|
123
|
+
|
|
124
|
+
### Key Entities
|
|
125
|
+
|
|
126
|
+
- **Selected measures**: The set of measures that the time signature change applies to, found from the selection and the Apply To choice. This is the "original set" whose music is preserved.
|
|
127
|
+
- **Preserved music**: Everything in the selected measures, in every staff and voice: notes, rests, tuplets, ties, grace notes and the markings attached to notes.
|
|
128
|
+
- **Re-barred measures**: The measures of the new time signature that hold the preserved music. These are the original measures with the new signature, plus any measures added to hold the overflow.
|
|
129
|
+
- **Preserve music option**: A yes/no choice in the dialog, on by default, that selects between re-barring all of the music (adding measures if needed) and keeping only what fits in each measure.
|
|
130
|
+
|
|
131
|
+
## Success Criteria *(mandatory)*
|
|
132
|
+
|
|
133
|
+
### Measurable Outcomes
|
|
134
|
+
|
|
135
|
+
- **SC-001**: With Preserve music ticked, changing the time signature never loses sounding time: the total duration of the music in the selected measures is the same before and after in 100% of tested cases (4/4 to 3/4, 3/4 to 4/4, 4/4 to 6/8, 4/4 to 5/8, 3/4 to 7/8, alternating meters such as 3/4+2/4, pickup measures).
|
|
136
|
+
- **SC-002**: In 100% of tested cases, the sequence of pitches and rhythms read from the re-barred measures, with tied notes joined, is the same as the sequence before the change, for every staff and voice.
|
|
137
|
+
- **SC-003**: For the example of two 4/4 measures changed to 3/4, the result is three 3/4 measures, and a user can get this result in a single open-and-confirm of the dialog (one OK click, one Undo to reverse).
|
|
138
|
+
- **SC-004**: While the dialog is open, the score, measure count and undo history are unchanged in 100% of the tested interactions, and after Cancel they are identical to before the dialog opened.
|
|
139
|
+
- **SC-005**: With Preserve music unticked, the result of every tested time signature change matches the result from before this feature, measure for measure.
|
|
140
|
+
- **SC-006**: One Undo after OK restores the score to exactly its content before the change in 100% of tested cases, including score-wide changes that added measures to several staves.
|
|
141
|
+
- **SC-007**: Clicking OK on a time signature change across a score of 100 measures completes, and the score is redrawn, in under 2 seconds.
|
|
142
|
+
|
|
143
|
+
## Assumptions
|
|
144
|
+
|
|
145
|
+
- The current time signature dialog applies the new time signature to the measure with that index in *every* staff of the score; this stays true, and so Preserve music re-bars and adds measures in every staff.
|
|
146
|
+
- Because the change is not committed until OK, the dialog does not preview the new meter in the score while it is open. Any preview inside the dialog itself is out of scope.
|
|
147
|
+
- The existing behavior (keep what fits, fill the rest with rests) is the behavior of the unticked box, and it is not changed.
|
|
148
|
+
- The Preserve music box is not remembered between uses of the dialog; it is ticked each time, as the request says "checked by default".
|
|
149
|
+
- Preserve music never removes measures. Where re-barring would leave fewer measures than the selected set, the extra measures stay, filled with rests. This is the safest choice for the user's music and matches "no less time represented".
|
|
150
|
+
- "Original set of selected measures" means the measures chosen by the Selected Measures, Remaining Measures or Score option at the time OK is clicked, for all staves.
|
|
151
|
+
- Measures added by Preserve music take their settings (key signature, clef, tempo, etc.) from the last measure of the re-barred set, which is the most natural continuation of the music.
|
|
152
|
+
- Multi-measure rests and measures that are part of one at the edit point are treated as ordinary measures for this feature.
|
|
153
|
+
- Scope is the Time Signature dialog and the time signature change it performs. Other ways that measures are created or changed (Insert Measures, Fill Measures, Paste) are not changed.
|