@musodojo/music-theory-data 26.5.0 → 27.0.0
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/README.md +52 -0
- package/esm/src/data/chromatic.d.ts +24 -0
- package/esm/src/data/chromatic.d.ts.map +1 -0
- package/esm/src/data/chromatic.js +15 -0
- package/esm/src/data/colors/mod.d.ts +37 -26
- package/esm/src/data/colors/mod.d.ts.map +1 -1
- package/esm/src/data/colors/mod.js +31 -5
- package/esm/src/data/labels/note-label-collections.d.ts +13 -25
- package/esm/src/data/labels/note-label-collections.d.ts.map +1 -1
- package/esm/src/data/labels/note-label-collections.js +10 -10
- package/esm/src/data/labels/note-labels.d.ts +2 -1
- package/esm/src/data/labels/note-labels.d.ts.map +1 -1
- package/esm/src/data/mod.d.ts +1 -0
- package/esm/src/data/mod.d.ts.map +1 -1
- package/esm/src/data/mod.js +1 -0
- package/esm/src/utils/chords.d.ts +1 -1
- package/esm/src/utils/chords.d.ts.map +1 -1
- package/esm/src/utils/chords.js +14 -9
- package/esm/src/utils/chromatic.d.ts +6 -0
- package/esm/src/utils/chromatic.d.ts.map +1 -0
- package/esm/src/utils/chromatic.js +24 -0
- package/esm/src/utils/colors.d.ts +5 -0
- package/esm/src/utils/colors.d.ts.map +1 -1
- package/esm/src/utils/colors.js +67 -32
- package/esm/src/utils/conversion-registry.d.ts +1 -1
- package/esm/src/utils/conversion-registry.d.ts.map +1 -1
- package/esm/src/utils/intervals.d.ts +34 -7
- package/esm/src/utils/intervals.d.ts.map +1 -1
- package/esm/src/utils/intervals.js +5 -55
- package/esm/src/utils/mod.d.ts +2 -0
- package/esm/src/utils/mod.d.ts.map +1 -1
- package/esm/src/utils/mod.js +2 -0
- package/esm/src/utils/note-colors.d.ts +10 -0
- package/esm/src/utils/note-colors.d.ts.map +1 -0
- package/esm/src/utils/note-colors.js +13 -0
- package/esm/src/utils/note-names.d.ts +7 -1
- package/esm/src/utils/note-names.d.ts.map +1 -1
- package/esm/src/utils/note-names.js +6 -24
- package/esm/src/utils/qualities.d.ts +10 -1
- package/esm/src/utils/qualities.d.ts.map +1 -1
- package/esm/src/utils/qualities.js +10 -27
- package/esm/tests/colors.test.d.ts.map +1 -0
- package/package.json +1 -1
- package/script/src/data/chromatic.d.ts +24 -0
- package/script/src/data/chromatic.d.ts.map +1 -0
- package/script/src/data/chromatic.js +18 -0
- package/script/src/data/colors/mod.d.ts +37 -26
- package/script/src/data/colors/mod.d.ts.map +1 -1
- package/script/src/data/colors/mod.js +35 -6
- package/script/src/data/labels/note-label-collections.d.ts +13 -25
- package/script/src/data/labels/note-label-collections.d.ts.map +1 -1
- package/script/src/data/labels/note-label-collections.js +10 -10
- package/script/src/data/labels/note-labels.d.ts +2 -1
- package/script/src/data/labels/note-labels.d.ts.map +1 -1
- package/script/src/data/mod.d.ts +1 -0
- package/script/src/data/mod.d.ts.map +1 -1
- package/script/src/data/mod.js +1 -0
- package/script/src/utils/chords.d.ts +1 -1
- package/script/src/utils/chords.d.ts.map +1 -1
- package/script/src/utils/chords.js +14 -9
- package/script/src/utils/chromatic.d.ts +6 -0
- package/script/src/utils/chromatic.d.ts.map +1 -0
- package/script/src/utils/chromatic.js +30 -0
- package/script/src/utils/colors.d.ts +5 -0
- package/script/src/utils/colors.d.ts.map +1 -1
- package/script/src/utils/colors.js +72 -32
- package/script/src/utils/conversion-registry.d.ts +1 -1
- package/script/src/utils/conversion-registry.d.ts.map +1 -1
- package/script/src/utils/intervals.d.ts +34 -7
- package/script/src/utils/intervals.d.ts.map +1 -1
- package/script/src/utils/intervals.js +5 -55
- package/script/src/utils/mod.d.ts +2 -0
- package/script/src/utils/mod.d.ts.map +1 -1
- package/script/src/utils/mod.js +2 -0
- package/script/src/utils/note-colors.d.ts +10 -0
- package/script/src/utils/note-colors.d.ts.map +1 -0
- package/script/src/utils/note-colors.js +18 -0
- package/script/src/utils/note-names.d.ts +7 -1
- package/script/src/utils/note-names.d.ts.map +1 -1
- package/script/src/utils/note-names.js +6 -24
- package/script/src/utils/qualities.d.ts +10 -1
- package/script/src/utils/qualities.d.ts.map +1 -1
- package/script/src/utils/qualities.js +10 -27
- package/script/tests/colors.test.d.ts.map +1 -0
package/README.md
CHANGED
|
@@ -194,6 +194,58 @@ console.log(
|
|
|
194
194
|
// ["CM", "FM", "GM"]
|
|
195
195
|
```
|
|
196
196
|
|
|
197
|
+
## Note Colors And Chromatic Indexes
|
|
198
|
+
|
|
199
|
+
Note color collections use 12 chromatic slots. In absolute mode, each index is a
|
|
200
|
+
pitch class where index `0` is C and index `7` is G. In relative mode, each
|
|
201
|
+
index is measured from a musical root where index `0` is the root and index `7`
|
|
202
|
+
is the fifth.
|
|
203
|
+
|
|
204
|
+
`noteLabelCollections.noteNamesFlat` is the default label set for absolute note
|
|
205
|
+
colors, and `noteLabelCollections.intervalsFlat` is the default label set for
|
|
206
|
+
relative note colors. `ChromaticIndex` is the shared `0`-to-`11` pitch-class
|
|
207
|
+
shape used by chromatic tuples, note labels, root-note integers, and filled
|
|
208
|
+
chromatic interval helpers. `ChromaticMode` is the shared `"absolute"` or
|
|
209
|
+
`"relative"` mode used by note colors and label collections.
|
|
210
|
+
|
|
211
|
+
Chromatic indexes must be integers. Helpers such as `normalizeChromaticIndex`
|
|
212
|
+
wrap negative or large semitone values into the `0`-to-`11` range, but reject
|
|
213
|
+
fractional or non-finite values.
|
|
214
|
+
|
|
215
|
+
```ts
|
|
216
|
+
import {
|
|
217
|
+
colorCollections,
|
|
218
|
+
getNoteColorIndex,
|
|
219
|
+
getNoteColorLabels,
|
|
220
|
+
} from "jsr:@musodojo/music-theory-data";
|
|
221
|
+
|
|
222
|
+
const absoluteIndex = getNoteColorIndex({
|
|
223
|
+
midi: 67,
|
|
224
|
+
mode: "absolute",
|
|
225
|
+
});
|
|
226
|
+
console.log(absoluteIndex);
|
|
227
|
+
// 7, the pitch class G
|
|
228
|
+
|
|
229
|
+
const relativeIndex = getNoteColorIndex({
|
|
230
|
+
midi: 69,
|
|
231
|
+
mode: "relative",
|
|
232
|
+
rootPitchClass: 2,
|
|
233
|
+
});
|
|
234
|
+
console.log(relativeIndex);
|
|
235
|
+
// 7, A as the fifth above D
|
|
236
|
+
|
|
237
|
+
console.log(getNoteColorLabels(colorCollections.musoDojoRootAndFifth));
|
|
238
|
+
// ["1", "♭2", "2", "♭3", "3", "4", "♭5", "5", "♭6", "6", "♭7", "7"]
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
Color values may be hex strings or `null`. A `null` value means there is
|
|
242
|
+
intentionally no semantic color for that pitch or degree; consuming apps should
|
|
243
|
+
choose their own visual fallback through theme or UI settings.
|
|
244
|
+
|
|
245
|
+
Regular note collection interval arrays remain variable length because chords,
|
|
246
|
+
dyads, arpeggios, and scales have different natural sizes. Helpers that opt into
|
|
247
|
+
`fillChromatic: true` return a fixed 12-slot chromatic tuple.
|
|
248
|
+
|
|
197
249
|
## API Documentation
|
|
198
250
|
|
|
199
251
|
For a full list of all available data, types, and utility functions, please see
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const CHROMATIC_NOTE_COUNT: 12;
|
|
2
|
+
/** A zero-indexed chromatic pitch-class or relative degree slot. */
|
|
3
|
+
export type ChromaticIndex = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11;
|
|
4
|
+
/** How a chromatic index should be interpreted. */
|
|
5
|
+
export type ChromaticMode = "absolute" | "relative";
|
|
6
|
+
/** A fixed 12-slot tuple indexed by chromatic pitch class or relative degree. */
|
|
7
|
+
export type ChromaticTuple<T> = readonly [
|
|
8
|
+
T,
|
|
9
|
+
T,
|
|
10
|
+
T,
|
|
11
|
+
T,
|
|
12
|
+
T,
|
|
13
|
+
T,
|
|
14
|
+
T,
|
|
15
|
+
T,
|
|
16
|
+
T,
|
|
17
|
+
T,
|
|
18
|
+
T,
|
|
19
|
+
T
|
|
20
|
+
];
|
|
21
|
+
export declare const CHROMATIC_INDEXES: ChromaticTuple<ChromaticIndex>;
|
|
22
|
+
/** A variable-length set of chromatic indexes, such as the pitch classes in a scale or dyad. */
|
|
23
|
+
export type ChromaticIndexSet = readonly ChromaticIndex[];
|
|
24
|
+
//# sourceMappingURL=chromatic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chromatic.d.ts","sourceRoot":"","sources":["../../../src/src/data/chromatic.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,EAAG,EAAW,CAAC;AAEhD,oEAAoE;AACpE,MAAM,MAAM,cAAc,GACtB,CAAC,GACD,CAAC,GACD,CAAC,GACD,CAAC,GACD,CAAC,GACD,CAAC,GACD,CAAC,GACD,CAAC,GACD,CAAC,GACD,CAAC,GACD,EAAE,GACF,EAAE,CAAC;AAEP,mDAAmD;AACnD,MAAM,MAAM,aAAa,GAAG,UAAU,GAAG,UAAU,CAAC;AAEpD,iFAAiF;AACjF,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,SAAS;IACvC,CAAC;IACD,CAAC;IACD,CAAC;IACD,CAAC;IACD,CAAC;IACD,CAAC;IACD,CAAC;IACD,CAAC;IACD,CAAC;IACD,CAAC;IACD,CAAC;IACD,CAAC;CACF,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,cAAc,CAAC,cAAc,CAanD,CAAC;AAEX,gGAAgG;AAChG,MAAM,MAAM,iBAAiB,GAAG,SAAS,cAAc,EAAE,CAAC"}
|
|
@@ -1,51 +1,62 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
Color,
|
|
14
|
-
Color
|
|
15
|
-
];
|
|
16
|
-
export interface ColorCollection {
|
|
17
|
-
name: string;
|
|
18
|
-
description: string;
|
|
19
|
-
relative: boolean;
|
|
20
|
-
colors: ColorGroup;
|
|
1
|
+
import { type NoteLabelCollectionKey, type NoteLabelGroup } from "../labels/note-label-collections.js";
|
|
2
|
+
import type { ChromaticMode, ChromaticTuple } from "../chromatic.js";
|
|
3
|
+
export type NoteColorMode = ChromaticMode;
|
|
4
|
+
export type NoteColorValue = string | null;
|
|
5
|
+
export type NoteColorTuple = ChromaticTuple<NoteColorValue>;
|
|
6
|
+
export interface NoteColorCollection {
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly shortName?: string;
|
|
9
|
+
readonly description: string;
|
|
10
|
+
readonly mode: NoteColorMode;
|
|
11
|
+
readonly labelCollectionKey?: NoteLabelCollectionKey;
|
|
12
|
+
readonly colors: NoteColorTuple;
|
|
21
13
|
}
|
|
14
|
+
export type Color = NoteColorValue;
|
|
15
|
+
export type ColorGroup = NoteColorTuple;
|
|
16
|
+
export type ColorCollection = NoteColorCollection;
|
|
17
|
+
export type DefaultNoteColorLabelCollectionKeys = Readonly<Record<NoteColorMode, NoteLabelCollectionKey>> & Readonly<{
|
|
18
|
+
absolute: "noteNamesFlat";
|
|
19
|
+
relative: "intervalsFlat";
|
|
20
|
+
}>;
|
|
21
|
+
export declare const defaultNoteColorLabelCollectionKeys: DefaultNoteColorLabelCollectionKeys;
|
|
22
|
+
export declare function getDefaultNoteColorLabelCollectionKey(mode: NoteColorMode): NoteLabelCollectionKey;
|
|
23
|
+
export declare function getNoteColorLabelCollectionKey(collection: NoteColorCollection): NoteLabelCollectionKey;
|
|
24
|
+
export declare function getNoteColorLabels(collection: NoteColorCollection): NoteLabelGroup;
|
|
22
25
|
declare const _colorCollections: {
|
|
23
26
|
readonly musoDojo: {
|
|
24
27
|
readonly name: "Muso Dojo Colors";
|
|
25
|
-
readonly
|
|
26
|
-
readonly
|
|
28
|
+
readonly shortName: "Muso Dojo";
|
|
29
|
+
readonly description: "A custom absolute chromatic palette designed by Muso Dojo.";
|
|
30
|
+
readonly mode: "absolute";
|
|
31
|
+
readonly labelCollectionKey: "noteNamesFlat";
|
|
27
32
|
readonly colors: readonly ["#ED2929", "#9F000F", "#78C7C7", "#00008B", "#FF9933", "#EBEB19", "#286704", "#99CC33", "#660099", "#CC00FF", "#BF6A1F", "#FF9EE6"];
|
|
28
33
|
};
|
|
29
34
|
readonly musoDojoRoot: {
|
|
30
35
|
readonly name: "Muso Dojo Root";
|
|
36
|
+
readonly shortName: "Root";
|
|
31
37
|
readonly description: "Use the red color from Muso Dojo's colors on just the root note.";
|
|
32
|
-
readonly
|
|
38
|
+
readonly mode: "relative";
|
|
39
|
+
readonly labelCollectionKey: "intervalsFlat";
|
|
33
40
|
readonly colors: readonly ["#ED2929", null, null, null, null, null, null, null, null, null, null, null];
|
|
34
41
|
};
|
|
35
42
|
readonly musoDojoRootAndFifth: {
|
|
36
43
|
readonly name: "Muso Dojo Root and Fifth";
|
|
44
|
+
readonly shortName: "Root and Fifth";
|
|
37
45
|
readonly description: "Use the red-and-green colors from Muso Dojo's colors on the root-and-fifth notes.";
|
|
38
|
-
readonly
|
|
46
|
+
readonly mode: "relative";
|
|
47
|
+
readonly labelCollectionKey: "intervalsFlat";
|
|
39
48
|
readonly colors: readonly ["#ED2929", null, null, null, null, null, null, "#99CC33", null, null, null, null];
|
|
40
49
|
};
|
|
41
50
|
readonly boomwhackers: {
|
|
42
51
|
readonly name: "Boomwhackers";
|
|
52
|
+
readonly shortName: "Boomwhackers";
|
|
43
53
|
readonly description: "The colors used by Boomwhackers.";
|
|
44
|
-
readonly
|
|
54
|
+
readonly mode: "absolute";
|
|
55
|
+
readonly labelCollectionKey: "noteNamesFlat";
|
|
45
56
|
readonly colors: readonly ["#E21C48", "#F26622", "#F99D1C", "#FFCC33", "#FFF32B", "#BCD85F", "#62BC47", "#009C95", "#0071BB", "#5E50A1", "#8D5BA6", "#CF3E96"];
|
|
46
57
|
};
|
|
47
58
|
};
|
|
48
59
|
export type ColorCollectionKey = keyof typeof _colorCollections;
|
|
49
|
-
export declare const colorCollections: Record<ColorCollectionKey,
|
|
60
|
+
export declare const colorCollections: Record<ColorCollectionKey, NoteColorCollection>;
|
|
50
61
|
export {};
|
|
51
62
|
//# sourceMappingURL=mod.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../../src/src/data/colors/mod.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../../src/src/data/colors/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,sBAAsB,EAE3B,KAAK,cAAc,EACpB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAErE,MAAM,MAAM,aAAa,GAAG,aAAa,CAAC;AAC1C,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,IAAI,CAAC;AAC3C,MAAM,MAAM,cAAc,GAAG,cAAc,CAAC,cAAc,CAAC,CAAC;AAE5D,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,kBAAkB,CAAC,EAAE,sBAAsB,CAAC;IACrD,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;CACjC;AAED,MAAM,MAAM,KAAK,GAAG,cAAc,CAAC;AACnC,MAAM,MAAM,UAAU,GAAG,cAAc,CAAC;AACxC,MAAM,MAAM,eAAe,GAAG,mBAAmB,CAAC;AAElD,MAAM,MAAM,mCAAmC,GAC3C,QAAQ,CAAC,MAAM,CAAC,aAAa,EAAE,sBAAsB,CAAC,CAAC,GACvD,QAAQ,CAAC;IACT,QAAQ,EAAE,eAAe,CAAC;IAC1B,QAAQ,EAAE,eAAe,CAAC;CAC3B,CAAC,CAAC;AAEL,eAAO,MAAM,mCAAmC,EAC9C,mCAGC,CAAC;AAEJ,wBAAgB,qCAAqC,CACnD,IAAI,EAAE,aAAa,GAClB,sBAAsB,CAExB;AAED,wBAAgB,8BAA8B,CAC5C,UAAU,EAAE,mBAAmB,GAC9B,sBAAsB,CAMxB;AAED,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,mBAAmB,GAC9B,cAAc,CAGhB;AAED,QAAA,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuFb,CAAC;AAEX,MAAM,MAAM,kBAAkB,GAAG,MAAM,OAAO,iBAAiB,CAAC;AAEhE,eAAO,MAAM,gBAAgB,EAAE,MAAM,CACnC,kBAAkB,EAClB,mBAAmB,CACA,CAAC"}
|
|
@@ -1,8 +1,28 @@
|
|
|
1
|
+
import { noteLabelCollections, } from "../labels/note-label-collections.js";
|
|
2
|
+
export const defaultNoteColorLabelCollectionKeys = {
|
|
3
|
+
absolute: "noteNamesFlat",
|
|
4
|
+
relative: "intervalsFlat",
|
|
5
|
+
};
|
|
6
|
+
export function getDefaultNoteColorLabelCollectionKey(mode) {
|
|
7
|
+
return defaultNoteColorLabelCollectionKeys[mode];
|
|
8
|
+
}
|
|
9
|
+
export function getNoteColorLabelCollectionKey(collection) {
|
|
10
|
+
if (collection.labelCollectionKey) {
|
|
11
|
+
return collection.labelCollectionKey;
|
|
12
|
+
}
|
|
13
|
+
return getDefaultNoteColorLabelCollectionKey(collection.mode);
|
|
14
|
+
}
|
|
15
|
+
export function getNoteColorLabels(collection) {
|
|
16
|
+
return noteLabelCollections[getNoteColorLabelCollectionKey(collection)]
|
|
17
|
+
.labels;
|
|
18
|
+
}
|
|
1
19
|
const _colorCollections = {
|
|
2
20
|
musoDojo: {
|
|
3
21
|
name: "Muso Dojo Colors",
|
|
4
|
-
|
|
5
|
-
|
|
22
|
+
shortName: "Muso Dojo",
|
|
23
|
+
description: "A custom absolute chromatic palette designed by Muso Dojo.",
|
|
24
|
+
mode: "absolute",
|
|
25
|
+
labelCollectionKey: "noteNamesFlat",
|
|
6
26
|
colors: [
|
|
7
27
|
"#ED2929",
|
|
8
28
|
"#9F000F",
|
|
@@ -20,8 +40,10 @@ const _colorCollections = {
|
|
|
20
40
|
},
|
|
21
41
|
musoDojoRoot: {
|
|
22
42
|
name: "Muso Dojo Root",
|
|
43
|
+
shortName: "Root",
|
|
23
44
|
description: "Use the red color from Muso Dojo's colors on just the root note.",
|
|
24
|
-
|
|
45
|
+
mode: "relative",
|
|
46
|
+
labelCollectionKey: "intervalsFlat",
|
|
25
47
|
colors: [
|
|
26
48
|
"#ED2929",
|
|
27
49
|
null,
|
|
@@ -39,8 +61,10 @@ const _colorCollections = {
|
|
|
39
61
|
},
|
|
40
62
|
musoDojoRootAndFifth: {
|
|
41
63
|
name: "Muso Dojo Root and Fifth",
|
|
64
|
+
shortName: "Root and Fifth",
|
|
42
65
|
description: "Use the red-and-green colors from Muso Dojo's colors on the root-and-fifth notes.",
|
|
43
|
-
|
|
66
|
+
mode: "relative",
|
|
67
|
+
labelCollectionKey: "intervalsFlat",
|
|
44
68
|
colors: [
|
|
45
69
|
"#ED2929",
|
|
46
70
|
null,
|
|
@@ -58,8 +82,10 @@ const _colorCollections = {
|
|
|
58
82
|
},
|
|
59
83
|
boomwhackers: {
|
|
60
84
|
name: "Boomwhackers",
|
|
85
|
+
shortName: "Boomwhackers",
|
|
61
86
|
description: "The colors used by Boomwhackers.",
|
|
62
|
-
|
|
87
|
+
mode: "absolute",
|
|
88
|
+
labelCollectionKey: "noteNamesFlat",
|
|
63
89
|
colors: [
|
|
64
90
|
"#E21C48",
|
|
65
91
|
"#F26622",
|
|
@@ -1,84 +1,72 @@
|
|
|
1
|
+
import type { ChromaticMode, ChromaticTuple } from "../chromatic.js";
|
|
1
2
|
/** A fixed 12-element tuple of strings representing each note in the chromatic scale. */
|
|
2
|
-
export type NoteLabelGroup =
|
|
3
|
-
string,
|
|
4
|
-
string,
|
|
5
|
-
string,
|
|
6
|
-
string,
|
|
7
|
-
string,
|
|
8
|
-
string,
|
|
9
|
-
string,
|
|
10
|
-
string,
|
|
11
|
-
string,
|
|
12
|
-
string,
|
|
13
|
-
string,
|
|
14
|
-
string
|
|
15
|
-
];
|
|
3
|
+
export type NoteLabelGroup = ChromaticTuple<string>;
|
|
16
4
|
/** The data interface governing an entire collection array of 12 note labels. */
|
|
17
5
|
export interface NoteLabelCollection {
|
|
18
6
|
readonly name: string;
|
|
19
7
|
readonly shortName: string;
|
|
20
|
-
readonly
|
|
8
|
+
readonly mode: ChromaticMode;
|
|
21
9
|
readonly labels: NoteLabelGroup;
|
|
22
10
|
}
|
|
23
11
|
declare const _noteLabelCollections: {
|
|
24
12
|
readonly noteNamesFlat: {
|
|
25
13
|
readonly name: "Flat Note Names";
|
|
26
14
|
readonly shortName: "Flat Notes";
|
|
27
|
-
readonly
|
|
15
|
+
readonly mode: "absolute";
|
|
28
16
|
readonly labels: readonly ["C", "D♭", "D", "E♭", "E", "F", "G♭", "G", "A♭", "A", "B♭", "B"];
|
|
29
17
|
};
|
|
30
18
|
readonly noteNamesSharp: {
|
|
31
19
|
readonly name: "Sharp Note Names";
|
|
32
20
|
readonly shortName: "Sharp Notes";
|
|
33
|
-
readonly
|
|
21
|
+
readonly mode: "absolute";
|
|
34
22
|
readonly labels: readonly ["C", "C♯", "D", "D♯", "E", "F", "F♯", "G", "G♯", "A", "A♯", "B"];
|
|
35
23
|
};
|
|
36
24
|
readonly intervalsFlat: {
|
|
37
25
|
readonly name: "Flat Note Intervals";
|
|
38
26
|
readonly shortName: "Flat Intervals";
|
|
39
|
-
readonly
|
|
27
|
+
readonly mode: "relative";
|
|
40
28
|
readonly labels: readonly ["1", "♭2", "2", "♭3", "3", "4", "♭5", "5", "♭6", "6", "♭7", "7"];
|
|
41
29
|
};
|
|
42
30
|
readonly intervalsSharp: {
|
|
43
31
|
readonly name: "Sharp Note Intervals";
|
|
44
32
|
readonly shortName: "Sharp Intervals";
|
|
45
|
-
readonly
|
|
33
|
+
readonly mode: "relative";
|
|
46
34
|
readonly labels: readonly ["1", "♯1", "2", "♯2", "3", "4", "♯4", "5", "♯5", "6", "♯6", "7"];
|
|
47
35
|
};
|
|
48
36
|
readonly extensionsFlat: {
|
|
49
37
|
readonly name: "Flat Note Extensions";
|
|
50
38
|
readonly shortName: "Flat Extensions";
|
|
51
|
-
readonly
|
|
39
|
+
readonly mode: "relative";
|
|
52
40
|
readonly labels: readonly ["1", "♭9", "9", "♭3", "3", "11", "♭5", "5", "♭13", "13", "♭7", "7"];
|
|
53
41
|
};
|
|
54
42
|
readonly extensionsSharp: {
|
|
55
43
|
readonly name: "Sharp Note Extensions";
|
|
56
44
|
readonly shortName: "Sharp Extensions";
|
|
57
|
-
readonly
|
|
45
|
+
readonly mode: "relative";
|
|
58
46
|
readonly labels: readonly ["1", "♯1", "9", "♯9", "3", "11", "♯11", "5", "♯5", "13", "♯13", "7"];
|
|
59
47
|
};
|
|
60
48
|
readonly fixedDoFlat: {
|
|
61
49
|
readonly name: "Solfege Fixed Do Flat Notes";
|
|
62
50
|
readonly shortName: "Fixed Do Flat";
|
|
63
|
-
readonly
|
|
51
|
+
readonly mode: "absolute";
|
|
64
52
|
readonly labels: readonly ["do", "re♭", "re", "mi♭", "mi", "fa", "sol♭", "sol", "la♭", "la", "si♭", "si"];
|
|
65
53
|
};
|
|
66
54
|
readonly fixedDoSharp: {
|
|
67
55
|
readonly name: "Solfege Fixed Do Sharp Notes";
|
|
68
56
|
readonly shortName: "Fixed Do Sharp";
|
|
69
|
-
readonly
|
|
57
|
+
readonly mode: "absolute";
|
|
70
58
|
readonly labels: readonly ["do", "do♯", "re", "re♯", "mi", "fa", "fa♯", "sol", "sol♯", "la", "la♯", "si"];
|
|
71
59
|
};
|
|
72
60
|
readonly movableDo: {
|
|
73
61
|
readonly name: "Solfege Movable Do Notes";
|
|
74
62
|
readonly shortName: "Movable Do";
|
|
75
|
-
readonly
|
|
63
|
+
readonly mode: "relative";
|
|
76
64
|
readonly labels: readonly ["do", "ra", "re", "me", "mi", "fa", "fi", "sol", "le", "la", "te", "ti"];
|
|
77
65
|
};
|
|
78
66
|
readonly movableLa: {
|
|
79
67
|
readonly name: "Solfege Movable La Notes";
|
|
80
68
|
readonly shortName: "Movable La";
|
|
81
|
-
readonly
|
|
69
|
+
readonly mode: "relative";
|
|
82
70
|
readonly labels: readonly ["la", "te", "ti", "do", "di", "re", "re", "mi", "fa", "fi", "sol", "si"];
|
|
83
71
|
};
|
|
84
72
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"note-label-collections.d.ts","sourceRoot":"","sources":["../../../../src/src/data/labels/note-label-collections.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"note-label-collections.d.ts","sourceRoot":"","sources":["../../../../src/src/data/labels/note-label-collections.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAErE,yFAAyF;AACzF,MAAM,MAAM,cAAc,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;AAEpD,iFAAiF;AACjF,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;CACjC;AAED,QAAA,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoJjB,CAAC;AAEX,+EAA+E;AAC/E,MAAM,MAAM,sBAAsB,GAAG,MAAM,OAAO,qBAAqB,CAAC;AAExE,yGAAyG;AACzG,eAAO,MAAM,oBAAoB,EAAE,MAAM,CACvC,sBAAsB,EACtB,mBAAmB,CACI,CAAC"}
|
|
@@ -2,31 +2,31 @@ const _noteLabelCollections = {
|
|
|
2
2
|
noteNamesFlat: {
|
|
3
3
|
name: "Flat Note Names",
|
|
4
4
|
shortName: "Flat Notes",
|
|
5
|
-
|
|
5
|
+
mode: "absolute",
|
|
6
6
|
labels: ["C", "D♭", "D", "E♭", "E", "F", "G♭", "G", "A♭", "A", "B♭", "B"],
|
|
7
7
|
},
|
|
8
8
|
noteNamesSharp: {
|
|
9
9
|
name: "Sharp Note Names",
|
|
10
10
|
shortName: "Sharp Notes",
|
|
11
|
-
|
|
11
|
+
mode: "absolute",
|
|
12
12
|
labels: ["C", "C♯", "D", "D♯", "E", "F", "F♯", "G", "G♯", "A", "A♯", "B"],
|
|
13
13
|
},
|
|
14
14
|
intervalsFlat: {
|
|
15
15
|
name: "Flat Note Intervals",
|
|
16
16
|
shortName: "Flat Intervals",
|
|
17
|
-
|
|
17
|
+
mode: "relative",
|
|
18
18
|
labels: ["1", "♭2", "2", "♭3", "3", "4", "♭5", "5", "♭6", "6", "♭7", "7"],
|
|
19
19
|
},
|
|
20
20
|
intervalsSharp: {
|
|
21
21
|
name: "Sharp Note Intervals",
|
|
22
22
|
shortName: "Sharp Intervals",
|
|
23
|
-
|
|
23
|
+
mode: "relative",
|
|
24
24
|
labels: ["1", "♯1", "2", "♯2", "3", "4", "♯4", "5", "♯5", "6", "♯6", "7"],
|
|
25
25
|
},
|
|
26
26
|
extensionsFlat: {
|
|
27
27
|
name: "Flat Note Extensions",
|
|
28
28
|
shortName: "Flat Extensions",
|
|
29
|
-
|
|
29
|
+
mode: "relative",
|
|
30
30
|
labels: [
|
|
31
31
|
"1",
|
|
32
32
|
"♭9",
|
|
@@ -45,7 +45,7 @@ const _noteLabelCollections = {
|
|
|
45
45
|
extensionsSharp: {
|
|
46
46
|
name: "Sharp Note Extensions",
|
|
47
47
|
shortName: "Sharp Extensions",
|
|
48
|
-
|
|
48
|
+
mode: "relative",
|
|
49
49
|
labels: [
|
|
50
50
|
"1",
|
|
51
51
|
"♯1",
|
|
@@ -64,7 +64,7 @@ const _noteLabelCollections = {
|
|
|
64
64
|
fixedDoFlat: {
|
|
65
65
|
name: "Solfege Fixed Do Flat Notes",
|
|
66
66
|
shortName: "Fixed Do Flat",
|
|
67
|
-
|
|
67
|
+
mode: "absolute",
|
|
68
68
|
labels: [
|
|
69
69
|
"do",
|
|
70
70
|
"re♭",
|
|
@@ -83,7 +83,7 @@ const _noteLabelCollections = {
|
|
|
83
83
|
fixedDoSharp: {
|
|
84
84
|
name: "Solfege Fixed Do Sharp Notes",
|
|
85
85
|
shortName: "Fixed Do Sharp",
|
|
86
|
-
|
|
86
|
+
mode: "absolute",
|
|
87
87
|
labels: [
|
|
88
88
|
"do",
|
|
89
89
|
"do♯",
|
|
@@ -102,7 +102,7 @@ const _noteLabelCollections = {
|
|
|
102
102
|
movableDo: {
|
|
103
103
|
name: "Solfege Movable Do Notes",
|
|
104
104
|
shortName: "Movable Do",
|
|
105
|
-
|
|
105
|
+
mode: "relative",
|
|
106
106
|
labels: [
|
|
107
107
|
"do",
|
|
108
108
|
"ra",
|
|
@@ -121,7 +121,7 @@ const _noteLabelCollections = {
|
|
|
121
121
|
movableLa: {
|
|
122
122
|
name: "Solfege Movable La Notes",
|
|
123
123
|
shortName: "Movable La",
|
|
124
|
-
|
|
124
|
+
mode: "relative",
|
|
125
125
|
labels: [
|
|
126
126
|
"la",
|
|
127
127
|
"te",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { ChromaticIndex } from "../chromatic.js";
|
|
1
2
|
/** Represents the mathematical zero-indexed pitch class of a root note, where C is 0 and B is 11. */
|
|
2
|
-
export type RootNoteInteger =
|
|
3
|
+
export type RootNoteInteger = ChromaticIndex;
|
|
3
4
|
declare const _noteLetters: readonly ["C", "D", "E", "F", "G", "A", "B"];
|
|
4
5
|
/** An alphabetical musical note letter without any accidentals. */
|
|
5
6
|
export type NoteLetter = (typeof _noteLetters)[number];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"note-labels.d.ts","sourceRoot":"","sources":["../../../../src/src/data/labels/note-labels.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"note-labels.d.ts","sourceRoot":"","sources":["../../../../src/src/data/labels/note-labels.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,qGAAqG;AACrG,MAAM,MAAM,eAAe,GAAG,cAAc,CAAC;AAE7C,QAAA,MAAM,YAAY,8CAA+C,CAAC;AAElE,mEAAmE;AACnE,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvD,4EAA4E;AAC5E,eAAO,MAAM,WAAW,EAAE,SAAS,UAAU,EAAiB,CAAC;AAE/D,QAAA,MAAM,2BAA2B;;;;;;CAMvB,CAAC;AAEX,kFAAkF;AAClF,MAAM,MAAM,cAAc,GAAG,MAAM,OAAO,2BAA2B,CAAC;AAEtE,uFAAuF;AACvF,eAAO,MAAM,0BAA0B,EAAE,WAAW,CAAC,cAAc,EAAE,MAAM,CAGxE,CAAC;AAEJ,QAAA,MAAM,yBAAyB,kZAarB,CAAC;AAEX,gGAAgG;AAChG,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,yBAAyB,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;AAE1E,wGAAwG;AACxG,eAAO,MAAM,wBAAwB,EAAE,SAAS,CAAC,SAAS,QAAQ,EAAE,CAAC,EAC1C,CAAC;AAE5B,qDAAqD;AACrD,eAAO,MAAM,SAAS,EAAE,SAAS,QAAQ,EAAoC,CAAC;AAE9E,qFAAqF;AACrF,eAAO,MAAM,YAAY,EAAE,WAAW,CAAC,QAAQ,CAAsB,CAAC;AAEtE,uGAAuG;AACvG,eAAO,MAAM,oBAAoB,EAAE,WAAW,CAAC,QAAQ,EAAE,eAAe,CASlE,CAAC;AAEP,QAAA,MAAM,yBAAyB,sQAarB,CAAC;AAEX,sGAAsG;AACtG,MAAM,MAAM,QAAQ,G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1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/src/data/mod.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/src/data/mod.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC"}
|
package/esm/src/data/mod.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type NoteCollectionKey } from "../data/note-collections/mod.js";
|
|
2
2
|
import type { ChordQuality, RomanSeventhChord, RomanTriad, SeventhChord, Triad } from "../types/chords";
|
|
3
|
-
import {
|
|
3
|
+
import type { NoteCollectionKeyTransformOptions, RootAndNoteCollectionKeyTransformOptions } from "./intervals.js";
|
|
4
4
|
import { type RootNote } from "../data/labels/note-labels.js";
|
|
5
5
|
export declare function getRomanNumeralForScaleIndexAndChordQuality(scaleIndex: number, quality: ChordQuality): string | undefined;
|
|
6
6
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chords.d.ts","sourceRoot":"","sources":["../../../src/src/utils/chords.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,UAAU,EACV,YAAY,EACZ,KAAK,EACN,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"chords.d.ts","sourceRoot":"","sources":["../../../src/src/utils/ch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,EAClB,iBAAiB,EAAE,iBAAiB,EACpC,OAAO,GAAE,wCAA6C,GACrD,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,CAsBxB;AAED;;;GAGG;AACH,wBAAgB,2CAA2C,CACzD,QAAQ,EAAE,QAAQ,EAClB,iBAAiB,EAAE,iBAAiB,EACpC,OAAO,GAAE,wCAA6C,GACrD,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,CAsBxB;AAED;;;;GAIG;AACH,wBAAgB,yCAAyC,CACvD,QAAQ,EAAE,QAAQ,EAClB,iBAAiB,EAAE,iBAAiB,EACpC,OAAO,GAAE,wCAA6C,GACrD,CAAC,UAAU,GAAG,SAAS,CAAC,EAAE,CAY5B;AAED;;;;GAIG;AACH,wBAAgB,gDAAgD,CAC9D,QAAQ,EAAE,QAAQ,EAClB,iBAAiB,EAAE,iBAAiB,EACpC,OAAO,GAAE,wCAA6C,GACrD,CAAC,iBAAiB,GAAG,SAAS,CAAC,EAAE,CAYnC"}
|
package/esm/src/utils/chords.js
CHANGED
|
@@ -5,7 +5,7 @@ import { harmonicMinorModes, } from "../data/note-collections/harmonic-minor-mod
|
|
|
5
5
|
import { melodicMinorModes, } from "../data/note-collections/melodic-minor-modes.js";
|
|
6
6
|
import { intervalToIntegerMap, } from "../data/labels/note-labels.js";
|
|
7
7
|
import { diatonicModes, } from "../data/note-collections/diatonic-modes.js";
|
|
8
|
-
import {
|
|
8
|
+
import { createChromaticTuple, normalizeChromaticIndex } from "./chromatic.js";
|
|
9
9
|
import { getNoteNamesForRootAndNoteCollectionKey } from "./note-names.js";
|
|
10
10
|
import { noteNameToIntegerMap, } from "../data/labels/note-labels.js";
|
|
11
11
|
export function getRomanNumeralForScaleIndexAndChordQuality(scaleIndex, quality) {
|
|
@@ -67,14 +67,16 @@ function getChromaticArray(items, intervals) {
|
|
|
67
67
|
undefined,
|
|
68
68
|
undefined,
|
|
69
69
|
];
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
intervals.forEach((interval, i) => {
|
|
71
|
+
if (interval === "8" || interval === "♮8") {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
72
74
|
const semitones = intervalToIntegerMap.get(interval);
|
|
73
75
|
if (semitones !== undefined) {
|
|
74
|
-
result[semitones
|
|
76
|
+
result[normalizeChromaticIndex(semitones)] = items[i];
|
|
75
77
|
}
|
|
76
78
|
});
|
|
77
|
-
return result;
|
|
79
|
+
return createChromaticTuple(result);
|
|
78
80
|
}
|
|
79
81
|
function getModeData(modeKey) {
|
|
80
82
|
if (Object.prototype.hasOwnProperty.call(diatonicModes, modeKey)) {
|
|
@@ -121,7 +123,7 @@ function getChordsForNoteCollectionKey(noteCollectionKey, options, extractChords
|
|
|
121
123
|
const { rotateToRootInteger0, rootNoteInteger } = rootOptions ?? {};
|
|
122
124
|
// Helper function to apply requested rotations after the chord array is cleanly generated.
|
|
123
125
|
const applyRotations = (chordsArray, isChromatic) => {
|
|
124
|
-
let result = chordsArray;
|
|
126
|
+
let result = [...chordsArray];
|
|
125
127
|
// If fillChromatic is true, the array represents the 12 absolute semitones (where index 0 = the root note relative to itself).
|
|
126
128
|
if (isChromatic) {
|
|
127
129
|
if (rotateToRootInteger0 && rootNoteInteger !== undefined) {
|
|
@@ -173,15 +175,18 @@ function getChordsForNoteCollectionKey(noteCollectionKey, options, extractChords
|
|
|
173
175
|
: similarChords;
|
|
174
176
|
// 3b. Pluck out only the chords that align with the intervals actually present in the custom scale.
|
|
175
177
|
// E.g. For Minor Pentatonic (intervals 1, b3, 4, 5, b7), we grab the 1st, 3rd, 4th, 5th, and 7th chords of Aeolian.
|
|
176
|
-
const
|
|
178
|
+
const collectionChordsByInterval = collection.intervals
|
|
177
179
|
.map((interval) => {
|
|
178
180
|
const index = similarData.intervals.indexOf(interval);
|
|
179
181
|
return index !== -1 ? similarProcessedChords[index] : undefined;
|
|
180
|
-
})
|
|
182
|
+
});
|
|
183
|
+
// Keep a placeholder-preserving array for fillChromatic;
|
|
184
|
+
// otherwise a missing interval, such as the blues scale ♭5, shifts later chords.
|
|
185
|
+
const collectionChords = collectionChordsByInterval
|
|
181
186
|
.filter((chord) => chord !== undefined);
|
|
182
187
|
// 3c. Format and return just like step 2.
|
|
183
188
|
if (fillChromatic) {
|
|
184
|
-
return applyRotations(getChromaticArray(
|
|
189
|
+
return applyRotations(getChromaticArray(collectionChordsByInterval, collection.intervals), true);
|
|
185
190
|
}
|
|
186
191
|
return applyRotations(collectionChords, false);
|
|
187
192
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type ChromaticIndex, type ChromaticTuple } from "../data/chromatic.js";
|
|
2
|
+
export declare function isChromaticIndex(value: number): value is ChromaticIndex;
|
|
3
|
+
export declare function normalizeChromaticIndex(value: number): ChromaticIndex;
|
|
4
|
+
export declare function isChromaticTuple<T>(values: readonly T[]): values is ChromaticTuple<T>;
|
|
5
|
+
export declare function createChromaticTuple<T>(values: readonly T[]): ChromaticTuple<T>;
|
|
6
|
+
//# sourceMappingURL=chromatic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chromatic.d.ts","sourceRoot":"","sources":["../../../src/src/utils/chromatic.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,sBAAsB,CAAC;AAE9B,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,cAAc,CAEvE;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,CAcrE;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAChC,MAAM,EAAE,SAAS,CAAC,EAAE,GACnB,MAAM,IAAI,cAAc,CAAC,CAAC,CAAC,CAE7B;AAED,wBAAgB,oBAAoB,CAAC,CAAC,EACpC,MAAM,EAAE,SAAS,CAAC,EAAE,GACnB,cAAc,CAAC,CAAC,CAAC,CAQnB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { CHROMATIC_NOTE_COUNT, } from "../data/chromatic.js";
|
|
2
|
+
export function isChromaticIndex(value) {
|
|
3
|
+
return Number.isInteger(value) && value >= 0 && value < CHROMATIC_NOTE_COUNT;
|
|
4
|
+
}
|
|
5
|
+
export function normalizeChromaticIndex(value) {
|
|
6
|
+
if (!Number.isFinite(value)) {
|
|
7
|
+
throw new Error(`Chromatic index must be finite. Received ${value}.`);
|
|
8
|
+
}
|
|
9
|
+
if (!Number.isInteger(value)) {
|
|
10
|
+
throw new Error(`Chromatic index must be an integer. Received ${value}.`);
|
|
11
|
+
}
|
|
12
|
+
const integer = value;
|
|
13
|
+
return ((integer % CHROMATIC_NOTE_COUNT + CHROMATIC_NOTE_COUNT) %
|
|
14
|
+
CHROMATIC_NOTE_COUNT);
|
|
15
|
+
}
|
|
16
|
+
export function isChromaticTuple(values) {
|
|
17
|
+
return values.length === CHROMATIC_NOTE_COUNT;
|
|
18
|
+
}
|
|
19
|
+
export function createChromaticTuple(values) {
|
|
20
|
+
if (!isChromaticTuple(values)) {
|
|
21
|
+
throw new Error(`Expected ${CHROMATIC_NOTE_COUNT} chromatic values. Received ${values.length}.`);
|
|
22
|
+
}
|
|
23
|
+
return [...values];
|
|
24
|
+
}
|