smoosic 1.0.25 → 1.0.26
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 +1 -1
- package/package.json +1 -1
- package/release/smoosic.js +1 -1
- package/src/application/exports.ts +1 -0
- package/types/src/application/application.d.ts +102 -102
- package/types/src/application/common.d.ts +74 -74
- package/types/src/application/configuration.d.ts +74 -74
- package/types/src/application/dom.d.ts +8 -8
- package/types/src/application/dynamicInit.d.ts +1 -1
- package/types/src/application/eventHandler.d.ts +78 -78
- package/types/src/application/exports.d.ts +494 -493
- package/types/src/application/generateVexTests.d.ts +10 -10
- package/types/src/application/keyCommands.d.ts +90 -90
- package/types/src/common/bootstrap.bundle.d.ts +1138 -1138
- package/types/src/common/htmlHelpers.d.ts +105 -105
- package/types/src/common/jszip.d.ts +2 -2
- package/types/src/common/midi-parser.d.ts +38 -38
- package/types/src/common/promiseHelpers.d.ts +30 -30
- package/types/src/common/serializationHelpers.d.ts +29 -29
- package/types/src/common/textformatter.d.ts +140 -140
- package/types/src/common/vex.d.ts +222 -222
- package/types/src/render/audio/musicCursor.d.ts +25 -25
- package/types/src/render/audio/oscillator.d.ts +98 -98
- package/types/src/render/audio/player.d.ts +141 -141
- package/types/src/render/audio/samples.d.ts +56 -56
- package/types/src/render/sui/configuration.d.ts +12 -12
- package/types/src/render/sui/formatter.d.ts +151 -151
- package/types/src/render/sui/layoutDebug.d.ts +43 -43
- package/types/src/render/sui/mapper.d.ts +116 -116
- package/types/src/render/sui/piano.d.ts +46 -46
- package/types/src/render/sui/renderState.d.ts +88 -88
- package/types/src/render/sui/scoreRender.d.ts +93 -93
- package/types/src/render/sui/scoreView.d.ts +267 -267
- package/types/src/render/sui/scoreViewOperations.d.ts +594 -594
- package/types/src/render/sui/scroller.d.ts +34 -34
- package/types/src/render/sui/svgHelpers.d.ts +85 -85
- package/types/src/render/sui/svgPageMap.d.ts +318 -318
- package/types/src/render/sui/textEdit.d.ts +310 -310
- package/types/src/render/sui/textRender.d.ts +189 -189
- package/types/src/render/sui/tracker.d.ts +90 -90
- package/types/src/render/vex/glyphDimensions.d.ts +23 -23
- package/types/src/render/vex/smoAdapter.d.ts +46 -46
- package/types/src/render/vex/toVex.d.ts +13 -13
- package/types/src/render/vex/vxMeasure.d.ts +95 -95
- package/types/src/render/vex/vxNote.d.ts +55 -55
- package/types/src/render/vex/vxSystem.d.ts +64 -64
- package/types/src/smo/data/common.d.ts +220 -220
- package/types/src/smo/data/measure.d.ts +510 -510
- package/types/src/smo/data/measureModifiers.d.ts +506 -506
- package/types/src/smo/data/music.d.ts +438 -438
- package/types/src/smo/data/note.d.ts +485 -485
- package/types/src/smo/data/noteModifiers.d.ts +590 -590
- package/types/src/smo/data/partInfo.d.ts +162 -162
- package/types/src/smo/data/score.d.ts +395 -395
- package/types/src/smo/data/scoreModifiers.d.ts +433 -433
- package/types/src/smo/data/scoreText.d.ts +277 -277
- package/types/src/smo/data/staffModifiers.d.ts +767 -767
- package/types/src/smo/data/systemStaff.d.ts +238 -238
- package/types/src/smo/data/tuplet.d.ts +146 -146
- package/types/src/smo/midi/midiToSmo.d.ts +198 -198
- package/types/src/smo/midi/smoToMidi.d.ts +23 -23
- package/types/src/smo/mxml/smoToXml.d.ts +165 -165
- package/types/src/smo/mxml/xmlHelpers.d.ts +140 -140
- package/types/src/smo/mxml/xmlState.d.ts +257 -257
- package/types/src/smo/mxml/xmlToSmo.d.ts +92 -92
- package/types/src/smo/xform/beamers.d.ts +46 -46
- package/types/src/smo/xform/copypaste.d.ts +99 -99
- package/types/src/smo/xform/operations.d.ts +127 -127
- package/types/src/smo/xform/roadmap.d.ts +70 -70
- package/types/src/smo/xform/selections.d.ts +153 -153
- package/types/src/smo/xform/tickDuration.d.ts +155 -155
- package/types/src/smo/xform/tickMap.d.ts +34 -34
- package/types/src/smo/xform/undo.d.ts +142 -142
- package/types/src/smo/xform/updateAudio.d.ts +9 -9
- package/types/src/styles/font_metrics/Commissioner-Medium-Metrics.d.ts +871 -871
- package/types/src/styles/font_metrics/ConcertOne-Regular.d.ts +871 -871
- package/types/src/styles/font_metrics/Merriweather-Regular.d.ts +871 -871
- package/types/src/styles/font_metrics/arial_metrics.d.ts +870 -870
- package/types/src/styles/font_metrics/ssp-sans-metrics.d.ts +871 -871
- package/types/src/styles/font_metrics/ssp-serif-metrics.d.ts +871 -871
- package/types/src/styles/font_metrics/times_metrics.d.ts +870 -870
- package/types/src/ui/buttons/button.d.ts +95 -95
- package/types/src/ui/buttons/collapsable.d.ts +42 -42
- package/types/src/ui/buttons/display.d.ts +23 -23
- package/types/src/ui/buttons/ribbon.d.ts +76 -76
- package/types/src/ui/common.d.ts +45 -45
- package/types/src/ui/composable/draggable.d.ts +12 -12
- package/types/src/ui/configuration.d.ts +31 -31
- package/types/src/ui/dialogs/adapter.d.ts +107 -107
- package/types/src/ui/dialogs/addMeasure.d.ts +20 -20
- package/types/src/ui/dialogs/arpeggio.d.ts +2 -2
- package/types/src/ui/dialogs/articulation.d.ts +2 -2
- package/types/src/ui/dialogs/audioSettings.d.ts +32 -32
- package/types/src/ui/dialogs/chordChange.d.ts +35 -35
- package/types/src/ui/dialogs/clefChange.d.ts +2 -2
- package/types/src/ui/dialogs/components/baseComponent.d.ts +158 -158
- package/types/src/ui/dialogs/components/button.d.ts +54 -54
- package/types/src/ui/dialogs/components/buttonArray.d.ts +101 -101
- package/types/src/ui/dialogs/components/checkdrop.d.ts +27 -27
- package/types/src/ui/dialogs/components/dragText.d.ts +27 -27
- package/types/src/ui/dialogs/components/dropdown.d.ts +78 -78
- package/types/src/ui/dialogs/components/fileDownload.d.ts +28 -28
- package/types/src/ui/dialogs/components/fontComponent.d.ts +32 -32
- package/types/src/ui/dialogs/components/noteText.d.ts +98 -98
- package/types/src/ui/dialogs/components/pitch.d.ts +95 -95
- package/types/src/ui/dialogs/components/rocker.d.ts +66 -66
- package/types/src/ui/dialogs/components/staffComponents.d.ts +77 -77
- package/types/src/ui/dialogs/components/textCheck.d.ts +38 -38
- package/types/src/ui/dialogs/components/textInPlace.d.ts +90 -90
- package/types/src/ui/dialogs/components/textInput.d.ts +58 -58
- package/types/src/ui/dialogs/components/tie.d.ts +41 -41
- package/types/src/ui/dialogs/components/toggle.d.ts +53 -53
- package/types/src/ui/dialogs/components/tree.d.ts +46 -46
- package/types/src/ui/dialogs/customTuplets.d.ts +25 -25
- package/types/src/ui/dialogs/dialog.d.ts +201 -201
- package/types/src/ui/dialogs/durations.d.ts +2 -2
- package/types/src/ui/dialogs/dynamics.d.ts +37 -37
- package/types/src/ui/dialogs/endings.d.ts +61 -61
- package/types/src/ui/dialogs/factory.d.ts +15 -15
- package/types/src/ui/dialogs/fileDialogs.d.ts +4 -4
- package/types/src/ui/dialogs/fonts.d.ts +2 -2
- package/types/src/ui/dialogs/globalLayout.d.ts +2 -2
- package/types/src/ui/dialogs/gracenote.d.ts +2 -2
- package/types/src/ui/dialogs/hairpin.d.ts +35 -35
- package/types/src/ui/dialogs/instrument.d.ts +3 -3
- package/types/src/ui/dialogs/keySignature.d.ts +33 -33
- package/types/src/ui/dialogs/library.d.ts +70 -70
- package/types/src/ui/dialogs/lyric.d.ts +39 -39
- package/types/src/ui/dialogs/measureFormat.d.ts +52 -52
- package/types/src/ui/dialogs/microtones.d.ts +2 -2
- package/types/src/ui/dialogs/noteHead.d.ts +2 -2
- package/types/src/ui/dialogs/ornament.d.ts +2 -2
- package/types/src/ui/dialogs/pageLayout.d.ts +2 -2
- package/types/src/ui/dialogs/partInfo.d.ts +2 -2
- package/types/src/ui/dialogs/pedalMarking.d.ts +35 -35
- package/types/src/ui/dialogs/pitch.d.ts +2 -2
- package/types/src/ui/dialogs/preferences.d.ts +2 -2
- package/types/src/ui/dialogs/scoreId.d.ts +2 -2
- package/types/src/ui/dialogs/scoreView.d.ts +2 -2
- package/types/src/ui/dialogs/slur.d.ts +57 -57
- package/types/src/ui/dialogs/staffGroup.d.ts +2 -2
- package/types/src/ui/dialogs/tabNote.d.ts +32 -32
- package/types/src/ui/dialogs/tabStave.d.ts +43 -43
- package/types/src/ui/dialogs/tempo.d.ts +50 -50
- package/types/src/ui/dialogs/textBlock.d.ts +61 -61
- package/types/src/ui/dialogs/textBracket.d.ts +35 -35
- package/types/src/ui/dialogs/tie.d.ts +41 -41
- package/types/src/ui/dialogs/timeSignature.d.ts +34 -34
- package/types/src/ui/dialogs/transposeScore.d.ts +2 -2
- package/types/src/ui/dialogs/volta.d.ts +40 -40
- package/types/src/ui/eventSource.d.ts +63 -63
- package/types/src/ui/exceptions.d.ts +12 -12
- package/types/src/ui/fileio/fileInput.d.ts +12 -12
- package/types/src/ui/fileio/library.d.ts +40 -40
- package/types/src/ui/fileio/xhrLoader.d.ts +18 -18
- package/types/src/ui/help.d.ts +22 -22
- package/types/src/ui/i18n/language.d.ts +37 -37
- package/types/src/ui/i18n/language_ar.d.ts +5 -5
- package/types/src/ui/i18n/language_de.d.ts +1 -1
- package/types/src/ui/i18n/language_en.d.ts +18 -18
- package/types/src/ui/i18n/translationEditor.d.ts +14 -14
- package/types/src/ui/keyBindings/default/editorKeys.d.ts +7 -7
- package/types/src/ui/keyBindings/default/trackerKeys.d.ts +7 -7
- package/types/src/ui/menus/beams.d.ts +13 -13
- package/types/src/ui/menus/edit.d.ts +8 -8
- package/types/src/ui/menus/file.d.ts +26 -26
- package/types/src/ui/menus/help.d.ts +8 -8
- package/types/src/ui/menus/keySignature.d.ts +13 -13
- package/types/src/ui/menus/language.d.ts +12 -12
- package/types/src/ui/menus/manager.d.ts +57 -57
- package/types/src/ui/menus/measure.d.ts +8 -8
- package/types/src/ui/menus/menu.d.ts +136 -136
- package/types/src/ui/menus/note.d.ts +8 -8
- package/types/src/ui/menus/partSelection.d.ts +19 -19
- package/types/src/ui/menus/parts.d.ts +50 -50
- package/types/src/ui/menus/score.d.ts +20 -20
- package/types/src/ui/menus/staffModifier.d.ts +21 -21
- package/types/src/ui/menus/text.d.ts +8 -8
- package/types/src/ui/menus/timeSignature.d.ts +12 -12
- package/types/src/ui/menus/tuplets.d.ts +13 -13
- package/types/src/ui/menus/voices.d.ts +8 -8
- package/types/src/ui/modalDialogs.d.ts +1 -1
- package/types/src/ui/navigation.d.ts +15 -15
- package/types/src/ui/qwerty.d.ts +41 -41
- package/types/src/ui/ribbonLayout/default/defaultRibbon.d.ts +15 -15
- package/types/src/ui/ribbonLayout/default/tabletRibbon.d.ts +22 -22
- package/types/typedoc.d.ts +158 -158
|
@@ -1,438 +1,438 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* shared music theory and audio frequency routines, helper functions etc.
|
|
3
|
-
* @module /smo/data/music
|
|
4
|
-
*/
|
|
5
|
-
import { SmoNote } from './note';
|
|
6
|
-
import { Pitch, PitchKey, Clef, PitchLetter, AccidentalArray, AccidentalDisplay } from './common';
|
|
7
|
-
import { SmoMicrotone } from './noteModifiers';
|
|
8
|
-
/**
|
|
9
|
-
* Used for xml clef conversion
|
|
10
|
-
* @category SmoObject
|
|
11
|
-
*/
|
|
12
|
-
export interface ClefSign {
|
|
13
|
-
sign: string;
|
|
14
|
-
line?: number;
|
|
15
|
-
octave?: number;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* calculate the pitch frequency, just temperment a=440, etc.
|
|
19
|
-
* @category SmoTransform
|
|
20
|
-
*/
|
|
21
|
-
export declare class SmoAudioPitch {
|
|
22
|
-
static _computeFrequencies(): Record<string, number>;
|
|
23
|
-
static frequencies: Record<string, number> | null;
|
|
24
|
-
static frequencyKeys: string[] | null;
|
|
25
|
-
static get pitchFrequencyKeys(): string[];
|
|
26
|
-
static get pitchFrequencyMap(): Record<string, number>;
|
|
27
|
-
static frequencyToVexPitch(freq: number): string;
|
|
28
|
-
static _rawPitchToFrequency(smoPitch: Pitch, offset: number): number;
|
|
29
|
-
/**
|
|
30
|
-
*
|
|
31
|
-
* @param smoPitch - pitch from the SMO object
|
|
32
|
-
* @param offset - transpose 1/2 steps, 0 means no transpose
|
|
33
|
-
* @param tone - optional transpose microtone
|
|
34
|
-
* @returns
|
|
35
|
-
*/
|
|
36
|
-
static smoPitchToFrequency(smoPitch: Pitch, offset: number, tone: SmoMicrotone | null): number;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* interface for valid non-tuplet duration value (all the
|
|
40
|
-
* base note lengths + dots)
|
|
41
|
-
* @category SmoTransform
|
|
42
|
-
*/
|
|
43
|
-
export interface SimpleDuration {
|
|
44
|
-
index: number;
|
|
45
|
-
ticks: number;
|
|
46
|
-
baseTicks: number;
|
|
47
|
-
dots: number;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* description of a scale entry, from vex theory routines
|
|
51
|
-
* @category SmoTransform
|
|
52
|
-
*/
|
|
53
|
-
export interface VexNoteValue {
|
|
54
|
-
root_index: number;
|
|
55
|
-
int_val: number;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Describe the music theory role of an accidental vs. the key signature.
|
|
59
|
-
* Used to determine default enharmonic spelling.
|
|
60
|
-
* @category SmoTransform
|
|
61
|
-
*/
|
|
62
|
-
export interface KeySignatureRole {
|
|
63
|
-
letter: PitchLetter;
|
|
64
|
-
accidental: string;
|
|
65
|
-
role: string;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Helper functions that build on the VX music theory routines, and other
|
|
69
|
-
* utilities I wish were in VF.Music but aren't
|
|
70
|
-
* ## Note on pitch and duration format
|
|
71
|
-
* We use some VEX music theory routines and frequently need to convert
|
|
72
|
-
* formats from SMO format. We also use the same 'ticks' abstraction for
|
|
73
|
-
* durations.
|
|
74
|
-
*
|
|
75
|
-
* `Smo` uses pitch JSON:
|
|
76
|
-
* ```javascript
|
|
77
|
-
* {note:'c',accidental:'#',octave:4}
|
|
78
|
-
* ```
|
|
79
|
-
*
|
|
80
|
-
* `Vex` usually uses a canonical string:
|
|
81
|
-
*
|
|
82
|
-
* `'c#/4'`
|
|
83
|
-
*
|
|
84
|
-
* Depending on the operation, the octave might be omitted
|
|
85
|
-
*
|
|
86
|
-
* `Smo` uses a JSON for duration always:
|
|
87
|
-
* ```javascript
|
|
88
|
-
* {numerator:4096,denominator:1,remainder:0}
|
|
89
|
-
* ```
|
|
90
|
-
* `Vex` uses a letter duration (`'4'` or `'q'`for 1/4 note) and `'d'` for dot.
|
|
91
|
-
*
|
|
92
|
-
* I try to indicate whether I am using vex or smo notation in the function name.
|
|
93
|
-
* Duration methods start around line 1100
|
|
94
|
-
* @category SmoTransform
|
|
95
|
-
*/
|
|
96
|
-
export declare class SmoMusic {
|
|
97
|
-
/**
|
|
98
|
-
*Normalized gain from dynamics
|
|
99
|
-
*/
|
|
100
|
-
static get dynamicVolumeMap(): Record<string, number>;
|
|
101
|
-
/**
|
|
102
|
-
* Ported from vex, used to convert pitches to numerical values
|
|
103
|
-
* */
|
|
104
|
-
static get noteValues(): Record<string, VexNoteValue>;
|
|
105
|
-
static accidentalDisplay(pitch: Pitch, keySignature: string, duration: number, accArray: AccidentalArray[]): AccidentalDisplay | null;
|
|
106
|
-
/**
|
|
107
|
-
* return Vex canonical note enharmonic - e.g. Bb to A#
|
|
108
|
-
* */
|
|
109
|
-
static vexToCannonical(vexKey: string): string;
|
|
110
|
-
/**
|
|
111
|
-
* A note array (sans octave) in key-signature order
|
|
112
|
-
*/
|
|
113
|
-
static get circleOfFifths(): PitchKey[];
|
|
114
|
-
/**
|
|
115
|
-
* Return the number of lines above first ledger line below the staff.
|
|
116
|
-
* e.g. middle c in treble clef returns 0. Top line f in treble returns 5.
|
|
117
|
-
* @param clef
|
|
118
|
-
* @param pitch
|
|
119
|
-
* @returns number where 0 is the first ledger line below
|
|
120
|
-
*/
|
|
121
|
-
static pitchToStaffLine(clef: string, smoPitch: Pitch): number;
|
|
122
|
-
/**
|
|
123
|
-
* return above if the first pitch is above line 3, else below
|
|
124
|
-
* @param note
|
|
125
|
-
* @returns
|
|
126
|
-
*/
|
|
127
|
-
static positionFromStaffLine(note: SmoNote): "above" | "below";
|
|
128
|
-
/**
|
|
129
|
-
* gives the index into circle-of-fifths array for a pitch, considering enharmonics.
|
|
130
|
-
* */
|
|
131
|
-
static circleOfFifthsIndex(smoPitch: Pitch): number;
|
|
132
|
-
/**
|
|
133
|
-
* Get pitch to the right in circle of fifths
|
|
134
|
-
* */
|
|
135
|
-
static addSharp(smoPitch: Pitch): Pitch;
|
|
136
|
-
/**
|
|
137
|
-
* Get pitch to the left in circle of fifths
|
|
138
|
-
*/
|
|
139
|
-
static addFlat(smoPitch: Pitch): Pitch;
|
|
140
|
-
/**
|
|
141
|
-
* Add @param {number} - sharps
|
|
142
|
-
*/
|
|
143
|
-
static addSharps(smoPitch: Pitch, distance: number): Pitch;
|
|
144
|
-
/**
|
|
145
|
-
* Add *distance* sharps/flats to given key
|
|
146
|
-
*/
|
|
147
|
-
static addFlats(smoPitch: Pitch, distance: number): Pitch;
|
|
148
|
-
/**
|
|
149
|
-
* Convert array of smo pitches to vex keys, with adjustment for transpose and notehead
|
|
150
|
-
* @param pitchAr
|
|
151
|
-
* @param keyOffset
|
|
152
|
-
* @param noteHead
|
|
153
|
-
* @returns {string[]} - array of vex keyx
|
|
154
|
-
*/
|
|
155
|
-
static smoPitchesToVexKeys(pitchAr: Pitch[], keyOffset: number, noteHead: string | null): string[];
|
|
156
|
-
static get scaleIntervals(): Record<string, number[]>;
|
|
157
|
-
/**
|
|
158
|
-
* return true if the pitches match, except for octave.
|
|
159
|
-
* `{ letter: 'a', accidental: '#'}, { letter: 'a', accidental: '#'}` returns true
|
|
160
|
-
* `{ letter: 'a', accidental: '#'}, { letter: 'b', accidental: 'b'}` returns false
|
|
161
|
-
* */
|
|
162
|
-
static smoScalePitchMatch(p1: Pitch, p2: Pitch): boolean;
|
|
163
|
-
/**
|
|
164
|
-
* Return the number of ledger lines, or 0 if none. positive if
|
|
165
|
-
* below the staff, negative if above
|
|
166
|
-
* @param clef
|
|
167
|
-
* @param pitch
|
|
168
|
-
* @returns number where 0 is the top staff line
|
|
169
|
-
*/
|
|
170
|
-
static pitchToLedgerLine(clef: Clef, pitch: Pitch): number;
|
|
171
|
-
/**
|
|
172
|
-
* return flag state (up === 1 or down === 2) based on pitch and clef if auto
|
|
173
|
-
* */
|
|
174
|
-
static flagStateFromNote(clef: Clef, note: SmoNote): number;
|
|
175
|
-
/**
|
|
176
|
-
* an array of clefs and the xml information they map to
|
|
177
|
-
*/
|
|
178
|
-
static clefSigns: Record<string, ClefSign>;
|
|
179
|
-
/**
|
|
180
|
-
* an array of clefs and the xml information they map to
|
|
181
|
-
*/
|
|
182
|
-
static clefLedgerShift: Record<string, number>;
|
|
183
|
-
static scaleTones: string[];
|
|
184
|
-
static getScaleTonesForKey(keySignature: string): Record<string, string>;
|
|
185
|
-
/**
|
|
186
|
-
* The purpose of this table is to keep consistent enharmonic spelling when transposing
|
|
187
|
-
* instruments in different keys. It is not theoritically complete, e.g.
|
|
188
|
-
* there is no reason to distinguish between #5 used as a leading tone for vi- or
|
|
189
|
-
* as an augmented chord, the spelling is the same. It does not show a preference
|
|
190
|
-
* for notes that don't have an obvious purpose in the key, e.g. it does not try to compute the
|
|
191
|
-
* equivalent to 'e#' in the key of 'c'. The computation of the 'intended key area' is
|
|
192
|
-
* beyond the scope of a music program to interpret.
|
|
193
|
-
*/
|
|
194
|
-
static get enharmonicRoles(): Record<string, KeySignatureRole[]>;
|
|
195
|
-
/**
|
|
196
|
-
* Find the harmonic role for the given pitch
|
|
197
|
-
* @param smoPitch
|
|
198
|
-
* @param keySignature
|
|
199
|
-
* @returns
|
|
200
|
-
*/
|
|
201
|
-
static findRoleOfPitch(smoPitch: Pitch, keySignature: string): string;
|
|
202
|
-
/**
|
|
203
|
-
* Given a harmonic role, find the pitch that matches it. If there is no one, just
|
|
204
|
-
* return the raw transposition
|
|
205
|
-
* @param role
|
|
206
|
-
* @param keySignature
|
|
207
|
-
* @param transposedPitch
|
|
208
|
-
* @returns
|
|
209
|
-
*/
|
|
210
|
-
static findPitchForRole(role: string, keySignature: string, transposedPitch: Pitch): Pitch;
|
|
211
|
-
static rawTranspose(pitch: Pitch, offset: number): Pitch;
|
|
212
|
-
static transposePitchForKey(pitch: Pitch, originalKey: string, destinationKey: string, offset: number): Pitch;
|
|
213
|
-
/**
|
|
214
|
-
* convert from SMO to VEX format so we can use the VexFlow tables and methods
|
|
215
|
-
* example:
|
|
216
|
-
* `{letter,octave,accidental}` object to vexKey string `'f#'`
|
|
217
|
-
* */
|
|
218
|
-
static _pitchToVexKey(smoPitch: Pitch): string;
|
|
219
|
-
/**
|
|
220
|
-
* convert smo pitch to easy score (vex) format. Mostly used
|
|
221
|
-
* for debugging and generating Vex test cases
|
|
222
|
-
* @param smoPitch
|
|
223
|
-
* @returns - a string that can be converted to a VEX routine, with some difficulty
|
|
224
|
-
*/
|
|
225
|
-
static pitchToEasyScore(smoPitch: Pitch): string;
|
|
226
|
-
/**
|
|
227
|
-
* convert a pitch to a format expected by the MIDI writer
|
|
228
|
-
* @param smoPitch pitch to convert
|
|
229
|
-
* @returns pitch in MIDI string format.
|
|
230
|
-
*/
|
|
231
|
-
static smoPitchToMidiString(smoPitch: Pitch, offset: number): string;
|
|
232
|
-
static smoPitchesToMidiStrings(smoPitches: Pitch[], offset: number): string[];
|
|
233
|
-
/**
|
|
234
|
-
* filled in from the midi routines borrowed from
|
|
235
|
-
* // https://github.com/grimmdude/MidiWriterJS
|
|
236
|
-
* @param midiPitch pitch from MIDIwrite
|
|
237
|
-
* @returns SMO pitch
|
|
238
|
-
*/
|
|
239
|
-
static midiPitchToSmoPitch(midiPitch: string): Pitch;
|
|
240
|
-
static midiPitchToMidiNumber(midiPitch: string): number;
|
|
241
|
-
static midiNumberAndDetuneFromPitch(pitch: Pitch, xpose: number, microtone?: SmoMicrotone): {
|
|
242
|
-
midinumber: number;
|
|
243
|
-
detune: number;
|
|
244
|
-
frequency: number;
|
|
245
|
-
};
|
|
246
|
-
static midiNumberToMidiPitch(midiNumber: number): string;
|
|
247
|
-
static pitchToVexKey(smoPitch: Pitch, head?: string | null): string;
|
|
248
|
-
/**
|
|
249
|
-
* Turns vex pitch string into smo pitch, e.g.
|
|
250
|
-
* `cn/4 => {'c','n',4}`
|
|
251
|
-
* @param vexPitch
|
|
252
|
-
* @returns SmoPitch
|
|
253
|
-
* */
|
|
254
|
-
static vexToSmoPitch(vexPitch: string): Pitch;
|
|
255
|
-
/**
|
|
256
|
-
* Convert to smo pitch, without octave
|
|
257
|
-
* ``['f#'] => [{letter:'f',accidental:'#'}]``
|
|
258
|
-
* */
|
|
259
|
-
static vexToSmoKey(vexPitch: string): PitchKey;
|
|
260
|
-
static smoPitchesToVex(pitchAr: Pitch[]): string[];
|
|
261
|
-
/**
|
|
262
|
-
* @param vexKey - pitch in vex format
|
|
263
|
-
* @returns pitch in vex format, sans octave
|
|
264
|
-
*/
|
|
265
|
-
static stripVexOctave(vexKey: string): string;
|
|
266
|
-
/**
|
|
267
|
-
* compare pitches for frequency match
|
|
268
|
-
*/
|
|
269
|
-
static pitchArraysMatch(ar1: Pitch[], ar2: Pitch[]): boolean;
|
|
270
|
-
/**
|
|
271
|
-
* convert pitches to integer pitch representations
|
|
272
|
-
* by calling smoPitchToInt
|
|
273
|
-
* @param pitches Smo pitches
|
|
274
|
-
* @returns
|
|
275
|
-
*/
|
|
276
|
-
static smoPitchesToIntArray(pitches: Pitch[]): number[];
|
|
277
|
-
/**
|
|
278
|
-
* convert a pitch to an integer value, used for transpositions, intervals, etc.
|
|
279
|
-
* @param pitch
|
|
280
|
-
* @returns
|
|
281
|
-
*/
|
|
282
|
-
static smoPitchToInt(pitch: Pitch): number;
|
|
283
|
-
/**
|
|
284
|
-
* Convert a number to a SMO pitch
|
|
285
|
-
* @param intValue - number of 1/2 steps from `c0`
|
|
286
|
-
* @returns
|
|
287
|
-
*/
|
|
288
|
-
static smoIntToPitch(intValue: number): Pitch;
|
|
289
|
-
static pitchKeyToPitch(pk: PitchKey): Pitch;
|
|
290
|
-
/**
|
|
291
|
-
* Consider instrument transpose when setting key -
|
|
292
|
-
* e.g. Eb for Bb instruments is F. Note: return value is not
|
|
293
|
-
* a valid VEX key signature. Use vexKeySignatureTranspose for that.
|
|
294
|
-
*/
|
|
295
|
-
static vexKeySigWithOffset(vexKey: string, offset: number): string;
|
|
296
|
-
static _enharmonics: Record<string, string[]> | null;
|
|
297
|
-
/**
|
|
298
|
-
* return a map of enharmonics for choosing or cycling. notes are in vexKey form.
|
|
299
|
-
*/
|
|
300
|
-
static get enharmonics(): Record<string, string[]>;
|
|
301
|
-
/**
|
|
302
|
-
* Get enharmonic equivalent of given notes for cycle/choose
|
|
303
|
-
* @param vexKey
|
|
304
|
-
* @returns
|
|
305
|
-
*/
|
|
306
|
-
static getEnharmonics(vexKey: string): string[];
|
|
307
|
-
/**
|
|
308
|
-
* return the next note from the cycle in `getEnharmonics`
|
|
309
|
-
*/
|
|
310
|
-
static getEnharmonic(vexKey: string): string;
|
|
311
|
-
/**
|
|
312
|
-
* Return a pitch a diatonic step away from SmoPitch in vexKey
|
|
313
|
-
* @param smoPitch
|
|
314
|
-
* @param vexKey
|
|
315
|
-
* @param direction
|
|
316
|
-
* @returns
|
|
317
|
-
*/
|
|
318
|
-
static closestTonic(smoPitch: Pitch, vexKey: string, direction: number): Pitch;
|
|
319
|
-
static toValidKeySignature(vexKey: string): string;
|
|
320
|
-
/**
|
|
321
|
-
* When transposing, get the enharmonic that most closely fits the key
|
|
322
|
-
* `getEnharmonicInKey` returns an alternate to the given pitch, or the same pitch.
|
|
323
|
-
* `getKeyFriendlyEnharmonic` return a pitch for a given key, given the letter name only
|
|
324
|
-
* @param smoPitch
|
|
325
|
-
* @param keySignature
|
|
326
|
-
* @returns
|
|
327
|
-
*/
|
|
328
|
-
static getEnharmonicInKey(smoPitch: Pitch, keySignature: string): Pitch;
|
|
329
|
-
/**
|
|
330
|
-
* fix the enharmonic to match the key, if possible
|
|
331
|
-
* @example
|
|
332
|
-
* `getKeyFriendlyEnharmonic('b','eb'); => returns 'bb'
|
|
333
|
-
* return vex string
|
|
334
|
-
* `getEnharmonicInKey` returns an alternate to the given pitch, or the same pitch.
|
|
335
|
-
* `getKeyFriendlyEnharmonic` return a pitch for a given key, given the letter name only
|
|
336
|
-
*/
|
|
337
|
-
static getKeyFriendlyEnharmonic(letter: string, keySignature: string): string;
|
|
338
|
-
/**
|
|
339
|
-
// given a letter pitch (a,b,c etc.), and a key signature, return the actual note
|
|
340
|
-
// that you get without accidentals
|
|
341
|
-
// `SmoMusic.getKeySignatureKey('F','G'); // returns f#`
|
|
342
|
-
* @param letter
|
|
343
|
-
* @param keySignature
|
|
344
|
-
* @returns
|
|
345
|
-
*/
|
|
346
|
-
static getKeySignatureKey(letter: PitchLetter, keySignature: string): string;
|
|
347
|
-
static getAccidentalForKeySignature(smoPitch: Pitch, keySignature: string): string;
|
|
348
|
-
static isPitchInKeySignature(smoPitch: Pitch, keySignature: string): boolean;
|
|
349
|
-
static getIntervalInKey(pitch: Pitch, keySignature: string, interval: number): Pitch;
|
|
350
|
-
static getLetterNotePitch(prevPitch: Pitch, letter: PitchLetter, key: string): Pitch;
|
|
351
|
-
/**
|
|
352
|
-
* return the key signature, transposed a number of 1/2 steps in Vex key format
|
|
353
|
-
* @param key start key
|
|
354
|
-
* @param transposeIndex number of 1/2 steps
|
|
355
|
-
* @returns {string} - vex key
|
|
356
|
-
*/
|
|
357
|
-
static vexKeySignatureTranspose(key: string, transposeIndex: number): string;
|
|
358
|
-
static get frequencyMap(): Record<string, number>;
|
|
359
|
-
static get letterPitchIndex(): Record<PitchLetter, number>;
|
|
360
|
-
/**
|
|
361
|
-
* Indicate if a change from letter note 'one' to 'two' needs us to adjust the
|
|
362
|
-
* octave due to the `SmoMusic.letterPitchIndex` (b0 is higher than c0)
|
|
363
|
-
* */
|
|
364
|
-
static letterChangedOctave(one: PitchLetter, two: PitchLetter): number;
|
|
365
|
-
/**
|
|
366
|
-
* Transpose a `Pitch` `offset` 1/2 steps
|
|
367
|
-
* @param pitch
|
|
368
|
-
* @param offset
|
|
369
|
-
* @returns
|
|
370
|
-
*/
|
|
371
|
-
static getKeyOffset(pitch: Pitch, offset: number): Pitch;
|
|
372
|
-
static get keySignatureLength(): Record<string, number>;
|
|
373
|
-
static getSharpsInKeySignature(key: string): number;
|
|
374
|
-
static getFlatsInKeySignature(key: string): number;
|
|
375
|
-
static midiKeyToVexKey(midiKey: number): string;
|
|
376
|
-
static highestDuration: number;
|
|
377
|
-
static lowestDuration: number;
|
|
378
|
-
static durationsDescending: number[];
|
|
379
|
-
static durationsAscending: number[];
|
|
380
|
-
static ticksFromSmoDuration(duration: SimpleDuration): number;
|
|
381
|
-
static _validDurations: Record<number, SimpleDuration> | null;
|
|
382
|
-
static _validDurationKeys: number[];
|
|
383
|
-
static get validDurations(): Record<number, SimpleDuration>;
|
|
384
|
-
/**
|
|
385
|
-
* Get the closest valid duration for this number of ticks, but not going over
|
|
386
|
-
* @param ticks
|
|
387
|
-
* @returns
|
|
388
|
-
*/
|
|
389
|
-
static closestSmoDurationFromTicks(ticks: number): SimpleDuration | null;
|
|
390
|
-
static closestSimpleDurationFromTicks(ticks: number): number;
|
|
391
|
-
static _ticksToDuration: Record<string, string>;
|
|
392
|
-
static get ticksToDuration(): Record<string, string>;
|
|
393
|
-
static timeSignatureToTicks(timeSignature: string): number;
|
|
394
|
-
static smoTicksToVexDots(ticks: number): number;
|
|
395
|
-
static midiTicksForQuantizeTo(ticks: number): number[];
|
|
396
|
-
static get midiTicksForQuantizeMap(): Record<number, number[]>;
|
|
397
|
-
static midiTicksForQuantize(ticks: number): number[];
|
|
398
|
-
static binarySearch(target: number, ix: number, partition: number, input: number[]): {
|
|
399
|
-
cost: number;
|
|
400
|
-
result: number;
|
|
401
|
-
newIx: number;
|
|
402
|
-
oldIx: number;
|
|
403
|
-
partition: number;
|
|
404
|
-
input: number[];
|
|
405
|
-
} | {
|
|
406
|
-
cost: number;
|
|
407
|
-
result: number;
|
|
408
|
-
newIx: number;
|
|
409
|
-
partition: number;
|
|
410
|
-
input: number[];
|
|
411
|
-
oldIx?: undefined;
|
|
412
|
-
};
|
|
413
|
-
static midiTickSearch(target: number, quantize: number): {
|
|
414
|
-
cost: number;
|
|
415
|
-
result: number;
|
|
416
|
-
};
|
|
417
|
-
static closestVexDuration(ticks: number): string;
|
|
418
|
-
static closestBeamDuration(ticks: number): SimpleDuration;
|
|
419
|
-
static closestDurationTickLtEq(ticks: number): number;
|
|
420
|
-
/**
|
|
421
|
-
* Return array of valid note-lengths from an odd number of ticks,
|
|
422
|
-
* so we can come as close as possible to representing the ticks with notes
|
|
423
|
-
* @param ticks
|
|
424
|
-
* @returns
|
|
425
|
-
*/
|
|
426
|
-
static splitIntoValidDurations(ticks: number): number[];
|
|
427
|
-
static vexStemType(ticks: number): string;
|
|
428
|
-
static getNextDottedLevel(ticks: number): number;
|
|
429
|
-
static getPreviousDottedLevel(ticks: number): number;
|
|
430
|
-
/**
|
|
431
|
-
* break the duration up into an array of durations, to split a long
|
|
432
|
-
* note up between bars when pasting.
|
|
433
|
-
* @param duration
|
|
434
|
-
* @returns
|
|
435
|
-
*/
|
|
436
|
-
static gcdMap(duration: number): number[];
|
|
437
|
-
static notesFromLetters(startPitch: Pitch, clef: Clef, keySignature: string, duration: number, letters: string): SmoNote[];
|
|
438
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* shared music theory and audio frequency routines, helper functions etc.
|
|
3
|
+
* @module /smo/data/music
|
|
4
|
+
*/
|
|
5
|
+
import { SmoNote } from './note';
|
|
6
|
+
import { Pitch, PitchKey, Clef, PitchLetter, AccidentalArray, AccidentalDisplay } from './common';
|
|
7
|
+
import { SmoMicrotone } from './noteModifiers';
|
|
8
|
+
/**
|
|
9
|
+
* Used for xml clef conversion
|
|
10
|
+
* @category SmoObject
|
|
11
|
+
*/
|
|
12
|
+
export interface ClefSign {
|
|
13
|
+
sign: string;
|
|
14
|
+
line?: number;
|
|
15
|
+
octave?: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* calculate the pitch frequency, just temperment a=440, etc.
|
|
19
|
+
* @category SmoTransform
|
|
20
|
+
*/
|
|
21
|
+
export declare class SmoAudioPitch {
|
|
22
|
+
static _computeFrequencies(): Record<string, number>;
|
|
23
|
+
static frequencies: Record<string, number> | null;
|
|
24
|
+
static frequencyKeys: string[] | null;
|
|
25
|
+
static get pitchFrequencyKeys(): string[];
|
|
26
|
+
static get pitchFrequencyMap(): Record<string, number>;
|
|
27
|
+
static frequencyToVexPitch(freq: number): string;
|
|
28
|
+
static _rawPitchToFrequency(smoPitch: Pitch, offset: number): number;
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
* @param smoPitch - pitch from the SMO object
|
|
32
|
+
* @param offset - transpose 1/2 steps, 0 means no transpose
|
|
33
|
+
* @param tone - optional transpose microtone
|
|
34
|
+
* @returns
|
|
35
|
+
*/
|
|
36
|
+
static smoPitchToFrequency(smoPitch: Pitch, offset: number, tone: SmoMicrotone | null): number;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* interface for valid non-tuplet duration value (all the
|
|
40
|
+
* base note lengths + dots)
|
|
41
|
+
* @category SmoTransform
|
|
42
|
+
*/
|
|
43
|
+
export interface SimpleDuration {
|
|
44
|
+
index: number;
|
|
45
|
+
ticks: number;
|
|
46
|
+
baseTicks: number;
|
|
47
|
+
dots: number;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* description of a scale entry, from vex theory routines
|
|
51
|
+
* @category SmoTransform
|
|
52
|
+
*/
|
|
53
|
+
export interface VexNoteValue {
|
|
54
|
+
root_index: number;
|
|
55
|
+
int_val: number;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Describe the music theory role of an accidental vs. the key signature.
|
|
59
|
+
* Used to determine default enharmonic spelling.
|
|
60
|
+
* @category SmoTransform
|
|
61
|
+
*/
|
|
62
|
+
export interface KeySignatureRole {
|
|
63
|
+
letter: PitchLetter;
|
|
64
|
+
accidental: string;
|
|
65
|
+
role: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Helper functions that build on the VX music theory routines, and other
|
|
69
|
+
* utilities I wish were in VF.Music but aren't
|
|
70
|
+
* ## Note on pitch and duration format
|
|
71
|
+
* We use some VEX music theory routines and frequently need to convert
|
|
72
|
+
* formats from SMO format. We also use the same 'ticks' abstraction for
|
|
73
|
+
* durations.
|
|
74
|
+
*
|
|
75
|
+
* `Smo` uses pitch JSON:
|
|
76
|
+
* ```javascript
|
|
77
|
+
* {note:'c',accidental:'#',octave:4}
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* `Vex` usually uses a canonical string:
|
|
81
|
+
*
|
|
82
|
+
* `'c#/4'`
|
|
83
|
+
*
|
|
84
|
+
* Depending on the operation, the octave might be omitted
|
|
85
|
+
*
|
|
86
|
+
* `Smo` uses a JSON for duration always:
|
|
87
|
+
* ```javascript
|
|
88
|
+
* {numerator:4096,denominator:1,remainder:0}
|
|
89
|
+
* ```
|
|
90
|
+
* `Vex` uses a letter duration (`'4'` or `'q'`for 1/4 note) and `'d'` for dot.
|
|
91
|
+
*
|
|
92
|
+
* I try to indicate whether I am using vex or smo notation in the function name.
|
|
93
|
+
* Duration methods start around line 1100
|
|
94
|
+
* @category SmoTransform
|
|
95
|
+
*/
|
|
96
|
+
export declare class SmoMusic {
|
|
97
|
+
/**
|
|
98
|
+
*Normalized gain from dynamics
|
|
99
|
+
*/
|
|
100
|
+
static get dynamicVolumeMap(): Record<string, number>;
|
|
101
|
+
/**
|
|
102
|
+
* Ported from vex, used to convert pitches to numerical values
|
|
103
|
+
* */
|
|
104
|
+
static get noteValues(): Record<string, VexNoteValue>;
|
|
105
|
+
static accidentalDisplay(pitch: Pitch, keySignature: string, duration: number, accArray: AccidentalArray[]): AccidentalDisplay | null;
|
|
106
|
+
/**
|
|
107
|
+
* return Vex canonical note enharmonic - e.g. Bb to A#
|
|
108
|
+
* */
|
|
109
|
+
static vexToCannonical(vexKey: string): string;
|
|
110
|
+
/**
|
|
111
|
+
* A note array (sans octave) in key-signature order
|
|
112
|
+
*/
|
|
113
|
+
static get circleOfFifths(): PitchKey[];
|
|
114
|
+
/**
|
|
115
|
+
* Return the number of lines above first ledger line below the staff.
|
|
116
|
+
* e.g. middle c in treble clef returns 0. Top line f in treble returns 5.
|
|
117
|
+
* @param clef
|
|
118
|
+
* @param pitch
|
|
119
|
+
* @returns number where 0 is the first ledger line below
|
|
120
|
+
*/
|
|
121
|
+
static pitchToStaffLine(clef: string, smoPitch: Pitch): number;
|
|
122
|
+
/**
|
|
123
|
+
* return above if the first pitch is above line 3, else below
|
|
124
|
+
* @param note
|
|
125
|
+
* @returns
|
|
126
|
+
*/
|
|
127
|
+
static positionFromStaffLine(note: SmoNote): "above" | "below";
|
|
128
|
+
/**
|
|
129
|
+
* gives the index into circle-of-fifths array for a pitch, considering enharmonics.
|
|
130
|
+
* */
|
|
131
|
+
static circleOfFifthsIndex(smoPitch: Pitch): number;
|
|
132
|
+
/**
|
|
133
|
+
* Get pitch to the right in circle of fifths
|
|
134
|
+
* */
|
|
135
|
+
static addSharp(smoPitch: Pitch): Pitch;
|
|
136
|
+
/**
|
|
137
|
+
* Get pitch to the left in circle of fifths
|
|
138
|
+
*/
|
|
139
|
+
static addFlat(smoPitch: Pitch): Pitch;
|
|
140
|
+
/**
|
|
141
|
+
* Add @param {number} - sharps
|
|
142
|
+
*/
|
|
143
|
+
static addSharps(smoPitch: Pitch, distance: number): Pitch;
|
|
144
|
+
/**
|
|
145
|
+
* Add *distance* sharps/flats to given key
|
|
146
|
+
*/
|
|
147
|
+
static addFlats(smoPitch: Pitch, distance: number): Pitch;
|
|
148
|
+
/**
|
|
149
|
+
* Convert array of smo pitches to vex keys, with adjustment for transpose and notehead
|
|
150
|
+
* @param pitchAr
|
|
151
|
+
* @param keyOffset
|
|
152
|
+
* @param noteHead
|
|
153
|
+
* @returns {string[]} - array of vex keyx
|
|
154
|
+
*/
|
|
155
|
+
static smoPitchesToVexKeys(pitchAr: Pitch[], keyOffset: number, noteHead: string | null): string[];
|
|
156
|
+
static get scaleIntervals(): Record<string, number[]>;
|
|
157
|
+
/**
|
|
158
|
+
* return true if the pitches match, except for octave.
|
|
159
|
+
* `{ letter: 'a', accidental: '#'}, { letter: 'a', accidental: '#'}` returns true
|
|
160
|
+
* `{ letter: 'a', accidental: '#'}, { letter: 'b', accidental: 'b'}` returns false
|
|
161
|
+
* */
|
|
162
|
+
static smoScalePitchMatch(p1: Pitch, p2: Pitch): boolean;
|
|
163
|
+
/**
|
|
164
|
+
* Return the number of ledger lines, or 0 if none. positive if
|
|
165
|
+
* below the staff, negative if above
|
|
166
|
+
* @param clef
|
|
167
|
+
* @param pitch
|
|
168
|
+
* @returns number where 0 is the top staff line
|
|
169
|
+
*/
|
|
170
|
+
static pitchToLedgerLine(clef: Clef, pitch: Pitch): number;
|
|
171
|
+
/**
|
|
172
|
+
* return flag state (up === 1 or down === 2) based on pitch and clef if auto
|
|
173
|
+
* */
|
|
174
|
+
static flagStateFromNote(clef: Clef, note: SmoNote): number;
|
|
175
|
+
/**
|
|
176
|
+
* an array of clefs and the xml information they map to
|
|
177
|
+
*/
|
|
178
|
+
static clefSigns: Record<string, ClefSign>;
|
|
179
|
+
/**
|
|
180
|
+
* an array of clefs and the xml information they map to
|
|
181
|
+
*/
|
|
182
|
+
static clefLedgerShift: Record<string, number>;
|
|
183
|
+
static scaleTones: string[];
|
|
184
|
+
static getScaleTonesForKey(keySignature: string): Record<string, string>;
|
|
185
|
+
/**
|
|
186
|
+
* The purpose of this table is to keep consistent enharmonic spelling when transposing
|
|
187
|
+
* instruments in different keys. It is not theoritically complete, e.g.
|
|
188
|
+
* there is no reason to distinguish between #5 used as a leading tone for vi- or
|
|
189
|
+
* as an augmented chord, the spelling is the same. It does not show a preference
|
|
190
|
+
* for notes that don't have an obvious purpose in the key, e.g. it does not try to compute the
|
|
191
|
+
* equivalent to 'e#' in the key of 'c'. The computation of the 'intended key area' is
|
|
192
|
+
* beyond the scope of a music program to interpret.
|
|
193
|
+
*/
|
|
194
|
+
static get enharmonicRoles(): Record<string, KeySignatureRole[]>;
|
|
195
|
+
/**
|
|
196
|
+
* Find the harmonic role for the given pitch
|
|
197
|
+
* @param smoPitch
|
|
198
|
+
* @param keySignature
|
|
199
|
+
* @returns
|
|
200
|
+
*/
|
|
201
|
+
static findRoleOfPitch(smoPitch: Pitch, keySignature: string): string;
|
|
202
|
+
/**
|
|
203
|
+
* Given a harmonic role, find the pitch that matches it. If there is no one, just
|
|
204
|
+
* return the raw transposition
|
|
205
|
+
* @param role
|
|
206
|
+
* @param keySignature
|
|
207
|
+
* @param transposedPitch
|
|
208
|
+
* @returns
|
|
209
|
+
*/
|
|
210
|
+
static findPitchForRole(role: string, keySignature: string, transposedPitch: Pitch): Pitch;
|
|
211
|
+
static rawTranspose(pitch: Pitch, offset: number): Pitch;
|
|
212
|
+
static transposePitchForKey(pitch: Pitch, originalKey: string, destinationKey: string, offset: number): Pitch;
|
|
213
|
+
/**
|
|
214
|
+
* convert from SMO to VEX format so we can use the VexFlow tables and methods
|
|
215
|
+
* example:
|
|
216
|
+
* `{letter,octave,accidental}` object to vexKey string `'f#'`
|
|
217
|
+
* */
|
|
218
|
+
static _pitchToVexKey(smoPitch: Pitch): string;
|
|
219
|
+
/**
|
|
220
|
+
* convert smo pitch to easy score (vex) format. Mostly used
|
|
221
|
+
* for debugging and generating Vex test cases
|
|
222
|
+
* @param smoPitch
|
|
223
|
+
* @returns - a string that can be converted to a VEX routine, with some difficulty
|
|
224
|
+
*/
|
|
225
|
+
static pitchToEasyScore(smoPitch: Pitch): string;
|
|
226
|
+
/**
|
|
227
|
+
* convert a pitch to a format expected by the MIDI writer
|
|
228
|
+
* @param smoPitch pitch to convert
|
|
229
|
+
* @returns pitch in MIDI string format.
|
|
230
|
+
*/
|
|
231
|
+
static smoPitchToMidiString(smoPitch: Pitch, offset: number): string;
|
|
232
|
+
static smoPitchesToMidiStrings(smoPitches: Pitch[], offset: number): string[];
|
|
233
|
+
/**
|
|
234
|
+
* filled in from the midi routines borrowed from
|
|
235
|
+
* // https://github.com/grimmdude/MidiWriterJS
|
|
236
|
+
* @param midiPitch pitch from MIDIwrite
|
|
237
|
+
* @returns SMO pitch
|
|
238
|
+
*/
|
|
239
|
+
static midiPitchToSmoPitch(midiPitch: string): Pitch;
|
|
240
|
+
static midiPitchToMidiNumber(midiPitch: string): number;
|
|
241
|
+
static midiNumberAndDetuneFromPitch(pitch: Pitch, xpose: number, microtone?: SmoMicrotone): {
|
|
242
|
+
midinumber: number;
|
|
243
|
+
detune: number;
|
|
244
|
+
frequency: number;
|
|
245
|
+
};
|
|
246
|
+
static midiNumberToMidiPitch(midiNumber: number): string;
|
|
247
|
+
static pitchToVexKey(smoPitch: Pitch, head?: string | null): string;
|
|
248
|
+
/**
|
|
249
|
+
* Turns vex pitch string into smo pitch, e.g.
|
|
250
|
+
* `cn/4 => {'c','n',4}`
|
|
251
|
+
* @param vexPitch
|
|
252
|
+
* @returns SmoPitch
|
|
253
|
+
* */
|
|
254
|
+
static vexToSmoPitch(vexPitch: string): Pitch;
|
|
255
|
+
/**
|
|
256
|
+
* Convert to smo pitch, without octave
|
|
257
|
+
* ``['f#'] => [{letter:'f',accidental:'#'}]``
|
|
258
|
+
* */
|
|
259
|
+
static vexToSmoKey(vexPitch: string): PitchKey;
|
|
260
|
+
static smoPitchesToVex(pitchAr: Pitch[]): string[];
|
|
261
|
+
/**
|
|
262
|
+
* @param vexKey - pitch in vex format
|
|
263
|
+
* @returns pitch in vex format, sans octave
|
|
264
|
+
*/
|
|
265
|
+
static stripVexOctave(vexKey: string): string;
|
|
266
|
+
/**
|
|
267
|
+
* compare pitches for frequency match
|
|
268
|
+
*/
|
|
269
|
+
static pitchArraysMatch(ar1: Pitch[], ar2: Pitch[]): boolean;
|
|
270
|
+
/**
|
|
271
|
+
* convert pitches to integer pitch representations
|
|
272
|
+
* by calling smoPitchToInt
|
|
273
|
+
* @param pitches Smo pitches
|
|
274
|
+
* @returns
|
|
275
|
+
*/
|
|
276
|
+
static smoPitchesToIntArray(pitches: Pitch[]): number[];
|
|
277
|
+
/**
|
|
278
|
+
* convert a pitch to an integer value, used for transpositions, intervals, etc.
|
|
279
|
+
* @param pitch
|
|
280
|
+
* @returns
|
|
281
|
+
*/
|
|
282
|
+
static smoPitchToInt(pitch: Pitch): number;
|
|
283
|
+
/**
|
|
284
|
+
* Convert a number to a SMO pitch
|
|
285
|
+
* @param intValue - number of 1/2 steps from `c0`
|
|
286
|
+
* @returns
|
|
287
|
+
*/
|
|
288
|
+
static smoIntToPitch(intValue: number): Pitch;
|
|
289
|
+
static pitchKeyToPitch(pk: PitchKey): Pitch;
|
|
290
|
+
/**
|
|
291
|
+
* Consider instrument transpose when setting key -
|
|
292
|
+
* e.g. Eb for Bb instruments is F. Note: return value is not
|
|
293
|
+
* a valid VEX key signature. Use vexKeySignatureTranspose for that.
|
|
294
|
+
*/
|
|
295
|
+
static vexKeySigWithOffset(vexKey: string, offset: number): string;
|
|
296
|
+
static _enharmonics: Record<string, string[]> | null;
|
|
297
|
+
/**
|
|
298
|
+
* return a map of enharmonics for choosing or cycling. notes are in vexKey form.
|
|
299
|
+
*/
|
|
300
|
+
static get enharmonics(): Record<string, string[]>;
|
|
301
|
+
/**
|
|
302
|
+
* Get enharmonic equivalent of given notes for cycle/choose
|
|
303
|
+
* @param vexKey
|
|
304
|
+
* @returns
|
|
305
|
+
*/
|
|
306
|
+
static getEnharmonics(vexKey: string): string[];
|
|
307
|
+
/**
|
|
308
|
+
* return the next note from the cycle in `getEnharmonics`
|
|
309
|
+
*/
|
|
310
|
+
static getEnharmonic(vexKey: string): string;
|
|
311
|
+
/**
|
|
312
|
+
* Return a pitch a diatonic step away from SmoPitch in vexKey
|
|
313
|
+
* @param smoPitch
|
|
314
|
+
* @param vexKey
|
|
315
|
+
* @param direction
|
|
316
|
+
* @returns
|
|
317
|
+
*/
|
|
318
|
+
static closestTonic(smoPitch: Pitch, vexKey: string, direction: number): Pitch;
|
|
319
|
+
static toValidKeySignature(vexKey: string): string;
|
|
320
|
+
/**
|
|
321
|
+
* When transposing, get the enharmonic that most closely fits the key
|
|
322
|
+
* `getEnharmonicInKey` returns an alternate to the given pitch, or the same pitch.
|
|
323
|
+
* `getKeyFriendlyEnharmonic` return a pitch for a given key, given the letter name only
|
|
324
|
+
* @param smoPitch
|
|
325
|
+
* @param keySignature
|
|
326
|
+
* @returns
|
|
327
|
+
*/
|
|
328
|
+
static getEnharmonicInKey(smoPitch: Pitch, keySignature: string): Pitch;
|
|
329
|
+
/**
|
|
330
|
+
* fix the enharmonic to match the key, if possible
|
|
331
|
+
* @example
|
|
332
|
+
* `getKeyFriendlyEnharmonic('b','eb'); => returns 'bb'
|
|
333
|
+
* return vex string
|
|
334
|
+
* `getEnharmonicInKey` returns an alternate to the given pitch, or the same pitch.
|
|
335
|
+
* `getKeyFriendlyEnharmonic` return a pitch for a given key, given the letter name only
|
|
336
|
+
*/
|
|
337
|
+
static getKeyFriendlyEnharmonic(letter: string, keySignature: string): string;
|
|
338
|
+
/**
|
|
339
|
+
// given a letter pitch (a,b,c etc.), and a key signature, return the actual note
|
|
340
|
+
// that you get without accidentals
|
|
341
|
+
// `SmoMusic.getKeySignatureKey('F','G'); // returns f#`
|
|
342
|
+
* @param letter
|
|
343
|
+
* @param keySignature
|
|
344
|
+
* @returns
|
|
345
|
+
*/
|
|
346
|
+
static getKeySignatureKey(letter: PitchLetter, keySignature: string): string;
|
|
347
|
+
static getAccidentalForKeySignature(smoPitch: Pitch, keySignature: string): string;
|
|
348
|
+
static isPitchInKeySignature(smoPitch: Pitch, keySignature: string): boolean;
|
|
349
|
+
static getIntervalInKey(pitch: Pitch, keySignature: string, interval: number): Pitch;
|
|
350
|
+
static getLetterNotePitch(prevPitch: Pitch, letter: PitchLetter, key: string): Pitch;
|
|
351
|
+
/**
|
|
352
|
+
* return the key signature, transposed a number of 1/2 steps in Vex key format
|
|
353
|
+
* @param key start key
|
|
354
|
+
* @param transposeIndex number of 1/2 steps
|
|
355
|
+
* @returns {string} - vex key
|
|
356
|
+
*/
|
|
357
|
+
static vexKeySignatureTranspose(key: string, transposeIndex: number): string;
|
|
358
|
+
static get frequencyMap(): Record<string, number>;
|
|
359
|
+
static get letterPitchIndex(): Record<PitchLetter, number>;
|
|
360
|
+
/**
|
|
361
|
+
* Indicate if a change from letter note 'one' to 'two' needs us to adjust the
|
|
362
|
+
* octave due to the `SmoMusic.letterPitchIndex` (b0 is higher than c0)
|
|
363
|
+
* */
|
|
364
|
+
static letterChangedOctave(one: PitchLetter, two: PitchLetter): number;
|
|
365
|
+
/**
|
|
366
|
+
* Transpose a `Pitch` `offset` 1/2 steps
|
|
367
|
+
* @param pitch
|
|
368
|
+
* @param offset
|
|
369
|
+
* @returns
|
|
370
|
+
*/
|
|
371
|
+
static getKeyOffset(pitch: Pitch, offset: number): Pitch;
|
|
372
|
+
static get keySignatureLength(): Record<string, number>;
|
|
373
|
+
static getSharpsInKeySignature(key: string): number;
|
|
374
|
+
static getFlatsInKeySignature(key: string): number;
|
|
375
|
+
static midiKeyToVexKey(midiKey: number): string;
|
|
376
|
+
static highestDuration: number;
|
|
377
|
+
static lowestDuration: number;
|
|
378
|
+
static durationsDescending: number[];
|
|
379
|
+
static durationsAscending: number[];
|
|
380
|
+
static ticksFromSmoDuration(duration: SimpleDuration): number;
|
|
381
|
+
static _validDurations: Record<number, SimpleDuration> | null;
|
|
382
|
+
static _validDurationKeys: number[];
|
|
383
|
+
static get validDurations(): Record<number, SimpleDuration>;
|
|
384
|
+
/**
|
|
385
|
+
* Get the closest valid duration for this number of ticks, but not going over
|
|
386
|
+
* @param ticks
|
|
387
|
+
* @returns
|
|
388
|
+
*/
|
|
389
|
+
static closestSmoDurationFromTicks(ticks: number): SimpleDuration | null;
|
|
390
|
+
static closestSimpleDurationFromTicks(ticks: number): number;
|
|
391
|
+
static _ticksToDuration: Record<string, string>;
|
|
392
|
+
static get ticksToDuration(): Record<string, string>;
|
|
393
|
+
static timeSignatureToTicks(timeSignature: string): number;
|
|
394
|
+
static smoTicksToVexDots(ticks: number): number;
|
|
395
|
+
static midiTicksForQuantizeTo(ticks: number): number[];
|
|
396
|
+
static get midiTicksForQuantizeMap(): Record<number, number[]>;
|
|
397
|
+
static midiTicksForQuantize(ticks: number): number[];
|
|
398
|
+
static binarySearch(target: number, ix: number, partition: number, input: number[]): {
|
|
399
|
+
cost: number;
|
|
400
|
+
result: number;
|
|
401
|
+
newIx: number;
|
|
402
|
+
oldIx: number;
|
|
403
|
+
partition: number;
|
|
404
|
+
input: number[];
|
|
405
|
+
} | {
|
|
406
|
+
cost: number;
|
|
407
|
+
result: number;
|
|
408
|
+
newIx: number;
|
|
409
|
+
partition: number;
|
|
410
|
+
input: number[];
|
|
411
|
+
oldIx?: undefined;
|
|
412
|
+
};
|
|
413
|
+
static midiTickSearch(target: number, quantize: number): {
|
|
414
|
+
cost: number;
|
|
415
|
+
result: number;
|
|
416
|
+
};
|
|
417
|
+
static closestVexDuration(ticks: number): string;
|
|
418
|
+
static closestBeamDuration(ticks: number): SimpleDuration;
|
|
419
|
+
static closestDurationTickLtEq(ticks: number): number;
|
|
420
|
+
/**
|
|
421
|
+
* Return array of valid note-lengths from an odd number of ticks,
|
|
422
|
+
* so we can come as close as possible to representing the ticks with notes
|
|
423
|
+
* @param ticks
|
|
424
|
+
* @returns
|
|
425
|
+
*/
|
|
426
|
+
static splitIntoValidDurations(ticks: number): number[];
|
|
427
|
+
static vexStemType(ticks: number): string;
|
|
428
|
+
static getNextDottedLevel(ticks: number): number;
|
|
429
|
+
static getPreviousDottedLevel(ticks: number): number;
|
|
430
|
+
/**
|
|
431
|
+
* break the duration up into an array of durations, to split a long
|
|
432
|
+
* note up between bars when pasting.
|
|
433
|
+
* @param duration
|
|
434
|
+
* @returns
|
|
435
|
+
*/
|
|
436
|
+
static gcdMap(duration: number): number[];
|
|
437
|
+
static notesFromLetters(startPitch: Pitch, clef: Clef, keySignature: string, duration: number, letters: string): SmoNote[];
|
|
438
|
+
}
|