@musodojo/music-theory-data 14.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.
@@ -0,0 +1,74 @@
1
+ import { diatonicModes } from "./diatonic-modes.ts";
2
+ import { harmonicMinorModes } from "./harmonic-minor-modes.ts";
3
+ import { melodicMinorModes } from "./melodic-minor-modes.ts";
4
+ import { dominantVariants } from "./dominant-variants.ts";
5
+ import { majorVariants } from "./major-variants.ts";
6
+ import { otherNoteCollections } from "./other-collections.ts";
7
+
8
+ export { diatonicModes } from "./diatonic-modes.ts";
9
+ export { dominantVariants } from "./dominant-variants.ts";
10
+ export { harmonicMinorModes } from "./harmonic-minor-modes.ts";
11
+ export { majorVariants } from "./major-variants.ts";
12
+ export { melodicMinorModes } from "./melodic-minor-modes.ts";
13
+ export { otherNoteCollections } from "./other-collections.ts";
14
+
15
+ export const noteCollections = {
16
+ ...diatonicModes,
17
+ ...harmonicMinorModes,
18
+ ...melodicMinorModes,
19
+ ...dominantVariants,
20
+ ...majorVariants,
21
+ ...otherNoteCollections,
22
+ } as const;
23
+
24
+ export type NoteCollectionKey = keyof typeof noteCollections;
25
+
26
+ export const groupedNoteCollections = {
27
+ diatonicModes,
28
+ harmonicMinorModes,
29
+ melodicMinorModes,
30
+ dominantVariants,
31
+ majorVariants,
32
+ otherNoteCollections,
33
+ } as const;
34
+
35
+ export type NoteCollectionGroupKey = keyof typeof groupedNoteCollections;
36
+
37
+ export const noteCollectionGroupsMetadata: Record<
38
+ NoteCollectionGroupKey,
39
+ {
40
+ displayName: string;
41
+ description: string;
42
+ }
43
+ > = {
44
+ diatonicModes: {
45
+ displayName: "Diatonic Modes",
46
+ description:
47
+ "Traditional seven-note scales derived from the major scale, each starting on a different scale degree.",
48
+ },
49
+ harmonicMinorModes: {
50
+ displayName: "Harmonic Minor Modes",
51
+ description:
52
+ "Seven-note scales derived from the harmonic minor scale, each starting on a different scale degree.",
53
+ },
54
+ melodicMinorModes: {
55
+ displayName: "Melodic Minor Modes",
56
+ description:
57
+ "Seven-note scales derived from the melodic minor scale, each starting on a different scale degree.",
58
+ },
59
+ dominantVariants: {
60
+ displayName: "Dominant Variants",
61
+ description:
62
+ "Chord structures based on the dominant seventh chord, including extended harmonies (9ths, 11ths, 13ths).",
63
+ },
64
+ majorVariants: {
65
+ displayName: "Major Variants",
66
+ description:
67
+ "Chord structures based on the major triad, including sixth and major seventh harmonies.",
68
+ },
69
+ otherNoteCollections: {
70
+ displayName: "Other",
71
+ description:
72
+ "Other note collections that don't fall into a specific category.",
73
+ },
74
+ } as const;
@@ -0,0 +1,76 @@
1
+ import type { NoteCollection } from "../../types/note-collections.d.ts";
2
+ const chromatic: NoteCollection = {
3
+ primaryName: "Chromatic",
4
+ names: ["Chromatic", "Twelve-Tone Scale"],
5
+ intervals: [
6
+ "1",
7
+ "♭2",
8
+ "2",
9
+ "♭3",
10
+ "3",
11
+ "4",
12
+ "♭5",
13
+ "5",
14
+ "♭6",
15
+ "6",
16
+ "♭7",
17
+ "7",
18
+ "8",
19
+ ],
20
+ integers: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
21
+ type: ["chromatic", "scale", "non-diatonic", "dodecaphonic"],
22
+ characteristics: [
23
+ "atonal",
24
+ "dissonant",
25
+ "no tonal center",
26
+ "contains all 12 pitches",
27
+ "used for passing tones and creating tension",
28
+ ],
29
+ pattern: [
30
+ "half",
31
+ "half",
32
+ "half",
33
+ "half",
34
+ "half",
35
+ "half",
36
+ "half",
37
+ "half",
38
+ "half",
39
+ "half",
40
+ "half",
41
+ ],
42
+ patternShort: ["H", "H", "H", "H", "H", "H", "H", "H", "H", "H", "H"],
43
+ } as const;
44
+
45
+ const wholeTone: NoteCollection = {
46
+ primaryName: "Whole Tone Scale",
47
+ names: [
48
+ "Whole Tone Scale",
49
+ ],
50
+ intervals: ["1", "2", "3", "♯4", "♯5", "♯6", "8"],
51
+ integers: [0, 2, 4, 6, 8, 10],
52
+ type: ["whole tone", "scale", "symmetrical", "hexatonic"],
53
+ characteristics: [
54
+ "six pitches in an octave",
55
+ "no tonal center",
56
+ "no leading tone and because all tones are the same distance apart",
57
+ "used in impressionistic music",
58
+ "creates a dreamy or ethereal sound",
59
+ "often used in film scores",
60
+ "associated with composers like Debussy and Ravel",
61
+ ],
62
+ pattern: ["whole", "whole", "whole", "whole", "whole"],
63
+ patternShort: ["W", "W", "W", "W", "W"],
64
+ } as const;
65
+
66
+ export const _otherNoteCollections = {
67
+ chromatic,
68
+ wholeTone,
69
+ } as const;
70
+
71
+ export type OtherNoteCollectionKey = keyof typeof _otherNoteCollections;
72
+
73
+ export const otherNoteCollections: Record<
74
+ OtherNoteCollectionKey,
75
+ NoteCollection
76
+ > = _otherNoteCollections;
@@ -0,0 +1,265 @@
1
+ // MINOR VARIANTS
2
+ export default [
3
+ {
4
+ name: "m / Minor",
5
+ category: "Minor",
6
+ sequence: [0, 3, 7],
7
+ },
8
+ {
9
+ name: "m6 / Minor Major 6th",
10
+ category: "Minor",
11
+ sequence: [0, 3, 7, 9],
12
+ },
13
+ {
14
+ name: "m7 / Minor 7th",
15
+ category: "Minor",
16
+ sequence: [0, 3, 7, 10],
17
+ },
18
+ {
19
+ name: "m9 / Minor 9th",
20
+ category: "Minor",
21
+ sequence: [0, 2, 3, 7, 10],
22
+ labels: {
23
+ Quality: { 2: "M9" },
24
+ Relative: { 2: "9" },
25
+ },
26
+ },
27
+ {
28
+ name: "m(add9) / Minor add 9",
29
+ category: "Minor",
30
+ sequence: [0, 2, 3, 7],
31
+ labels: {
32
+ Quality: { 2: "M9" },
33
+ Relative: { 2: "9" },
34
+ },
35
+ },
36
+ {
37
+ name: "m6/9 / Minor 6/9",
38
+ category: "Minor",
39
+ sequence: [0, 2, 3, 7, 9],
40
+ labels: {
41
+ Quality: { 2: "M9" },
42
+ Relative: { 2: "9" },
43
+ },
44
+ },
45
+ ];
46
+
47
+
48
+ // PENTATONIC
49
+ export default [
50
+ {
51
+ name: "Major Pentatonic",
52
+ category: "Pentatonic",
53
+ sequence: [0, 2, 4, 7, 9],
54
+ },
55
+ {
56
+ name: "Suspended Pentatonic",
57
+ category: "Pentatonic",
58
+ sequence: [0, 2, 5, 7, 10],
59
+ },
60
+ {
61
+ name: "Blues Minor Pentatonic",
62
+ category: "Pentatonic",
63
+ sequence: [0, 3, 5, 8, 10],
64
+ },
65
+ {
66
+ name: "Blues Major Pentatonic",
67
+ category: "Pentatonic",
68
+ sequence: [0, 2, 5, 7, 9],
69
+ },
70
+ {
71
+ name: "Minor Pentatonic",
72
+ category: "Pentatonic",
73
+ sequence: [0, 3, 5, 7, 10],
74
+ },
75
+ {
76
+ name: "Dominant Pentatonic",
77
+ category: "Pentatonic",
78
+ sequence: [0, 2, 4, 7, 10],
79
+ },
80
+ ];
81
+
82
+
83
+ // OTHER
84
+ export default [
85
+ // Diminished
86
+ {
87
+ name: "dim / o / Diminished Triad",
88
+ category: "Diminished",
89
+ sequence: [0, 3, 6],
90
+ },
91
+ {
92
+ name: "dim7 / o7 / Diminished 7th",
93
+ category: "Diminished",
94
+ sequence: [0, 3, 6, 9],
95
+ labels: {
96
+ Quality: { 9: "d7" },
97
+ Relative: { 9: "♭♭7" },
98
+ Extension: { 9: "♭♭7" },
99
+ },
100
+ },
101
+ {
102
+ name: "m7♭5 / ø7 / Half Diminished 7th",
103
+ category: "Diminished",
104
+ sequence: [0, 3, 6, 10],
105
+ },
106
+ {
107
+ name: "Whole Half Diminished",
108
+ category: "Diminished",
109
+ sequence: [0, 2, 3, 5, 6, 8, 9, 11],
110
+ labels: {
111
+ Quality: { 8: "A5" },
112
+ Relative: { 8: "♯5" },
113
+ Extension: { 8: "♯5" },
114
+ },
115
+ },
116
+ {
117
+ name: "Half Whole / Dominant Diminished",
118
+ category: "Diminished",
119
+ sequence: [0, 1, 3, 4, 6, 7, 9, 10],
120
+ labels: {
121
+ Quality: { 3: "A2", 6: "A4" },
122
+ Relative: { 3: "♯2", 6: "♯4" },
123
+ Extension: { 3: "♯9", 6: "♯11" },
124
+ },
125
+ },
126
+ // Augmented
127
+ {
128
+ name: "aug / + / Augmented Triad",
129
+ category: "Augmented",
130
+ sequence: [0, 4, 8],
131
+ labels: {
132
+ Quality: { 8: "A5" },
133
+ Relative: { 8: "♯5" },
134
+ Extension: { 8: "♯5" },
135
+ },
136
+ },
137
+ {
138
+ name: "It+6 / Italian 6th",
139
+ category: "Augmented",
140
+ sequence: [0, 4, 10],
141
+ labels: {
142
+ Quality: { 10: "A6" },
143
+ Relative: { 10: "♯6" },
144
+ Extension: { 10: "♯13" },
145
+ },
146
+ },
147
+ {
148
+ name: "Fr+6 / French 6th",
149
+ category: "Augmented",
150
+ sequence: [0, 4, 6, 10],
151
+ labels: {
152
+ Quality: { 10: "A6" },
153
+ Relative: { 10: "♯6" },
154
+ Extension: { 10: "♯13" },
155
+ },
156
+ },
157
+ {
158
+ name: "Ger+6 / German 6th",
159
+ category: "Augmented",
160
+ sequence: [0, 4, 7, 10],
161
+ labels: {
162
+ Quality: { 10: "A6" },
163
+ Relative: { 10: "♯6" },
164
+ Extension: { 10: "♯13" },
165
+ },
166
+ },
167
+ {
168
+ name: "aug7 / +7 / 7♯5 / Augmented Seventh",
169
+ category: "Augmented",
170
+ sequence: [0, 4, 8, 10],
171
+ labels: {
172
+ Quality: { 8: "A5" },
173
+ Relative: { 8: "♯5" },
174
+ Extension: { 8: "♯5" },
175
+ },
176
+ },
177
+
178
+ // Harmonic Minor
179
+ {
180
+ name: "Harmonic Minor",
181
+ category: "Harmonic Minor",
182
+ sequence: [0, 2, 3, 5, 7, 8, 11],
183
+ },
184
+ {
185
+ name: "Locrian ♯6",
186
+ category: "Harmonic Minor",
187
+ sequence: [0, 1, 3, 5, 6, 9, 10],
188
+ },
189
+ {
190
+ name: "Ionian ♯5",
191
+ category: "Harmonic Minor",
192
+ sequence: [0, 2, 4, 5, 8, 9, 11],
193
+ labels: {
194
+ Quality: { 8: "A5" },
195
+ Relative: { 8: "♯5" },
196
+ Extension: { 8: "♯5" },
197
+ },
198
+ },
199
+ {
200
+ name: "Dorian ♯4",
201
+ category: "Harmonic Minor",
202
+ sequence: [0, 2, 3, 6, 7, 9, 10],
203
+ labels: {
204
+ Quality: { 6: "A4" },
205
+ Relative: { 6: "♯4" },
206
+ Extension: { 6: "♯11" },
207
+ },
208
+ },
209
+ {
210
+ name: "Phrygian Dominant",
211
+ category: "Harmonic Minor",
212
+ sequence: [0, 1, 4, 5, 7, 8, 10],
213
+ },
214
+ {
215
+ name: "Lydian ♯2",
216
+ category: "Harmonic Minor",
217
+ sequence: [0, 3, 4, 6, 7, 9, 11],
218
+ labels: {
219
+ Quality: { 3: "A2", 6: "A4" },
220
+ Relative: { 3: "♯2", 6: "♯4" },
221
+ Extension: { 3: "♯9", 6: "♯11" },
222
+ },
223
+ },
224
+ {
225
+ name: "Super Locrian ♭♭7",
226
+ category: "Harmonic Minor",
227
+ sequence: [0, 1, 3, 4, 6, 8, 9],
228
+ labels: {
229
+ Quality: { 4: "d4", 9: "d7" },
230
+ Relative: { 4: "♭4", 9: "♭♭7" },
231
+ Extension: { 4: "♭11", 9: "♭♭7" },
232
+ },
233
+ },
234
+ // Other
235
+ {
236
+ name: "R / Root",
237
+ category: "Other",
238
+ sequence: [0],
239
+ },
240
+ {
241
+ name: "Chromatic",
242
+ category: "Other",
243
+ sequence: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
244
+ },
245
+ {
246
+ name: "Blank",
247
+ category: "Other",
248
+ sequence: [],
249
+ },
250
+ {
251
+ name: "Root and 5th",
252
+ category: "Other",
253
+ sequence: [0, 7],
254
+ },
255
+ {
256
+ name: "Blues",
257
+ category: "Other",
258
+ sequence: [0, 3, 5, 6, 7, 10],
259
+ },
260
+ {
261
+ name: "Whole Tone",
262
+ category: "Other",
263
+ sequence: [0, 2, 4, 6, 8, 10],
264
+ },
265
+ ];
package/src/mod.ts ADDED
@@ -0,0 +1,24 @@
1
+ /**
2
+ * A comprehensive library of music theory data, including scales, chords, and notes.
3
+ *
4
+ * This package provides a collection of datasets and utility functions
5
+ * to work with fundamental concepts of music theory. It's designed to be
6
+ * a foundational block for music-related applications, educational tools,
7
+ * and creative coding projects.
8
+ *
9
+ * @module
10
+ * @example
11
+ * ```ts
12
+ * // Import the entire library
13
+ * import * as music_theory_data from "jsr:@musodojo/music-theory-data";
14
+ *
15
+ * // You can now access all the data and functions.
16
+ * // The details for the Ionian Diatonic Mode (Major Scale).
17
+ * console.log("ionian details: ", music_theory_data.noteCollections.ionian);
18
+ * // Get the notes of a stored chord, or scale.
19
+ * console.log("A harmonic minor: ", music_theory_data.getNoteNamesFromRootAndCollectionKey("A", "harmonicMinor"))
20
+ * ```
21
+ */
22
+ export * from "./data/mod.ts";
23
+ export type * from "./types/mod.d.ts";
24
+ export * from "./utils/mod.ts";
@@ -0,0 +1,48 @@
1
+ import type { Interval } from "../data/labels/note-labels.ts";
2
+
3
+ export type Triad = "M" | "m" | "°" | "+";
4
+
5
+ export type SeventhChord =
6
+ | "M7"
7
+ | "m7"
8
+ | "7"
9
+ | "ø7"
10
+ | "m7♭5"
11
+ | "°7"
12
+ | "m(M7)"
13
+ | "+M7"
14
+ | "M7♯5";
15
+
16
+ export type UpperCaseRomanNumeral =
17
+ | "I"
18
+ | "II"
19
+ | "III"
20
+ | "IV"
21
+ | "V"
22
+ | "VI"
23
+ | "VII";
24
+
25
+ export type LowerCaseRomanNumeral =
26
+ | "i"
27
+ | "ii"
28
+ | "iii"
29
+ | "iv"
30
+ | "v"
31
+ | "vi"
32
+ | "vii";
33
+
34
+ export type RomanNumeral = UpperCaseRomanNumeral | LowerCaseRomanNumeral;
35
+
36
+ export type RomanTriad =
37
+ | `${RomanNumeral}`
38
+ | `${RomanNumeral}${Triad}`;
39
+
40
+ export type RomanSeventhChord = `${RomanNumeral}${SeventhChord}`;
41
+
42
+ export interface ChordDetails {
43
+ interval: Interval;
44
+ triad: Triad;
45
+ seventh: SeventhChord;
46
+ romanTriad: RomanTriad;
47
+ romanSeventhChord: RomanSeventhChord;
48
+ }
@@ -0,0 +1,133 @@
1
+ export type OctaveNumber = -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
2
+
3
+ export type MidiNoteNumber =
4
+ | 0
5
+ | 1
6
+ | 2
7
+ | 3
8
+ | 4
9
+ | 5
10
+ | 6
11
+ | 7
12
+ | 8
13
+ | 9
14
+ | 10
15
+ | 11
16
+ | 12
17
+ | 13
18
+ | 14
19
+ | 15
20
+ | 16
21
+ | 17
22
+ | 18
23
+ | 19
24
+ | 20
25
+ | 21
26
+ | 22
27
+ | 23
28
+ | 24
29
+ | 25
30
+ | 26
31
+ | 27
32
+ | 28
33
+ | 29
34
+ | 30
35
+ | 31
36
+ | 32
37
+ | 33
38
+ | 34
39
+ | 35
40
+ | 36
41
+ | 37
42
+ | 38
43
+ | 39
44
+ | 40
45
+ | 41
46
+ | 42
47
+ | 43
48
+ | 44
49
+ | 45
50
+ | 46
51
+ | 47
52
+ | 48
53
+ | 49
54
+ | 50
55
+ | 51
56
+ | 52
57
+ | 53
58
+ | 54
59
+ | 55
60
+ | 56
61
+ | 57
62
+ | 58
63
+ | 59
64
+ | 60
65
+ | 61
66
+ | 62
67
+ | 63
68
+ | 64
69
+ | 65
70
+ | 66
71
+ | 67
72
+ | 68
73
+ | 69
74
+ | 70
75
+ | 71
76
+ | 72
77
+ | 73
78
+ | 74
79
+ | 75
80
+ | 76
81
+ | 77
82
+ | 78
83
+ | 79
84
+ | 80
85
+ | 81
86
+ | 82
87
+ | 83
88
+ | 84
89
+ | 85
90
+ | 86
91
+ | 87
92
+ | 88
93
+ | 89
94
+ | 90
95
+ | 91
96
+ | 92
97
+ | 93
98
+ | 94
99
+ | 95
100
+ | 96
101
+ | 97
102
+ | 98
103
+ | 99
104
+ | 100
105
+ | 101
106
+ | 102
107
+ | 103
108
+ | 104
109
+ | 105
110
+ | 106
111
+ | 107
112
+ | 108
113
+ | 109
114
+ | 110
115
+ | 111
116
+ | 112
117
+ | 113
118
+ | 114
119
+ | 115
120
+ | 116
121
+ | 117
122
+ | 118
123
+ | 119
124
+ | 120
125
+ | 121
126
+ | 122
127
+ | 123
128
+ | 124
129
+ | 125
130
+ | 126
131
+ | 127;
132
+
133
+ export type MidiNoteSequence = (MidiNoteNumber | null)[];
@@ -0,0 +1,3 @@
1
+ export type * from "./chords.d.ts";
2
+ export type * from "./midi.d.ts";
3
+ export type * from "./note-collections.d.ts";
@@ -0,0 +1,13 @@
1
+ import type { Interval, NoteInteger } from "../data/labels/note-labels.ts";
2
+
3
+ export interface NoteCollection {
4
+ readonly primaryName: string;
5
+ readonly names: readonly string[];
6
+ readonly intervals: readonly Interval[];
7
+ readonly integers: readonly NoteInteger[];
8
+ readonly rotation?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
9
+ readonly type: readonly string[];
10
+ readonly characteristics: readonly string[];
11
+ readonly pattern: readonly string[];
12
+ readonly patternShort: readonly string[];
13
+ }