@tonaljs/chord 4.6.5 → 4.7.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 +2 -2
- package/dist/index.d.ts +93 -91
- package/dist/index.js +168 -232
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +145 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +11 -9
- package/dist/index.es.js +0 -200
- package/dist/index.es.js.map +0 -1
package/README.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,91 +1,93 @@
|
|
|
1
|
-
import { detect } from
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* @
|
|
24
|
-
* @
|
|
25
|
-
* @
|
|
26
|
-
*
|
|
27
|
-
* tokenize("
|
|
28
|
-
* tokenize("
|
|
29
|
-
* tokenize("
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* @param
|
|
41
|
-
* @param [
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* @
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
* @
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
declare
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
1
|
+
import { detect } from '@tonaljs/chord-detect';
|
|
2
|
+
export { detect } from '@tonaljs/chord-detect';
|
|
3
|
+
import { ChordType } from '@tonaljs/chord-type';
|
|
4
|
+
import { NoteName } from '@tonaljs/core';
|
|
5
|
+
|
|
6
|
+
type ChordName = string;
|
|
7
|
+
type ChordNameTokens = [string, string];
|
|
8
|
+
interface Chord extends ChordType {
|
|
9
|
+
tonic: string | null;
|
|
10
|
+
type: string;
|
|
11
|
+
root: string;
|
|
12
|
+
rootDegree: number;
|
|
13
|
+
symbol: string;
|
|
14
|
+
notes: NoteName[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Tokenize a chord name. It returns an array with the tonic and chord type
|
|
18
|
+
* If not tonic is found, all the name is considered the chord name.
|
|
19
|
+
*
|
|
20
|
+
* This function does NOT check if the chord type exists or not. It only tries
|
|
21
|
+
* to split the tonic and chord type.
|
|
22
|
+
*
|
|
23
|
+
* @function
|
|
24
|
+
* @param {string} name - the chord name
|
|
25
|
+
* @return {Array} an array with [tonic, type]
|
|
26
|
+
* @example
|
|
27
|
+
* tokenize("Cmaj7") // => [ "C", "maj7" ]
|
|
28
|
+
* tokenize("C7") // => [ "C", "7" ]
|
|
29
|
+
* tokenize("mMaj7") // => [ null, "mMaj7" ]
|
|
30
|
+
* tokenize("Cnonsense") // => [ null, "nonsense" ]
|
|
31
|
+
*/
|
|
32
|
+
declare function tokenize(name: string): ChordNameTokens;
|
|
33
|
+
/**
|
|
34
|
+
* Get a Chord from a chord name.
|
|
35
|
+
*/
|
|
36
|
+
declare function get(src: ChordName | ChordNameTokens): Chord;
|
|
37
|
+
/**
|
|
38
|
+
* Get chord properties
|
|
39
|
+
*
|
|
40
|
+
* @param typeName - the chord type name
|
|
41
|
+
* @param [tonic] - Optional tonic
|
|
42
|
+
* @param [root] - Optional root (requires a tonic)
|
|
43
|
+
*/
|
|
44
|
+
declare function getChord(typeName: string, optionalTonic?: string, optionalRoot?: string): Chord;
|
|
45
|
+
declare const chord: (this: unknown, ...args: unknown[]) => Chord;
|
|
46
|
+
/**
|
|
47
|
+
* Transpose a chord name
|
|
48
|
+
*
|
|
49
|
+
* @param {string} chordName - the chord name
|
|
50
|
+
* @return {string} the transposed chord
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* transpose('Dm7', 'P4') // => 'Gm7
|
|
54
|
+
*/
|
|
55
|
+
declare function transpose(chordName: string, interval: string): string;
|
|
56
|
+
/**
|
|
57
|
+
* Get all scales where the given chord fits
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* chordScales('C7b9')
|
|
61
|
+
* // => ["phrygian dominant", "flamenco", "spanish heptatonic", "half-whole diminished", "chromatic"]
|
|
62
|
+
*/
|
|
63
|
+
declare function chordScales(name: string): string[];
|
|
64
|
+
/**
|
|
65
|
+
* Get all chords names that are a superset of the given one
|
|
66
|
+
* (has the same notes and at least one more)
|
|
67
|
+
*
|
|
68
|
+
* @function
|
|
69
|
+
* @example
|
|
70
|
+
* extended("CMaj7")
|
|
71
|
+
* // => [ 'Cmaj#4', 'Cmaj7#9#11', 'Cmaj9', 'CM7add13', 'Cmaj13', 'Cmaj9#11', 'CM13#11', 'CM7b9' ]
|
|
72
|
+
*/
|
|
73
|
+
declare function extended(chordName: string): string[];
|
|
74
|
+
/**
|
|
75
|
+
* Find all chords names that are a subset of the given one
|
|
76
|
+
* (has less notes but all from the given chord)
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
*/
|
|
80
|
+
declare function reduced(chordName: string): string[];
|
|
81
|
+
declare const _default: {
|
|
82
|
+
getChord: typeof getChord;
|
|
83
|
+
get: typeof get;
|
|
84
|
+
detect: typeof detect;
|
|
85
|
+
chordScales: typeof chordScales;
|
|
86
|
+
extended: typeof extended;
|
|
87
|
+
reduced: typeof reduced;
|
|
88
|
+
tokenize: typeof tokenize;
|
|
89
|
+
transpose: typeof transpose;
|
|
90
|
+
chord: (this: unknown, ...args: unknown[]) => Chord;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export { Chord, chord, chordScales, _default as default, extended, get, getChord, reduced, tokenize, transpose };
|
package/dist/index.js
CHANGED
|
@@ -1,233 +1,169 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
6
19
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Get all scales where the given chord fits
|
|
160
|
-
*
|
|
161
|
-
* @example
|
|
162
|
-
* chordScales('C7b9')
|
|
163
|
-
* // => ["phrygian dominant", "flamenco", "spanish heptatonic", "half-whole diminished", "chromatic"]
|
|
164
|
-
*/
|
|
165
|
-
function chordScales(name) {
|
|
166
|
-
var s = get(name);
|
|
167
|
-
var isChordIncluded = pcset.isSupersetOf(s.chroma);
|
|
168
|
-
return scaleType.all()
|
|
169
|
-
.filter(function (scale) { return isChordIncluded(scale.chroma); })
|
|
170
|
-
.map(function (scale) { return scale.name; });
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Get all chords names that are a superset of the given one
|
|
174
|
-
* (has the same notes and at least one more)
|
|
175
|
-
*
|
|
176
|
-
* @function
|
|
177
|
-
* @example
|
|
178
|
-
* extended("CMaj7")
|
|
179
|
-
* // => [ 'Cmaj#4', 'Cmaj7#9#11', 'Cmaj9', 'CM7add13', 'Cmaj13', 'Cmaj9#11', 'CM13#11', 'CM7b9' ]
|
|
180
|
-
*/
|
|
181
|
-
function extended(chordName) {
|
|
182
|
-
var s = get(chordName);
|
|
183
|
-
var isSuperset = pcset.isSupersetOf(s.chroma);
|
|
184
|
-
return chordType.all()
|
|
185
|
-
.filter(function (chord) { return isSuperset(chord.chroma); })
|
|
186
|
-
.map(function (chord) { return s.tonic + chord.aliases[0]; });
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Find all chords names that are a subset of the given one
|
|
190
|
-
* (has less notes but all from the given chord)
|
|
191
|
-
*
|
|
192
|
-
* @example
|
|
193
|
-
*/
|
|
194
|
-
function reduced(chordName) {
|
|
195
|
-
var s = get(chordName);
|
|
196
|
-
var isSubset = pcset.isSubsetOf(s.chroma);
|
|
197
|
-
return chordType.all()
|
|
198
|
-
.filter(function (chord) { return isSubset(chord.chroma); })
|
|
199
|
-
.map(function (chord) { return s.tonic + chord.aliases[0]; });
|
|
200
|
-
}
|
|
201
|
-
var index = {
|
|
202
|
-
getChord: getChord,
|
|
203
|
-
get: get,
|
|
204
|
-
detect: chordDetect.detect,
|
|
205
|
-
chordScales: chordScales,
|
|
206
|
-
extended: extended,
|
|
207
|
-
reduced: reduced,
|
|
208
|
-
tokenize: tokenize,
|
|
209
|
-
transpose: transpose,
|
|
210
|
-
// deprecate
|
|
211
|
-
chord: chord,
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
Object.defineProperty(exports, 'detect', {
|
|
215
|
-
enumerable: true,
|
|
216
|
-
get: function () {
|
|
217
|
-
return chordDetect.detect;
|
|
218
|
-
}
|
|
219
|
-
});
|
|
220
|
-
exports.chord = chord;
|
|
221
|
-
exports.chordScales = chordScales;
|
|
222
|
-
exports['default'] = index;
|
|
223
|
-
exports.extended = extended;
|
|
224
|
-
exports.get = get;
|
|
225
|
-
exports.getChord = getChord;
|
|
226
|
-
exports.reduced = reduced;
|
|
227
|
-
exports.tokenize = tokenize;
|
|
228
|
-
exports.transpose = transpose;
|
|
229
|
-
|
|
230
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
231
|
-
|
|
232
|
-
})));
|
|
233
|
-
//# sourceMappingURL=index.js.map
|
|
20
|
+
// index.ts
|
|
21
|
+
var chord_exports = {};
|
|
22
|
+
__export(chord_exports, {
|
|
23
|
+
chord: () => chord,
|
|
24
|
+
chordScales: () => chordScales,
|
|
25
|
+
default: () => chord_default,
|
|
26
|
+
detect: () => import_chord_detect2.detect,
|
|
27
|
+
extended: () => extended,
|
|
28
|
+
get: () => get,
|
|
29
|
+
getChord: () => getChord,
|
|
30
|
+
reduced: () => reduced,
|
|
31
|
+
tokenize: () => tokenize,
|
|
32
|
+
transpose: () => transpose
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(chord_exports);
|
|
35
|
+
var import_chord_detect = require("@tonaljs/chord-detect");
|
|
36
|
+
var import_chord_type = require("@tonaljs/chord-type");
|
|
37
|
+
var import_core = require("@tonaljs/core");
|
|
38
|
+
var import_pcset = require("@tonaljs/pcset");
|
|
39
|
+
var import_scale_type = require("@tonaljs/scale-type");
|
|
40
|
+
var import_chord_detect2 = require("@tonaljs/chord-detect");
|
|
41
|
+
var NoChord = {
|
|
42
|
+
empty: true,
|
|
43
|
+
name: "",
|
|
44
|
+
symbol: "",
|
|
45
|
+
root: "",
|
|
46
|
+
rootDegree: 0,
|
|
47
|
+
type: "",
|
|
48
|
+
tonic: null,
|
|
49
|
+
setNum: NaN,
|
|
50
|
+
quality: "Unknown",
|
|
51
|
+
chroma: "",
|
|
52
|
+
normalized: "",
|
|
53
|
+
aliases: [],
|
|
54
|
+
notes: [],
|
|
55
|
+
intervals: []
|
|
56
|
+
};
|
|
57
|
+
var NUM_TYPES = /^(6|64|7|9|11|13)$/;
|
|
58
|
+
function tokenize(name) {
|
|
59
|
+
const [letter, acc, oct, type] = (0, import_core.tokenizeNote)(name);
|
|
60
|
+
if (letter === "") {
|
|
61
|
+
return ["", name];
|
|
62
|
+
}
|
|
63
|
+
if (letter === "A" && type === "ug") {
|
|
64
|
+
return ["", "aug"];
|
|
65
|
+
}
|
|
66
|
+
if (!type && (oct === "4" || oct === "5")) {
|
|
67
|
+
return [letter + acc, oct];
|
|
68
|
+
}
|
|
69
|
+
if (NUM_TYPES.test(oct)) {
|
|
70
|
+
return [letter + acc, oct + type];
|
|
71
|
+
} else {
|
|
72
|
+
return [letter + acc + oct, type];
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function get(src) {
|
|
76
|
+
if (src === "") {
|
|
77
|
+
return NoChord;
|
|
78
|
+
}
|
|
79
|
+
if (Array.isArray(src) && src.length === 2) {
|
|
80
|
+
return getChord(src[1], src[0]);
|
|
81
|
+
} else {
|
|
82
|
+
const [tonic, type] = tokenize(src);
|
|
83
|
+
const chord2 = getChord(type, tonic);
|
|
84
|
+
return chord2.empty ? getChord(src) : chord2;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function getChord(typeName, optionalTonic, optionalRoot) {
|
|
88
|
+
const type = (0, import_chord_type.get)(typeName);
|
|
89
|
+
const tonic = (0, import_core.note)(optionalTonic || "");
|
|
90
|
+
const root = (0, import_core.note)(optionalRoot || "");
|
|
91
|
+
if (type.empty || optionalTonic && tonic.empty || optionalRoot && root.empty) {
|
|
92
|
+
return NoChord;
|
|
93
|
+
}
|
|
94
|
+
const rootInterval = (0, import_core.distance)(tonic.pc, root.pc);
|
|
95
|
+
const rootDegree = type.intervals.indexOf(rootInterval) + 1;
|
|
96
|
+
if (!root.empty && !rootDegree) {
|
|
97
|
+
return NoChord;
|
|
98
|
+
}
|
|
99
|
+
const intervals = Array.from(type.intervals);
|
|
100
|
+
for (let i = 1; i < rootDegree; i++) {
|
|
101
|
+
const num = intervals[0][0];
|
|
102
|
+
const quality = intervals[0][1];
|
|
103
|
+
const newNum = parseInt(num, 10) + 7;
|
|
104
|
+
intervals.push(`${newNum}${quality}`);
|
|
105
|
+
intervals.shift();
|
|
106
|
+
}
|
|
107
|
+
const notes = tonic.empty ? [] : intervals.map((i) => (0, import_core.transpose)(tonic, i));
|
|
108
|
+
typeName = type.aliases.indexOf(typeName) !== -1 ? typeName : type.aliases[0];
|
|
109
|
+
const symbol = `${tonic.empty ? "" : tonic.pc}${typeName}${root.empty || rootDegree <= 1 ? "" : "/" + root.pc}`;
|
|
110
|
+
const name = `${optionalTonic ? tonic.pc + " " : ""}${type.name}${rootDegree > 1 && optionalRoot ? " over " + root.pc : ""}`;
|
|
111
|
+
return {
|
|
112
|
+
...type,
|
|
113
|
+
name,
|
|
114
|
+
symbol,
|
|
115
|
+
type: type.name,
|
|
116
|
+
root: root.name,
|
|
117
|
+
intervals,
|
|
118
|
+
rootDegree,
|
|
119
|
+
tonic: tonic.name,
|
|
120
|
+
notes
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
var chord = (0, import_core.deprecate)("Chord.chord", "Chord.get", get);
|
|
124
|
+
function transpose(chordName, interval) {
|
|
125
|
+
const [tonic, type] = tokenize(chordName);
|
|
126
|
+
if (!tonic) {
|
|
127
|
+
return chordName;
|
|
128
|
+
}
|
|
129
|
+
return (0, import_core.transpose)(tonic, interval) + type;
|
|
130
|
+
}
|
|
131
|
+
function chordScales(name) {
|
|
132
|
+
const s = get(name);
|
|
133
|
+
const isChordIncluded = (0, import_pcset.isSupersetOf)(s.chroma);
|
|
134
|
+
return (0, import_scale_type.all)().filter((scale) => isChordIncluded(scale.chroma)).map((scale) => scale.name);
|
|
135
|
+
}
|
|
136
|
+
function extended(chordName) {
|
|
137
|
+
const s = get(chordName);
|
|
138
|
+
const isSuperset = (0, import_pcset.isSupersetOf)(s.chroma);
|
|
139
|
+
return (0, import_chord_type.all)().filter((chord2) => isSuperset(chord2.chroma)).map((chord2) => s.tonic + chord2.aliases[0]);
|
|
140
|
+
}
|
|
141
|
+
function reduced(chordName) {
|
|
142
|
+
const s = get(chordName);
|
|
143
|
+
const isSubset = (0, import_pcset.isSubsetOf)(s.chroma);
|
|
144
|
+
return (0, import_chord_type.all)().filter((chord2) => isSubset(chord2.chroma)).map((chord2) => s.tonic + chord2.aliases[0]);
|
|
145
|
+
}
|
|
146
|
+
var chord_default = {
|
|
147
|
+
getChord,
|
|
148
|
+
get,
|
|
149
|
+
detect: import_chord_detect.detect,
|
|
150
|
+
chordScales,
|
|
151
|
+
extended,
|
|
152
|
+
reduced,
|
|
153
|
+
tokenize,
|
|
154
|
+
transpose,
|
|
155
|
+
chord
|
|
156
|
+
};
|
|
157
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
158
|
+
0 && (module.exports = {
|
|
159
|
+
chord,
|
|
160
|
+
chordScales,
|
|
161
|
+
detect,
|
|
162
|
+
extended,
|
|
163
|
+
get,
|
|
164
|
+
getChord,
|
|
165
|
+
reduced,
|
|
166
|
+
tokenize,
|
|
167
|
+
transpose
|
|
168
|
+
});
|
|
169
|
+
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../index.ts"],"sourcesContent":["import { detect } from \"@tonaljs/chord-detect\";\nimport {\n all as chordTypes,\n ChordType,\n get as getChordType,\n} from \"@tonaljs/chord-type\";\n\nimport {\n deprecate,\n distance,\n note,\n NoteName,\n tokenizeNote,\n transpose as transposeNote,\n} from \"@tonaljs/core\";\n\nimport { isSubsetOf, isSupersetOf } from \"@tonaljs/pcset\";\n\nimport { all as scaleTypes } from \"@tonaljs/scale-type\";\nexport { detect } from \"@tonaljs/chord-detect\";\n\ntype ChordName = string;\ntype ChordNameTokens = [string, string]; // [TONIC, SCALE TYPE]\n\nexport interface Chord extends ChordType {\n tonic: string | null;\n type: string;\n root: string;\n rootDegree: number;\n symbol: string;\n notes: NoteName[];\n}\n\nconst NoChord: Chord = {\n empty: true,\n name: \"\",\n symbol: \"\",\n root: \"\",\n rootDegree: 0,\n type: \"\",\n tonic: null,\n setNum: NaN,\n quality: \"Unknown\",\n chroma: \"\",\n normalized: \"\",\n aliases: [],\n notes: [],\n intervals: [],\n};\n\n// 6, 64, 7, 9, 11 and 13 are consider part of the chord\n// (see https://github.com/danigb/tonal/issues/55)\nconst NUM_TYPES = /^(6|64|7|9|11|13)$/;\n/**\n * Tokenize a chord name. It returns an array with the tonic and chord type\n * If not tonic is found, all the name is considered the chord name.\n *\n * This function does NOT check if the chord type exists or not. It only tries\n * to split the tonic and chord type.\n *\n * @function\n * @param {string} name - the chord name\n * @return {Array} an array with [tonic, type]\n * @example\n * tokenize(\"Cmaj7\") // => [ \"C\", \"maj7\" ]\n * tokenize(\"C7\") // => [ \"C\", \"7\" ]\n * tokenize(\"mMaj7\") // => [ null, \"mMaj7\" ]\n * tokenize(\"Cnonsense\") // => [ null, \"nonsense\" ]\n */\nexport function tokenize(name: string): ChordNameTokens {\n const [letter, acc, oct, type] = tokenizeNote(name);\n if (letter === \"\") {\n return [\"\", name];\n }\n // aug is augmented (see https://github.com/danigb/tonal/issues/55)\n if (letter === \"A\" && type === \"ug\") {\n return [\"\", \"aug\"];\n }\n // see: https://github.com/tonaljs/tonal/issues/70\n if (!type && (oct === \"4\" || oct === \"5\")) {\n return [letter + acc, oct];\n }\n\n if (NUM_TYPES.test(oct)) {\n return [letter + acc, oct + type];\n } else {\n return [letter + acc + oct, type];\n }\n}\n\n/**\n * Get a Chord from a chord name.\n */\nexport function get(src: ChordName | ChordNameTokens): Chord {\n if (src === \"\") {\n return NoChord;\n }\n if (Array.isArray(src) && src.length === 2) {\n return getChord(src[1], src[0]);\n } else {\n const [tonic, type] = tokenize(src);\n const chord = getChord(type, tonic);\n return chord.empty ? getChord(src) : chord;\n }\n}\n\n/**\n * Get chord properties\n *\n * @param typeName - the chord type name\n * @param [tonic] - Optional tonic\n * @param [root] - Optional root (requires a tonic)\n */\nexport function getChord(\n typeName: string,\n optionalTonic?: string,\n optionalRoot?: string\n): Chord {\n const type = getChordType(typeName);\n const tonic = note(optionalTonic || \"\");\n const root = note(optionalRoot || \"\");\n\n if (\n type.empty ||\n (optionalTonic && tonic.empty) ||\n (optionalRoot && root.empty)\n ) {\n return NoChord;\n }\n\n const rootInterval = distance(tonic.pc, root.pc);\n const rootDegree = type.intervals.indexOf(rootInterval) + 1;\n if (!root.empty && !rootDegree) {\n return NoChord;\n }\n\n const intervals = Array.from(type.intervals);\n\n for (let i = 1; i < rootDegree; i++) {\n const num = intervals[0][0];\n const quality = intervals[0][1];\n const newNum = parseInt(num, 10) + 7;\n intervals.push(`${newNum}${quality}`);\n intervals.shift();\n }\n\n const notes = tonic.empty\n ? []\n : intervals.map((i) => transposeNote(tonic, i));\n\n typeName = type.aliases.indexOf(typeName) !== -1 ? typeName : type.aliases[0];\n const symbol = `${tonic.empty ? \"\" : tonic.pc}${typeName}${\n root.empty || rootDegree <= 1 ? \"\" : \"/\" + root.pc\n }`;\n const name = `${optionalTonic ? tonic.pc + \" \" : \"\"}${type.name}${\n rootDegree > 1 && optionalRoot ? \" over \" + root.pc : \"\"\n }`;\n return {\n ...type,\n name,\n symbol,\n type: type.name,\n root: root.name,\n intervals,\n rootDegree,\n tonic: tonic.name,\n notes,\n };\n}\n\nexport const chord = deprecate(\"Chord.chord\", \"Chord.get\", get);\n\n/**\n * Transpose a chord name\n *\n * @param {string} chordName - the chord name\n * @return {string} the transposed chord\n *\n * @example\n * transpose('Dm7', 'P4') // => 'Gm7\n */\nexport function transpose(chordName: string, interval: string): string {\n const [tonic, type] = tokenize(chordName);\n if (!tonic) {\n return chordName;\n }\n return transposeNote(tonic, interval) + type;\n}\n\n/**\n * Get all scales where the given chord fits\n *\n * @example\n * chordScales('C7b9')\n * // => [\"phrygian dominant\", \"flamenco\", \"spanish heptatonic\", \"half-whole diminished\", \"chromatic\"]\n */\nexport function chordScales(name: string): string[] {\n const s = get(name);\n const isChordIncluded = isSupersetOf(s.chroma);\n return scaleTypes()\n .filter((scale) => isChordIncluded(scale.chroma))\n .map((scale) => scale.name);\n}\n/**\n * Get all chords names that are a superset of the given one\n * (has the same notes and at least one more)\n *\n * @function\n * @example\n * extended(\"CMaj7\")\n * // => [ 'Cmaj#4', 'Cmaj7#9#11', 'Cmaj9', 'CM7add13', 'Cmaj13', 'Cmaj9#11', 'CM13#11', 'CM7b9' ]\n */\nexport function extended(chordName: string): string[] {\n const s = get(chordName);\n const isSuperset = isSupersetOf(s.chroma);\n return chordTypes()\n .filter((chord) => isSuperset(chord.chroma))\n .map((chord) => s.tonic + chord.aliases[0]);\n}\n\n/**\n * Find all chords names that are a subset of the given one\n * (has less notes but all from the given chord)\n *\n * @example\n */\nexport function reduced(chordName: string): string[] {\n const s = get(chordName);\n const isSubset = isSubsetOf(s.chroma);\n return chordTypes()\n .filter((chord) => isSubset(chord.chroma))\n .map((chord) => s.tonic + chord.aliases[0]);\n}\n\nexport default {\n getChord,\n get,\n detect,\n chordScales,\n extended,\n reduced,\n tokenize,\n transpose,\n // deprecate\n chord,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAuB;AACvB,wBAIO;AAEP,kBAOO;AAEP,mBAAyC;AAEzC,wBAAkC;AAClC,IAAAA,uBAAuB;AAcvB,IAAM,UAAiB;AAAA,EACrB,OAAO;AAAA,EACP,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,MAAM;AAAA,EACN,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,SAAS,CAAC;AAAA,EACV,OAAO,CAAC;AAAA,EACR,WAAW,CAAC;AACd;AAIA,IAAM,YAAY;AAiBX,SAAS,SAAS,MAA+B;AACtD,QAAM,CAAC,QAAQ,KAAK,KAAK,IAAI,QAAI,0BAAa,IAAI;AAClD,MAAI,WAAW,IAAI;AACjB,WAAO,CAAC,IAAI,IAAI;AAAA,EAClB;AAEA,MAAI,WAAW,OAAO,SAAS,MAAM;AACnC,WAAO,CAAC,IAAI,KAAK;AAAA,EACnB;AAEA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;AAQO,SAAS,QAAQ,WAA6B;AACnD,QAAM,IAAI,IAAI,SAAS;AACvB,QAAM,eAAW,yBAAW,EAAE,MAAM;AACpC,aAAO,kBAAAI,KAAW,EACf,OAAO,CAACJ,WAAU,SAASA,OAAM,MAAM,CAAC,EACxC,IAAI,CAACA,WAAU,EAAE,QAAQA,OAAM,QAAQ,EAAE;AAC9C;AAEA,IAAO,gBAAQ;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AACF;","names":["import_chord_detect","chord","getChordType","transposeNote","scaleTypes","chordTypes"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
// index.ts
|
|
2
|
+
import { detect } from "@tonaljs/chord-detect";
|
|
3
|
+
import {
|
|
4
|
+
all as chordTypes,
|
|
5
|
+
get as getChordType
|
|
6
|
+
} from "@tonaljs/chord-type";
|
|
7
|
+
import {
|
|
8
|
+
deprecate,
|
|
9
|
+
distance,
|
|
10
|
+
note,
|
|
11
|
+
tokenizeNote,
|
|
12
|
+
transpose as transposeNote
|
|
13
|
+
} from "@tonaljs/core";
|
|
14
|
+
import { isSubsetOf, isSupersetOf } from "@tonaljs/pcset";
|
|
15
|
+
import { all as scaleTypes } from "@tonaljs/scale-type";
|
|
16
|
+
import { detect as detect2 } from "@tonaljs/chord-detect";
|
|
17
|
+
var NoChord = {
|
|
18
|
+
empty: true,
|
|
19
|
+
name: "",
|
|
20
|
+
symbol: "",
|
|
21
|
+
root: "",
|
|
22
|
+
rootDegree: 0,
|
|
23
|
+
type: "",
|
|
24
|
+
tonic: null,
|
|
25
|
+
setNum: NaN,
|
|
26
|
+
quality: "Unknown",
|
|
27
|
+
chroma: "",
|
|
28
|
+
normalized: "",
|
|
29
|
+
aliases: [],
|
|
30
|
+
notes: [],
|
|
31
|
+
intervals: []
|
|
32
|
+
};
|
|
33
|
+
var NUM_TYPES = /^(6|64|7|9|11|13)$/;
|
|
34
|
+
function tokenize(name) {
|
|
35
|
+
const [letter, acc, oct, type] = tokenizeNote(name);
|
|
36
|
+
if (letter === "") {
|
|
37
|
+
return ["", name];
|
|
38
|
+
}
|
|
39
|
+
if (letter === "A" && type === "ug") {
|
|
40
|
+
return ["", "aug"];
|
|
41
|
+
}
|
|
42
|
+
if (!type && (oct === "4" || oct === "5")) {
|
|
43
|
+
return [letter + acc, oct];
|
|
44
|
+
}
|
|
45
|
+
if (NUM_TYPES.test(oct)) {
|
|
46
|
+
return [letter + acc, oct + type];
|
|
47
|
+
} else {
|
|
48
|
+
return [letter + acc + oct, type];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function get(src) {
|
|
52
|
+
if (src === "") {
|
|
53
|
+
return NoChord;
|
|
54
|
+
}
|
|
55
|
+
if (Array.isArray(src) && src.length === 2) {
|
|
56
|
+
return getChord(src[1], src[0]);
|
|
57
|
+
} else {
|
|
58
|
+
const [tonic, type] = tokenize(src);
|
|
59
|
+
const chord2 = getChord(type, tonic);
|
|
60
|
+
return chord2.empty ? getChord(src) : chord2;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function getChord(typeName, optionalTonic, optionalRoot) {
|
|
64
|
+
const type = getChordType(typeName);
|
|
65
|
+
const tonic = note(optionalTonic || "");
|
|
66
|
+
const root = note(optionalRoot || "");
|
|
67
|
+
if (type.empty || optionalTonic && tonic.empty || optionalRoot && root.empty) {
|
|
68
|
+
return NoChord;
|
|
69
|
+
}
|
|
70
|
+
const rootInterval = distance(tonic.pc, root.pc);
|
|
71
|
+
const rootDegree = type.intervals.indexOf(rootInterval) + 1;
|
|
72
|
+
if (!root.empty && !rootDegree) {
|
|
73
|
+
return NoChord;
|
|
74
|
+
}
|
|
75
|
+
const intervals = Array.from(type.intervals);
|
|
76
|
+
for (let i = 1; i < rootDegree; i++) {
|
|
77
|
+
const num = intervals[0][0];
|
|
78
|
+
const quality = intervals[0][1];
|
|
79
|
+
const newNum = parseInt(num, 10) + 7;
|
|
80
|
+
intervals.push(`${newNum}${quality}`);
|
|
81
|
+
intervals.shift();
|
|
82
|
+
}
|
|
83
|
+
const notes = tonic.empty ? [] : intervals.map((i) => transposeNote(tonic, i));
|
|
84
|
+
typeName = type.aliases.indexOf(typeName) !== -1 ? typeName : type.aliases[0];
|
|
85
|
+
const symbol = `${tonic.empty ? "" : tonic.pc}${typeName}${root.empty || rootDegree <= 1 ? "" : "/" + root.pc}`;
|
|
86
|
+
const name = `${optionalTonic ? tonic.pc + " " : ""}${type.name}${rootDegree > 1 && optionalRoot ? " over " + root.pc : ""}`;
|
|
87
|
+
return {
|
|
88
|
+
...type,
|
|
89
|
+
name,
|
|
90
|
+
symbol,
|
|
91
|
+
type: type.name,
|
|
92
|
+
root: root.name,
|
|
93
|
+
intervals,
|
|
94
|
+
rootDegree,
|
|
95
|
+
tonic: tonic.name,
|
|
96
|
+
notes
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
var chord = deprecate("Chord.chord", "Chord.get", get);
|
|
100
|
+
function transpose(chordName, interval) {
|
|
101
|
+
const [tonic, type] = tokenize(chordName);
|
|
102
|
+
if (!tonic) {
|
|
103
|
+
return chordName;
|
|
104
|
+
}
|
|
105
|
+
return transposeNote(tonic, interval) + type;
|
|
106
|
+
}
|
|
107
|
+
function chordScales(name) {
|
|
108
|
+
const s = get(name);
|
|
109
|
+
const isChordIncluded = isSupersetOf(s.chroma);
|
|
110
|
+
return scaleTypes().filter((scale) => isChordIncluded(scale.chroma)).map((scale) => scale.name);
|
|
111
|
+
}
|
|
112
|
+
function extended(chordName) {
|
|
113
|
+
const s = get(chordName);
|
|
114
|
+
const isSuperset = isSupersetOf(s.chroma);
|
|
115
|
+
return chordTypes().filter((chord2) => isSuperset(chord2.chroma)).map((chord2) => s.tonic + chord2.aliases[0]);
|
|
116
|
+
}
|
|
117
|
+
function reduced(chordName) {
|
|
118
|
+
const s = get(chordName);
|
|
119
|
+
const isSubset = isSubsetOf(s.chroma);
|
|
120
|
+
return chordTypes().filter((chord2) => isSubset(chord2.chroma)).map((chord2) => s.tonic + chord2.aliases[0]);
|
|
121
|
+
}
|
|
122
|
+
var chord_default = {
|
|
123
|
+
getChord,
|
|
124
|
+
get,
|
|
125
|
+
detect,
|
|
126
|
+
chordScales,
|
|
127
|
+
extended,
|
|
128
|
+
reduced,
|
|
129
|
+
tokenize,
|
|
130
|
+
transpose,
|
|
131
|
+
chord
|
|
132
|
+
};
|
|
133
|
+
export {
|
|
134
|
+
chord,
|
|
135
|
+
chordScales,
|
|
136
|
+
chord_default as default,
|
|
137
|
+
detect2 as detect,
|
|
138
|
+
extended,
|
|
139
|
+
get,
|
|
140
|
+
getChord,
|
|
141
|
+
reduced,
|
|
142
|
+
tokenize,
|
|
143
|
+
transpose
|
|
144
|
+
};
|
|
145
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../index.ts"],"sourcesContent":["import { detect } from \"@tonaljs/chord-detect\";\nimport {\n all as chordTypes,\n ChordType,\n get as getChordType,\n} from \"@tonaljs/chord-type\";\n\nimport {\n deprecate,\n distance,\n note,\n NoteName,\n tokenizeNote,\n transpose as transposeNote,\n} from \"@tonaljs/core\";\n\nimport { isSubsetOf, isSupersetOf } from \"@tonaljs/pcset\";\n\nimport { all as scaleTypes } from \"@tonaljs/scale-type\";\nexport { detect } from \"@tonaljs/chord-detect\";\n\ntype ChordName = string;\ntype ChordNameTokens = [string, string]; // [TONIC, SCALE TYPE]\n\nexport interface Chord extends ChordType {\n tonic: string | null;\n type: string;\n root: string;\n rootDegree: number;\n symbol: string;\n notes: NoteName[];\n}\n\nconst NoChord: Chord = {\n empty: true,\n name: \"\",\n symbol: \"\",\n root: \"\",\n rootDegree: 0,\n type: \"\",\n tonic: null,\n setNum: NaN,\n quality: \"Unknown\",\n chroma: \"\",\n normalized: \"\",\n aliases: [],\n notes: [],\n intervals: [],\n};\n\n// 6, 64, 7, 9, 11 and 13 are consider part of the chord\n// (see https://github.com/danigb/tonal/issues/55)\nconst NUM_TYPES = /^(6|64|7|9|11|13)$/;\n/**\n * Tokenize a chord name. It returns an array with the tonic and chord type\n * If not tonic is found, all the name is considered the chord name.\n *\n * This function does NOT check if the chord type exists or not. It only tries\n * to split the tonic and chord type.\n *\n * @function\n * @param {string} name - the chord name\n * @return {Array} an array with [tonic, type]\n * @example\n * tokenize(\"Cmaj7\") // => [ \"C\", \"maj7\" ]\n * tokenize(\"C7\") // => [ \"C\", \"7\" ]\n * tokenize(\"mMaj7\") // => [ null, \"mMaj7\" ]\n * tokenize(\"Cnonsense\") // => [ null, \"nonsense\" ]\n */\nexport function tokenize(name: string): ChordNameTokens {\n const [letter, acc, oct, type] = tokenizeNote(name);\n if (letter === \"\") {\n return [\"\", name];\n }\n // aug is augmented (see https://github.com/danigb/tonal/issues/55)\n if (letter === \"A\" && type === \"ug\") {\n return [\"\", \"aug\"];\n }\n // see: https://github.com/tonaljs/tonal/issues/70\n if (!type && (oct === \"4\" || oct === \"5\")) {\n return [letter + acc, oct];\n }\n\n if (NUM_TYPES.test(oct)) {\n return [letter + acc, oct + type];\n } else {\n return [letter + acc + oct, type];\n }\n}\n\n/**\n * Get a Chord from a chord name.\n */\nexport function get(src: ChordName | ChordNameTokens): Chord {\n if (src === \"\") {\n return NoChord;\n }\n if (Array.isArray(src) && src.length === 2) {\n return getChord(src[1], src[0]);\n } else {\n const [tonic, type] = tokenize(src);\n const chord = getChord(type, tonic);\n return chord.empty ? getChord(src) : chord;\n }\n}\n\n/**\n * Get chord properties\n *\n * @param typeName - the chord type name\n * @param [tonic] - Optional tonic\n * @param [root] - Optional root (requires a tonic)\n */\nexport function getChord(\n typeName: string,\n optionalTonic?: string,\n optionalRoot?: string\n): Chord {\n const type = getChordType(typeName);\n const tonic = note(optionalTonic || \"\");\n const root = note(optionalRoot || \"\");\n\n if (\n type.empty ||\n (optionalTonic && tonic.empty) ||\n (optionalRoot && root.empty)\n ) {\n return NoChord;\n }\n\n const rootInterval = distance(tonic.pc, root.pc);\n const rootDegree = type.intervals.indexOf(rootInterval) + 1;\n if (!root.empty && !rootDegree) {\n return NoChord;\n }\n\n const intervals = Array.from(type.intervals);\n\n for (let i = 1; i < rootDegree; i++) {\n const num = intervals[0][0];\n const quality = intervals[0][1];\n const newNum = parseInt(num, 10) + 7;\n intervals.push(`${newNum}${quality}`);\n intervals.shift();\n }\n\n const notes = tonic.empty\n ? []\n : intervals.map((i) => transposeNote(tonic, i));\n\n typeName = type.aliases.indexOf(typeName) !== -1 ? typeName : type.aliases[0];\n const symbol = `${tonic.empty ? \"\" : tonic.pc}${typeName}${\n root.empty || rootDegree <= 1 ? \"\" : \"/\" + root.pc\n }`;\n const name = `${optionalTonic ? tonic.pc + \" \" : \"\"}${type.name}${\n rootDegree > 1 && optionalRoot ? \" over \" + root.pc : \"\"\n }`;\n return {\n ...type,\n name,\n symbol,\n type: type.name,\n root: root.name,\n intervals,\n rootDegree,\n tonic: tonic.name,\n notes,\n };\n}\n\nexport const chord = deprecate(\"Chord.chord\", \"Chord.get\", get);\n\n/**\n * Transpose a chord name\n *\n * @param {string} chordName - the chord name\n * @return {string} the transposed chord\n *\n * @example\n * transpose('Dm7', 'P4') // => 'Gm7\n */\nexport function transpose(chordName: string, interval: string): string {\n const [tonic, type] = tokenize(chordName);\n if (!tonic) {\n return chordName;\n }\n return transposeNote(tonic, interval) + type;\n}\n\n/**\n * Get all scales where the given chord fits\n *\n * @example\n * chordScales('C7b9')\n * // => [\"phrygian dominant\", \"flamenco\", \"spanish heptatonic\", \"half-whole diminished\", \"chromatic\"]\n */\nexport function chordScales(name: string): string[] {\n const s = get(name);\n const isChordIncluded = isSupersetOf(s.chroma);\n return scaleTypes()\n .filter((scale) => isChordIncluded(scale.chroma))\n .map((scale) => scale.name);\n}\n/**\n * Get all chords names that are a superset of the given one\n * (has the same notes and at least one more)\n *\n * @function\n * @example\n * extended(\"CMaj7\")\n * // => [ 'Cmaj#4', 'Cmaj7#9#11', 'Cmaj9', 'CM7add13', 'Cmaj13', 'Cmaj9#11', 'CM13#11', 'CM7b9' ]\n */\nexport function extended(chordName: string): string[] {\n const s = get(chordName);\n const isSuperset = isSupersetOf(s.chroma);\n return chordTypes()\n .filter((chord) => isSuperset(chord.chroma))\n .map((chord) => s.tonic + chord.aliases[0]);\n}\n\n/**\n * Find all chords names that are a subset of the given one\n * (has less notes but all from the given chord)\n *\n * @example\n */\nexport function reduced(chordName: string): string[] {\n const s = get(chordName);\n const isSubset = isSubsetOf(s.chroma);\n return chordTypes()\n .filter((chord) => isSubset(chord.chroma))\n .map((chord) => s.tonic + chord.aliases[0]);\n}\n\nexport default {\n getChord,\n get,\n detect,\n chordScales,\n extended,\n reduced,\n tokenize,\n transpose,\n // deprecate\n chord,\n};\n"],"mappings":";AAAA,SAAS,cAAc;AACvB;AAAA,EACE,OAAO;AAAA,EAEP,OAAO;AAAA,OACF;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA,aAAa;AAAA,OACR;AAEP,SAAS,YAAY,oBAAoB;AAEzC,SAAS,OAAO,kBAAkB;AAClC,SAAS,UAAAA,eAAc;AAcvB,IAAM,UAAiB;AAAA,EACrB,OAAO;AAAA,EACP,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,MAAM;AAAA,EACN,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,SAAS,CAAC;AAAA,EACV,OAAO,CAAC;AAAA,EACR,WAAW,CAAC;AACd;AAIA,IAAM,YAAY;AAiBX,SAAS,SAAS,MAA+B;AACtD,QAAM,CAAC,QAAQ,KAAK,KAAK,IAAI,IAAI,aAAa,IAAI;AAClD,MAAI,WAAW,IAAI;AACjB,WAAO,CAAC,IAAI,IAAI;AAAA,EAClB;AAEA,MAAI,WAAW,OAAO,SAAS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C9C;AAQO,SAAS,QAAQ,WAA6B;AACnD,QAAM,IAAI,IAAI,SAAS;AACvB,QAAM,WAAW,WAAW,EAAE,MAAM;AACpC,SAAO,WAAW,EACf,OAAO,CAACA,WAAU,SAASA,OAAM,MAAM,CAAC,EACxC,IAAI,CAACA,WAAU,EAAE,QAAQA,OAAM,QAAQ,EAAE;AAC9C;AAEA,IAAO,gBAAQ;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AACF;","names":["detect","chord"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tonaljs/chord",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.7.0",
|
|
4
4
|
"description": "Musical chords and its relations",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"chord",
|
|
@@ -10,23 +10,25 @@
|
|
|
10
10
|
"@tonaljs"
|
|
11
11
|
],
|
|
12
12
|
"main": "dist/index.js",
|
|
13
|
-
"module": "dist/index.
|
|
13
|
+
"module": "dist/index.mjs",
|
|
14
14
|
"files": [
|
|
15
15
|
"dist"
|
|
16
16
|
],
|
|
17
17
|
"types": "dist/index.d.ts",
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@tonaljs/chord-detect": "^4.
|
|
20
|
-
"@tonaljs/chord-type": "^4.
|
|
21
|
-
"@tonaljs/collection": "^4.
|
|
22
|
-
"@tonaljs/core": "^4.6.
|
|
23
|
-
"@tonaljs/pcset": "^4.
|
|
24
|
-
"@tonaljs/scale-type": "^4.
|
|
19
|
+
"@tonaljs/chord-detect": "^4.7.0",
|
|
20
|
+
"@tonaljs/chord-type": "^4.7.0",
|
|
21
|
+
"@tonaljs/collection": "^4.7.0",
|
|
22
|
+
"@tonaljs/core": "^4.6.11",
|
|
23
|
+
"@tonaljs/pcset": "^4.7.0",
|
|
24
|
+
"@tonaljs/scale-type": "^4.7.0"
|
|
25
25
|
},
|
|
26
26
|
"author": "danigb@gmail.com",
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"publishConfig": {
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
|
-
"
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsup index.ts --sourcemap --dts --format esm,cjs"
|
|
33
|
+
}
|
|
32
34
|
}
|
package/dist/index.es.js
DELETED
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
import { detect } from '@tonaljs/chord-detect';
|
|
2
|
-
export { detect } from '@tonaljs/chord-detect';
|
|
3
|
-
import { get as get$1, all as all$1 } from '@tonaljs/chord-type';
|
|
4
|
-
import { deprecate, tokenizeNote, note, distance, transpose as transpose$1 } from '@tonaljs/core';
|
|
5
|
-
import { isSupersetOf, isSubsetOf } from '@tonaljs/pcset';
|
|
6
|
-
import { all } from '@tonaljs/scale-type';
|
|
7
|
-
|
|
8
|
-
const NoChord = {
|
|
9
|
-
empty: true,
|
|
10
|
-
name: "",
|
|
11
|
-
symbol: "",
|
|
12
|
-
root: "",
|
|
13
|
-
rootDegree: 0,
|
|
14
|
-
type: "",
|
|
15
|
-
tonic: null,
|
|
16
|
-
setNum: NaN,
|
|
17
|
-
quality: "Unknown",
|
|
18
|
-
chroma: "",
|
|
19
|
-
normalized: "",
|
|
20
|
-
aliases: [],
|
|
21
|
-
notes: [],
|
|
22
|
-
intervals: [],
|
|
23
|
-
};
|
|
24
|
-
// 6, 64, 7, 9, 11 and 13 are consider part of the chord
|
|
25
|
-
// (see https://github.com/danigb/tonal/issues/55)
|
|
26
|
-
const NUM_TYPES = /^(6|64|7|9|11|13)$/;
|
|
27
|
-
/**
|
|
28
|
-
* Tokenize a chord name. It returns an array with the tonic and chord type
|
|
29
|
-
* If not tonic is found, all the name is considered the chord name.
|
|
30
|
-
*
|
|
31
|
-
* This function does NOT check if the chord type exists or not. It only tries
|
|
32
|
-
* to split the tonic and chord type.
|
|
33
|
-
*
|
|
34
|
-
* @function
|
|
35
|
-
* @param {string} name - the chord name
|
|
36
|
-
* @return {Array} an array with [tonic, type]
|
|
37
|
-
* @example
|
|
38
|
-
* tokenize("Cmaj7") // => [ "C", "maj7" ]
|
|
39
|
-
* tokenize("C7") // => [ "C", "7" ]
|
|
40
|
-
* tokenize("mMaj7") // => [ null, "mMaj7" ]
|
|
41
|
-
* tokenize("Cnonsense") // => [ null, "nonsense" ]
|
|
42
|
-
*/
|
|
43
|
-
function tokenize(name) {
|
|
44
|
-
const [letter, acc, oct, type] = tokenizeNote(name);
|
|
45
|
-
if (letter === "") {
|
|
46
|
-
return ["", name];
|
|
47
|
-
}
|
|
48
|
-
// aug is augmented (see https://github.com/danigb/tonal/issues/55)
|
|
49
|
-
if (letter === "A" && type === "ug") {
|
|
50
|
-
return ["", "aug"];
|
|
51
|
-
}
|
|
52
|
-
// see: https://github.com/tonaljs/tonal/issues/70
|
|
53
|
-
if (!type && (oct === "4" || oct === "5")) {
|
|
54
|
-
return [letter + acc, oct];
|
|
55
|
-
}
|
|
56
|
-
if (NUM_TYPES.test(oct)) {
|
|
57
|
-
return [letter + acc, oct + type];
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
return [letter + acc + oct, type];
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Get a Chord from a chord name.
|
|
65
|
-
*/
|
|
66
|
-
function get(src) {
|
|
67
|
-
if (src === "") {
|
|
68
|
-
return NoChord;
|
|
69
|
-
}
|
|
70
|
-
if (Array.isArray(src) && src.length === 2) {
|
|
71
|
-
return getChord(src[1], src[0]);
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
const [tonic, type] = tokenize(src);
|
|
75
|
-
const chord = getChord(type, tonic);
|
|
76
|
-
return chord.empty ? getChord(src) : chord;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Get chord properties
|
|
81
|
-
*
|
|
82
|
-
* @param typeName - the chord type name
|
|
83
|
-
* @param [tonic] - Optional tonic
|
|
84
|
-
* @param [root] - Optional root (requires a tonic)
|
|
85
|
-
*/
|
|
86
|
-
function getChord(typeName, optionalTonic, optionalRoot) {
|
|
87
|
-
const type = get$1(typeName);
|
|
88
|
-
const tonic = note(optionalTonic || "");
|
|
89
|
-
const root = note(optionalRoot || "");
|
|
90
|
-
if (type.empty ||
|
|
91
|
-
(optionalTonic && tonic.empty) ||
|
|
92
|
-
(optionalRoot && root.empty)) {
|
|
93
|
-
return NoChord;
|
|
94
|
-
}
|
|
95
|
-
const rootInterval = distance(tonic.pc, root.pc);
|
|
96
|
-
const rootDegree = type.intervals.indexOf(rootInterval) + 1;
|
|
97
|
-
if (!root.empty && !rootDegree) {
|
|
98
|
-
return NoChord;
|
|
99
|
-
}
|
|
100
|
-
const intervals = Array.from(type.intervals);
|
|
101
|
-
for (let i = 1; i < rootDegree; i++) {
|
|
102
|
-
const num = intervals[0][0];
|
|
103
|
-
const quality = intervals[0][1];
|
|
104
|
-
const newNum = parseInt(num, 10) + 7;
|
|
105
|
-
intervals.push(`${newNum}${quality}`);
|
|
106
|
-
intervals.shift();
|
|
107
|
-
}
|
|
108
|
-
const notes = tonic.empty
|
|
109
|
-
? []
|
|
110
|
-
: intervals.map((i) => transpose$1(tonic, i));
|
|
111
|
-
typeName = type.aliases.indexOf(typeName) !== -1 ? typeName : type.aliases[0];
|
|
112
|
-
const symbol = `${tonic.empty ? "" : tonic.pc}${typeName}${root.empty || rootDegree <= 1 ? "" : "/" + root.pc}`;
|
|
113
|
-
const name = `${optionalTonic ? tonic.pc + " " : ""}${type.name}${rootDegree > 1 && optionalRoot ? " over " + root.pc : ""}`;
|
|
114
|
-
return {
|
|
115
|
-
...type,
|
|
116
|
-
name,
|
|
117
|
-
symbol,
|
|
118
|
-
type: type.name,
|
|
119
|
-
root: root.name,
|
|
120
|
-
intervals,
|
|
121
|
-
rootDegree,
|
|
122
|
-
tonic: tonic.name,
|
|
123
|
-
notes,
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
const chord = deprecate("Chord.chord", "Chord.get", get);
|
|
127
|
-
/**
|
|
128
|
-
* Transpose a chord name
|
|
129
|
-
*
|
|
130
|
-
* @param {string} chordName - the chord name
|
|
131
|
-
* @return {string} the transposed chord
|
|
132
|
-
*
|
|
133
|
-
* @example
|
|
134
|
-
* transpose('Dm7', 'P4') // => 'Gm7
|
|
135
|
-
*/
|
|
136
|
-
function transpose(chordName, interval) {
|
|
137
|
-
const [tonic, type] = tokenize(chordName);
|
|
138
|
-
if (!tonic) {
|
|
139
|
-
return chordName;
|
|
140
|
-
}
|
|
141
|
-
return transpose$1(tonic, interval) + type;
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Get all scales where the given chord fits
|
|
145
|
-
*
|
|
146
|
-
* @example
|
|
147
|
-
* chordScales('C7b9')
|
|
148
|
-
* // => ["phrygian dominant", "flamenco", "spanish heptatonic", "half-whole diminished", "chromatic"]
|
|
149
|
-
*/
|
|
150
|
-
function chordScales(name) {
|
|
151
|
-
const s = get(name);
|
|
152
|
-
const isChordIncluded = isSupersetOf(s.chroma);
|
|
153
|
-
return all()
|
|
154
|
-
.filter((scale) => isChordIncluded(scale.chroma))
|
|
155
|
-
.map((scale) => scale.name);
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Get all chords names that are a superset of the given one
|
|
159
|
-
* (has the same notes and at least one more)
|
|
160
|
-
*
|
|
161
|
-
* @function
|
|
162
|
-
* @example
|
|
163
|
-
* extended("CMaj7")
|
|
164
|
-
* // => [ 'Cmaj#4', 'Cmaj7#9#11', 'Cmaj9', 'CM7add13', 'Cmaj13', 'Cmaj9#11', 'CM13#11', 'CM7b9' ]
|
|
165
|
-
*/
|
|
166
|
-
function extended(chordName) {
|
|
167
|
-
const s = get(chordName);
|
|
168
|
-
const isSuperset = isSupersetOf(s.chroma);
|
|
169
|
-
return all$1()
|
|
170
|
-
.filter((chord) => isSuperset(chord.chroma))
|
|
171
|
-
.map((chord) => s.tonic + chord.aliases[0]);
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Find all chords names that are a subset of the given one
|
|
175
|
-
* (has less notes but all from the given chord)
|
|
176
|
-
*
|
|
177
|
-
* @example
|
|
178
|
-
*/
|
|
179
|
-
function reduced(chordName) {
|
|
180
|
-
const s = get(chordName);
|
|
181
|
-
const isSubset = isSubsetOf(s.chroma);
|
|
182
|
-
return all$1()
|
|
183
|
-
.filter((chord) => isSubset(chord.chroma))
|
|
184
|
-
.map((chord) => s.tonic + chord.aliases[0]);
|
|
185
|
-
}
|
|
186
|
-
var index = {
|
|
187
|
-
getChord,
|
|
188
|
-
get,
|
|
189
|
-
detect,
|
|
190
|
-
chordScales,
|
|
191
|
-
extended,
|
|
192
|
-
reduced,
|
|
193
|
-
tokenize,
|
|
194
|
-
transpose,
|
|
195
|
-
// deprecate
|
|
196
|
-
chord,
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
export { chord, chordScales, index as default, extended, get, getChord, reduced, tokenize, transpose };
|
|
200
|
-
//# sourceMappingURL=index.es.js.map
|
package/dist/index.es.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|