smoosic 2.0.1 → 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 +171 -78
- package/package.json +82 -77
- package/release/smoosic.js +171 -78
- package/release/styles/fonts/MaterialIconsOutlined-Regular.otf +0 -0
- 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,7 +1,5 @@
|
|
|
1
1
|
// [Smoosic](https://github.com/AaronDavidNewman/Smoosic)
|
|
2
2
|
// Copyright (c) Aaron David Newman 2021.
|
|
3
|
-
import { SuiRenderState } from "../render/sui/renderState";
|
|
4
|
-
|
|
5
3
|
export type promiseFunction = () => void;
|
|
6
4
|
export type promiseCondition = () => boolean;
|
|
7
5
|
export type promiseInstance = () => Promise<any>;
|
|
@@ -22,6 +20,8 @@ export function TEmptyPromise<T>(obj: T): Promise<T> {
|
|
|
22
20
|
});
|
|
23
21
|
}
|
|
24
22
|
/**
|
|
23
|
+
* Helpers from before async/await was available. The application itself no longer uses
|
|
24
|
+
* them; this class is kept, unchanged, for external applications that call it.
|
|
25
25
|
* @internal
|
|
26
26
|
*/
|
|
27
27
|
export class PromiseHelpers {
|
|
@@ -1,118 +1,117 @@
|
|
|
1
|
-
// [Smoosic](https://github.com/AaronDavidNewman/Smoosic)
|
|
2
|
-
// Copyright (c) Aaron David Newman 2021.
|
|
3
|
-
import { SmoAudioPitch } from '../../smo/data/music';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
'
|
|
19
|
-
'
|
|
20
|
-
'
|
|
21
|
-
'
|
|
22
|
-
'
|
|
23
|
-
'
|
|
24
|
-
'
|
|
25
|
-
'
|
|
26
|
-
'
|
|
27
|
-
'
|
|
28
|
-
'
|
|
29
|
-
'
|
|
30
|
-
'
|
|
31
|
-
'
|
|
32
|
-
'
|
|
33
|
-
'
|
|
34
|
-
|
|
35
|
-
'
|
|
36
|
-
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
*
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
*
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
static
|
|
82
|
-
static
|
|
83
|
-
static
|
|
84
|
-
static
|
|
85
|
-
static
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
*
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
const
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
1
|
+
// [Smoosic](https://github.com/AaronDavidNewman/Smoosic)
|
|
2
|
+
// Copyright (c) Aaron David Newman 2021.
|
|
3
|
+
import { SmoAudioPitch } from '../../smo/data/music';
|
|
4
|
+
import { Ref } from 'vue';
|
|
5
|
+
import { SmoOscillatorInfo, SmoInstrument, SmoOscillatorInfoAllTypes,
|
|
6
|
+
SmoOscillatorInfoNumberType, SmoOscillatorInfoNumberArType, SmoOscillatorInfoStringType, SmoOscillatorInfoStringNullType,
|
|
7
|
+
SmoOscillatorInfoWaveformType, SmoOscillatorInfoSustainType, SmoOscillatorInfoOptionsType } from '../../smo/data/staffModifiers';
|
|
8
|
+
import {
|
|
9
|
+
getSoundfontKits,
|
|
10
|
+
Soundfont,
|
|
11
|
+
getSoundfontNames,
|
|
12
|
+
Reverb,
|
|
13
|
+
Soundfont2Sampler,
|
|
14
|
+
} from 'smplr';
|
|
15
|
+
|
|
16
|
+
export const instrumentSampleMap: Record<string, string> = {
|
|
17
|
+
'piano':'acoustic_grand_piano',
|
|
18
|
+
'accordion': 'accordion',
|
|
19
|
+
'electricPiano':'electric_piano_1',
|
|
20
|
+
'bass':'acoustic_bass',
|
|
21
|
+
'jazzBass': 'electric_bass_finger',
|
|
22
|
+
'eGuitar': 'electric_guitar_jazz',
|
|
23
|
+
'cello': 'cello',
|
|
24
|
+
'violin': 'violin',
|
|
25
|
+
'trumpet':'trumpet',
|
|
26
|
+
'horn': 'french_horn',
|
|
27
|
+
'trombone':'trombone',
|
|
28
|
+
'tuba': 'tuba',
|
|
29
|
+
'clarinet':'clarinet',
|
|
30
|
+
'flute':'flute',
|
|
31
|
+
'altoSax':'alto_sax',
|
|
32
|
+
'tenorSax':'tenor_sax',
|
|
33
|
+
'bariSax':'baritone_sax',
|
|
34
|
+
'pad': 'pad_3_polysynth',
|
|
35
|
+
'percussion':'timpani'
|
|
36
|
+
};
|
|
37
|
+
export const loadedSoundfonts: Record<string, Soundfont> = {};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* A set of parameters from the instrument interface used to create audio from samples.
|
|
41
|
+
* @category SuiAudio
|
|
42
|
+
*/
|
|
43
|
+
export interface SampleChooserParams {
|
|
44
|
+
family?: string,
|
|
45
|
+
instrument: string,
|
|
46
|
+
frequency: number,
|
|
47
|
+
duration: number,
|
|
48
|
+
gain: number,
|
|
49
|
+
articulation?: string
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* A function prototype that chooses from among samples to return the correct one for that note
|
|
53
|
+
*/
|
|
54
|
+
export type SampleChooser = (params: SampleChooserParams, samples: SmoOscillatorInfo[]) => AudioSample | null;
|
|
55
|
+
/**
|
|
56
|
+
* A specific audio sample that can be converted into an audio node
|
|
57
|
+
* @category SuiAudio
|
|
58
|
+
*/
|
|
59
|
+
export interface AudioSample {
|
|
60
|
+
sample: AudioBuffer,
|
|
61
|
+
frequency: number,
|
|
62
|
+
patch: string,
|
|
63
|
+
gain: number
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Interface for a chooser function and a set of samples
|
|
67
|
+
* @category SuiAudio
|
|
68
|
+
*/
|
|
69
|
+
export interface InstrumentSampleChooser {
|
|
70
|
+
instrument: string,
|
|
71
|
+
sampleChooser: SampleChooser,
|
|
72
|
+
samples: SmoOscillatorInfo[]
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Logic to create audio nodes out of HTML5 media elements
|
|
77
|
+
* @category SuiAudio
|
|
78
|
+
*/
|
|
79
|
+
export class SuiSampleMedia {
|
|
80
|
+
static sampleFiles: SmoOscillatorInfo[] = [];
|
|
81
|
+
static sampleBufferMap: Record<string, AudioBuffer> = {};
|
|
82
|
+
static sampleOscMap: Record<string, SmoOscillatorInfo[]> = {};
|
|
83
|
+
static instrumentChooser: Record<string, InstrumentSampleChooser> = {};
|
|
84
|
+
static receivedBuffer: boolean = false;
|
|
85
|
+
static getFamilyForInstrument(instKey: string): string {
|
|
86
|
+
const sound = SuiSampleMedia.instrumentChooser[instKey];
|
|
87
|
+
if (sound && sound.samples.length) {
|
|
88
|
+
return sound.samples[0].family;
|
|
89
|
+
}
|
|
90
|
+
return 'keyboard';
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Load samples so we can play the music
|
|
94
|
+
* @returns - promise, resolved when loaded
|
|
95
|
+
*/
|
|
96
|
+
static async samplePromise(audio: AudioContext, setProgress: (percent: number) => void): Promise<any> {
|
|
97
|
+
let i = 0;
|
|
98
|
+
const instrumentKeys = Object.keys(instrumentSampleMap);
|
|
99
|
+
const context = new AudioContext() as unknown as AudioContext;
|
|
100
|
+
for (let i = 0; i < instrumentKeys.length; ++i) {
|
|
101
|
+
const key = instrumentKeys[i];
|
|
102
|
+
const sampler = instrumentSampleMap[key];
|
|
103
|
+
const obj: any = {};
|
|
104
|
+
if (key === 'percussion') {
|
|
105
|
+
obj['instrumentUrl'] = 'https://smoosic.github.io/SmoSounds/drumfont/percussion-ogg.js';
|
|
106
|
+
} else {
|
|
107
|
+
obj['instrument'] = sampler;
|
|
108
|
+
}
|
|
109
|
+
const instrument = new Soundfont(context, obj);
|
|
110
|
+
// instrument.output.addEffect("reverb", new Reverb(context), 0.9);
|
|
111
|
+
await instrument.load;
|
|
112
|
+
instrument.output.addEffect("reverb", new Reverb(context), 0.1);
|
|
113
|
+
loadedSoundfonts[key] = instrument;
|
|
114
|
+
setProgress(Math.round(((i + 1) / instrumentKeys.length) * 100));
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// [Smoosic](https://github.com/AaronDavidNewman/Smoosic)
|
|
2
|
+
// Copyright (c) Aaron David Newman 2021.
|
|
3
|
+
/**
|
|
4
|
+
* Pure helpers that split a page into contiguous divisions along its flow dimension, and find
|
|
5
|
+
* the division that contains a position. SvgPage uses them to file and look up modifiers.
|
|
6
|
+
* This module has no imports so it can be tested without a DOM or VexFlow.
|
|
7
|
+
* @module /render/sui/pageDivisions
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A band of a page. A division contains positions from `start` (inclusive) to `end`
|
|
12
|
+
* (exclusive), except the last division of a page, which also contains `end`.
|
|
13
|
+
* @category SuiRender
|
|
14
|
+
*/
|
|
15
|
+
export interface PageDivision {
|
|
16
|
+
start: number,
|
|
17
|
+
end: number
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Split `[pageStart, pageStart + pageExtent]` into `count` contiguous divisions. Each division
|
|
22
|
+
* ends exactly where the next begins, and the last ends exactly at the page edge.
|
|
23
|
+
* @param pageStart position of the leading edge of the page
|
|
24
|
+
* @param pageExtent size of the page along the flow dimension
|
|
25
|
+
* @param count number of divisions
|
|
26
|
+
* @returns the divisions, in increasing order
|
|
27
|
+
*/
|
|
28
|
+
export function computeDivisions(pageStart: number, pageExtent: number, count: number): PageDivision[] {
|
|
29
|
+
const rv: PageDivision[] = [];
|
|
30
|
+
const edge = (i: number) => (i === count ? pageStart + pageExtent : pageStart + (pageExtent * i) / count);
|
|
31
|
+
for (let i = 0; i < count; ++i) {
|
|
32
|
+
rv.push({ start: edge(i), end: edge(i + 1) });
|
|
33
|
+
}
|
|
34
|
+
return rv;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Find the division containing `position`. A position on a boundary between two divisions
|
|
39
|
+
* belongs to the later one; the page's trailing edge belongs to the last division.
|
|
40
|
+
* @param position position along the flow dimension
|
|
41
|
+
* @param divisions the page's divisions, from {@link computeDivisions}
|
|
42
|
+
* @returns the index of the division, or -1 if the position is outside the page
|
|
43
|
+
*/
|
|
44
|
+
export function findDivision(position: number, divisions: PageDivision[]): number {
|
|
45
|
+
if (!Number.isFinite(position) || divisions.length === 0) {
|
|
46
|
+
return -1;
|
|
47
|
+
}
|
|
48
|
+
const last = divisions.length - 1;
|
|
49
|
+
if (position < divisions[0].start || position > divisions[last].end) {
|
|
50
|
+
return -1;
|
|
51
|
+
}
|
|
52
|
+
for (let i = 0; i < last; ++i) {
|
|
53
|
+
if (position < divisions[i].end) {
|
|
54
|
+
return i;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return last;
|
|
58
|
+
}
|