-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbundle.js
More file actions
3806 lines (3618 loc) · 132 KB
/
bundle.js
File metadata and controls
3806 lines (3618 loc) · 132 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tonaljs/core')) :
typeof define === 'function' && define.amd ? define(['exports', '@tonaljs/core'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.AbcNotation = {}, global.core));
}(this, (function (exports, core) { 'use strict';
var fillStr = function (character, times) {
return Array(times + 1).join(character);
};
var REGEX = /^(_{1,}|=|\^{1,}|)([abcdefgABCDEFG])([,']*)$/;
function tokenize(str) {
var m = REGEX.exec(str);
if (!m) {
return ["", "", ""];
}
return [m[1], m[2], m[3]];
}
/**
* Convert a (string) note in ABC notation into a (string) note in scientific notation
*
* @example
* abcToScientificNotation("c") // => "C5"
*/
function abcToScientificNotation(str) {
var _a = tokenize(str), acc = _a[0], letter = _a[1], oct = _a[2];
if (letter === "") {
return "";
}
var o = 4;
for (var i = 0; i < oct.length; i++) {
o += oct.charAt(i) === "," ? -1 : 1;
}
var a = acc[0] === "_"
? acc.replace(/_/g, "b")
: acc[0] === "^"
? acc.replace(/\^/g, "#")
: "";
return letter.charCodeAt(0) > 96
? letter.toUpperCase() + a + (o + 1)
: letter + a + o;
}
/**
* Convert a (string) note in scientific notation into a (string) note in ABC notation
*
* @example
* scientificToAbcNotation("C#4") // => "^C"
*/
function scientificToAbcNotation(str) {
var n = core.note(str);
if (n.empty || !n.oct) {
return "";
}
var letter = n.letter, acc = n.acc, oct = n.oct;
var a = acc[0] === "b" ? acc.replace(/b/g, "_") : acc.replace(/#/g, "^");
var l = oct > 4 ? letter.toLowerCase() : letter;
var o = oct === 5 ? "" : oct > 4 ? fillStr("'", oct - 5) : fillStr(",", 4 - oct);
return a + l + o;
}
function transpose(note, interval) {
return scientificToAbcNotation(core.transpose(abcToScientificNotation(note), interval));
}
function distance(from, to) {
return core.distance(abcToScientificNotation(from), abcToScientificNotation(to));
}
var index = {
abcToScientificNotation: abcToScientificNotation,
scientificToAbcNotation: scientificToAbcNotation,
tokenize: tokenize,
transpose: transpose,
distance: distance,
};
exports.abcToScientificNotation = abcToScientificNotation;
exports.default = index;
exports.distance = distance;
exports.scientificToAbcNotation = scientificToAbcNotation;
exports.tokenize = tokenize;
exports.transpose = transpose;
Object.defineProperty(exports, '__esModule', { value: true });
})));
},{"@tonaljs/core":7}],2:[function(require,module,exports){
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tonaljs/core')) :
typeof define === 'function' && define.amd ? define(['exports', '@tonaljs/core'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Array = {}, global.core));
}(this, (function (exports, core) { 'use strict';
// ascending range
function ascR(b, n) {
var a = [];
// tslint:disable-next-line:curly
for (; n--; a[n] = n + b)
;
return a;
}
// descending range
function descR(b, n) {
var a = [];
// tslint:disable-next-line:curly
for (; n--; a[n] = b - n)
;
return a;
}
/**
* Creates a numeric range
*
* @param {number} from
* @param {number} to
* @return {Array<number>}
*
* @example
* range(-2, 2) // => [-2, -1, 0, 1, 2]
* range(2, -2) // => [2, 1, 0, -1, -2]
*/
function range(from, to) {
return from < to ? ascR(from, to - from + 1) : descR(from, from - to + 1);
}
/**
* Rotates a list a number of times. It"s completly agnostic about the
* contents of the list.
*
* @param {Integer} times - the number of rotations
* @param {Array} array
* @return {Array} the rotated array
*
* @example
* rotate(1, [1, 2, 3]) // => [2, 3, 1]
*/
function rotate(times, arr) {
var len = arr.length;
var n = ((times % len) + len) % len;
return arr.slice(n, len).concat(arr.slice(0, n));
}
/**
* Return a copy of the array with the null values removed
* @function
* @param {Array} array
* @return {Array}
*
* @example
* compact(["a", "b", null, "c"]) // => ["a", "b", "c"]
*/
function compact(arr) {
return arr.filter(function (n) { return n === 0 || n; });
}
/**
* Sort an array of notes in ascending order. Pitch classes are listed
* before notes. Any string that is not a note is removed.
*
* @param {string[]} notes
* @return {string[]} sorted array of notes
*
* @example
* sortedNoteNames(['c2', 'c5', 'c1', 'c0', 'c6', 'c'])
* // => ['C', 'C0', 'C1', 'C2', 'C5', 'C6']
* sortedNoteNames(['c', 'F', 'G', 'a', 'b', 'h', 'J'])
* // => ['C', 'F', 'G', 'A', 'B']
*/
function sortedNoteNames(notes) {
var valid = notes.map(function (n) { return core.note(n); }).filter(function (n) { return !n.empty; });
return valid.sort(function (a, b) { return a.height - b.height; }).map(function (n) { return n.name; });
}
/**
* Get sorted notes with duplicates removed. Pitch classes are listed
* before notes.
*
* @function
* @param {string[]} array
* @return {string[]} unique sorted notes
*
* @example
* Array.sortedUniqNoteNames(['a', 'b', 'c2', '1p', 'p2', 'c2', 'b', 'c', 'c3' ])
* // => [ 'C', 'A', 'B', 'C2', 'C3' ]
*/
function sortedUniqNoteNames(arr) {
return sortedNoteNames(arr).filter(function (n, i, a) { return i === 0 || n !== a[i - 1]; });
}
/**
* Randomizes the order of the specified array in-place, using the Fisher–Yates shuffle.
*
* @function
* @param {Array} array
* @return {Array} the array shuffled
*
* @example
* shuffle(["C", "D", "E", "F"]) // => [...]
*/
function shuffle(arr, rnd) {
if (rnd === void 0) { rnd = Math.random; }
var i;
var t;
var m = arr.length;
while (m) {
i = Math.floor(rnd() * m--);
t = arr[m];
arr[m] = arr[i];
arr[i] = t;
}
return arr;
}
/**
* Get all permutations of an array
*
* @param {Array} array - the array
* @return {Array<Array>} an array with all the permutations
* @example
* permutations(["a", "b", "c"])) // =>
* [
* ["a", "b", "c"],
* ["b", "a", "c"],
* ["b", "c", "a"],
* ["a", "c", "b"],
* ["c", "a", "b"],
* ["c", "b", "a"]
* ]
*/
function permutations(arr) {
if (arr.length === 0) {
return [[]];
}
return permutations(arr.slice(1)).reduce(function (acc, perm) {
return acc.concat(arr.map(function (e, pos) {
var newPerm = perm.slice();
newPerm.splice(pos, 0, arr[0]);
return newPerm;
}));
}, []);
}
exports.compact = compact;
exports.permutations = permutations;
exports.range = range;
exports.rotate = rotate;
exports.shuffle = shuffle;
exports.sortedNoteNames = sortedNoteNames;
exports.sortedUniqNoteNames = sortedUniqNoteNames;
Object.defineProperty(exports, '__esModule', { value: true });
})));
},{"@tonaljs/core":7}],3:[function(require,module,exports){
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tonaljs/chord-type'), require('@tonaljs/core'), require('@tonaljs/pcset')) :
typeof define === 'function' && define.amd ? define(['exports', '@tonaljs/chord-type', '@tonaljs/core', '@tonaljs/pcset'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ChordDetect = {}, global.chordType, global.core, global.pcset));
}(this, (function (exports, chordType, core, pcset) { 'use strict';
var namedSet = function (notes) {
var pcToName = notes.reduce(function (record, n) {
var chroma = core.note(n).chroma;
if (chroma !== undefined) {
record[chroma] = record[chroma] || core.note(n).name;
}
return record;
}, {});
return function (chroma) { return pcToName[chroma]; };
};
function detect(source) {
var notes = source.map(function (n) { return core.note(n).pc; }).filter(function (x) { return x; });
if (core.note.length === 0) {
return [];
}
var found = findExactMatches(notes, 1);
return found
.filter(function (chord) { return chord.weight; })
.sort(function (a, b) { return b.weight - a.weight; })
.map(function (chord) { return chord.name; });
}
function findExactMatches(notes, weight) {
var tonic = notes[0];
var tonicChroma = core.note(tonic).chroma;
var noteName = namedSet(notes);
// we need to test all chormas to get the correct baseNote
var allModes = pcset.modes(notes, false);
var found = [];
allModes.forEach(function (mode, index) {
// some chords could have the same chroma but different interval spelling
var chordTypes = chordType.all().filter(function (chordType) { return chordType.chroma === mode; });
chordTypes.forEach(function (chordType) {
var chordName = chordType.aliases[0];
var baseNote = noteName(index);
var isInversion = index !== tonicChroma;
if (isInversion) {
found.push({
weight: 0.5 * weight,
name: "" + baseNote + chordName + "/" + tonic,
});
}
else {
found.push({ weight: 1 * weight, name: "" + baseNote + chordName });
}
});
});
return found;
}
var index = { detect: detect };
exports.default = index;
exports.detect = detect;
Object.defineProperty(exports, '__esModule', { value: true });
})));
},{"@tonaljs/chord-type":4,"@tonaljs/core":7,"@tonaljs/pcset":14}],4:[function(require,module,exports){
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tonaljs/core'), require('@tonaljs/pcset')) :
typeof define === 'function' && define.amd ? define(['exports', '@tonaljs/core', '@tonaljs/pcset'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ChordType = {}, global.core, global.pcset));
}(this, (function (exports, core, pcset) { 'use strict';
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
/**
* @private
* Chord List
* Source: https://en.wikibooks.org/wiki/Music_Theory/Complete_List_of_Chord_Patterns
* Format: ["intervals", "full name", "abrv1 abrv2"]
*/
var CHORDS = [
// ==Major==
["1P 3M 5P", "major", "M ^ "],
["1P 3M 5P 7M", "major seventh", "maj7 Δ ma7 M7 Maj7 ^7"],
["1P 3M 5P 7M 9M", "major ninth", "maj9 Δ9 ^9"],
["1P 3M 5P 7M 9M 13M", "major thirteenth", "maj13 Maj13 ^13"],
["1P 3M 5P 6M", "sixth", "6 add6 add13 M6"],
["1P 3M 5P 6M 9M", "sixth/ninth", "6/9 69 M69"],
["1P 3M 6m 7M", "major seventh flat sixth", "M7b6 ^7b6"],
[
"1P 3M 5P 7M 11A",
"major seventh sharp eleventh",
"maj#4 Δ#4 Δ#11 M7#11 ^7#11 maj7#11",
],
// ==Minor==
// '''Normal'''
["1P 3m 5P", "minor", "m min -"],
["1P 3m 5P 7m", "minor seventh", "m7 min7 mi7 -7"],
[
"1P 3m 5P 7M",
"minor/major seventh",
"m/ma7 m/maj7 mM7 mMaj7 m/M7 -Δ7 mΔ -^7",
],
["1P 3m 5P 6M", "minor sixth", "m6 -6"],
["1P 3m 5P 7m 9M", "minor ninth", "m9 -9"],
["1P 3m 5P 7M 9M", "minor/major ninth", "mM9 mMaj9 -^9"],
["1P 3m 5P 7m 9M 11P", "minor eleventh", "m11 -11"],
["1P 3m 5P 7m 9M 13M", "minor thirteenth", "m13 -13"],
// '''Diminished'''
["1P 3m 5d", "diminished", "dim ° o"],
["1P 3m 5d 7d", "diminished seventh", "dim7 °7 o7"],
["1P 3m 5d 7m", "half-diminished", "m7b5 ø -7b5 h7 h"],
// ==Dominant/Seventh==
// '''Normal'''
["1P 3M 5P 7m", "dominant seventh", "7 dom"],
["1P 3M 5P 7m 9M", "dominant ninth", "9"],
["1P 3M 5P 7m 9M 13M", "dominant thirteenth", "13"],
["1P 3M 5P 7m 11A", "lydian dominant seventh", "7#11 7#4"],
// '''Altered'''
["1P 3M 5P 7m 9m", "dominant flat ninth", "7b9"],
["1P 3M 5P 7m 9A", "dominant sharp ninth", "7#9"],
["1P 3M 7m 9m", "altered", "alt7"],
// '''Suspended'''
["1P 4P 5P", "suspended fourth", "sus4 sus"],
["1P 2M 5P", "suspended second", "sus2"],
["1P 4P 5P 7m", "suspended fourth seventh", "7sus4 7sus"],
["1P 5P 7m 9M 11P", "eleventh", "11"],
[
"1P 4P 5P 7m 9m",
"suspended fourth flat ninth",
"b9sus phryg 7b9sus 7b9sus4",
],
// ==Other==
["1P 5P", "fifth", "5"],
["1P 3M 5A", "augmented", "aug + +5 ^#5"],
["1P 3m 5A", "minor augmented", "m#5 -#5 m+"],
["1P 3M 5A 7M", "augmented seventh", "maj7#5 maj7+5 +maj7 ^7#5"],
[
"1P 3M 5P 7M 9M 11A",
"major sharp eleventh (lydian)",
"maj9#11 Δ9#11 ^9#11",
],
// ==Legacy==
["1P 2M 4P 5P", "", "sus24 sus4add9"],
["1P 3M 5A 7M 9M", "", "maj9#5 Maj9#5"],
["1P 3M 5A 7m", "", "7#5 +7 7+ 7aug aug7"],
["1P 3M 5A 7m 9A", "", "7#5#9 7#9#5 7alt"],
["1P 3M 5A 7m 9M", "", "9#5 9+"],
["1P 3M 5A 7m 9M 11A", "", "9#5#11"],
["1P 3M 5A 7m 9m", "", "7#5b9 7b9#5"],
["1P 3M 5A 7m 9m 11A", "", "7#5b9#11"],
["1P 3M 5A 9A", "", "+add#9"],
["1P 3M 5A 9M", "", "M#5add9 +add9"],
["1P 3M 5P 6M 11A", "", "M6#11 M6b5 6#11 6b5"],
["1P 3M 5P 6M 7M 9M", "", "M7add13"],
["1P 3M 5P 6M 9M 11A", "", "69#11"],
["1P 3m 5P 6M 9M", "", "m69 -69"],
["1P 3M 5P 6m 7m", "", "7b6"],
["1P 3M 5P 7M 9A 11A", "", "maj7#9#11"],
["1P 3M 5P 7M 9M 11A 13M", "", "M13#11 maj13#11 M13+4 M13#4"],
["1P 3M 5P 7M 9m", "", "M7b9"],
["1P 3M 5P 7m 11A 13m", "", "7#11b13 7b5b13"],
["1P 3M 5P 7m 13M", "", "7add6 67 7add13"],
["1P 3M 5P 7m 9A 11A", "", "7#9#11 7b5#9 7#9b5"],
["1P 3M 5P 7m 9A 11A 13M", "", "13#9#11"],
["1P 3M 5P 7m 9A 11A 13m", "", "7#9#11b13"],
["1P 3M 5P 7m 9A 13M", "", "13#9"],
["1P 3M 5P 7m 9A 13m", "", "7#9b13"],
["1P 3M 5P 7m 9M 11A", "", "9#11 9+4 9#4"],
["1P 3M 5P 7m 9M 11A 13M", "", "13#11 13+4 13#4"],
["1P 3M 5P 7m 9M 11A 13m", "", "9#11b13 9b5b13"],
["1P 3M 5P 7m 9m 11A", "", "7b9#11 7b5b9 7b9b5"],
["1P 3M 5P 7m 9m 11A 13M", "", "13b9#11"],
["1P 3M 5P 7m 9m 11A 13m", "", "7b9b13#11 7b9#11b13 7b5b9b13"],
["1P 3M 5P 7m 9m 13M", "", "13b9"],
["1P 3M 5P 7m 9m 13m", "", "7b9b13"],
["1P 3M 5P 7m 9m 9A", "", "7b9#9"],
["1P 3M 5P 9M", "", "Madd9 2 add9 add2"],
["1P 3M 5P 9m", "", "Maddb9"],
["1P 3M 5d", "", "Mb5"],
["1P 3M 5d 6M 7m 9M", "", "13b5"],
["1P 3M 5d 7M", "", "M7b5"],
["1P 3M 5d 7M 9M", "", "M9b5"],
["1P 3M 5d 7m", "", "7b5"],
["1P 3M 5d 7m 9M", "", "9b5"],
["1P 3M 7m", "", "7no5"],
["1P 3M 7m 13m", "", "7b13"],
["1P 3M 7m 9M", "", "9no5"],
["1P 3M 7m 9M 13M", "", "13no5"],
["1P 3M 7m 9M 13m", "", "9b13"],
["1P 3m 4P 5P", "", "madd4"],
["1P 3m 5P 6m 7M", "", "mMaj7b6"],
["1P 3m 5P 6m 7M 9M", "", "mMaj9b6"],
["1P 3m 5P 7m 11P", "", "m7add11 m7add4"],
["1P 3m 5P 9M", "", "madd9"],
["1P 3m 5d 6M 7M", "", "o7M7"],
["1P 3m 5d 7M", "", "oM7"],
["1P 3m 6m 7M", "", "mb6M7"],
["1P 3m 6m 7m", "", "m7#5"],
["1P 3m 6m 7m 9M", "", "m9#5"],
["1P 3m 5A 7m 9M 11P", "", "m11A"],
["1P 3m 6m 9m", "", "mb6b9"],
["1P 2M 3m 5d 7m", "", "m9b5"],
["1P 4P 5A 7M", "", "M7#5sus4"],
["1P 4P 5A 7M 9M", "", "M9#5sus4"],
["1P 4P 5A 7m", "", "7#5sus4"],
["1P 4P 5P 7M", "", "M7sus4"],
["1P 4P 5P 7M 9M", "", "M9sus4"],
["1P 4P 5P 7m 9M", "", "9sus4 9sus"],
["1P 4P 5P 7m 9M 13M", "", "13sus4 13sus"],
["1P 4P 5P 7m 9m 13m", "", "7sus4b9b13 7b9b13sus4"],
["1P 4P 7m 10m", "", "4 quartal"],
["1P 5P 7m 9m 11P", "", "11b9"],
];
var NoChordType = __assign(__assign({}, pcset.EmptyPcset), { name: "", quality: "Unknown", intervals: [], aliases: [] });
var dictionary = [];
var index = {};
/**
* Given a chord name or chroma, return the chord properties
* @param {string} source - chord name or pitch class set chroma
* @example
* import { get } from 'tonaljs/chord-type'
* get('major') // => { name: 'major', ... }
*/
function get(type) {
return index[type] || NoChordType;
}
var chordType = core.deprecate("ChordType.chordType", "ChordType.get", get);
/**
* Get all chord (long) names
*/
function names() {
return dictionary.map(function (chord) { return chord.name; }).filter(function (x) { return x; });
}
/**
* Get all chord symbols
*/
function symbols() {
return dictionary.map(function (chord) { return chord.aliases[0]; }).filter(function (x) { return x; });
}
/**
* Keys used to reference chord types
*/
function keys() {
return Object.keys(index);
}
/**
* Return a list of all chord types
*/
function all() {
return dictionary.slice();
}
var entries = core.deprecate("ChordType.entries", "ChordType.all", all);
/**
* Clear the dictionary
*/
function removeAll() {
dictionary = [];
index = {};
}
/**
* Add a chord to the dictionary.
* @param intervals
* @param aliases
* @param [fullName]
*/
function add(intervals, aliases, fullName) {
var quality = getQuality(intervals);
var chord = __assign(__assign({}, pcset.get(intervals)), { name: fullName || "", quality: quality,
intervals: intervals,
aliases: aliases });
dictionary.push(chord);
if (chord.name) {
index[chord.name] = chord;
}
index[chord.setNum] = chord;
index[chord.chroma] = chord;
chord.aliases.forEach(function (alias) { return addAlias(chord, alias); });
}
function addAlias(chord, alias) {
index[alias] = chord;
}
function getQuality(intervals) {
var has = function (interval) { return intervals.indexOf(interval) !== -1; };
return has("5A")
? "Augmented"
: has("3M")
? "Major"
: has("5d")
? "Diminished"
: has("3m")
? "Minor"
: "Unknown";
}
CHORDS.forEach(function (_a) {
var ivls = _a[0], fullName = _a[1], names = _a[2];
return add(ivls.split(" "), names.split(" "), fullName);
});
dictionary.sort(function (a, b) { return a.setNum - b.setNum; });
var index$1 = {
names: names,
symbols: symbols,
get: get,
all: all,
add: add,
removeAll: removeAll,
keys: keys,
// deprecated
entries: entries,
chordType: chordType,
};
exports.add = add;
exports.addAlias = addAlias;
exports.all = all;
exports.chordType = chordType;
exports.default = index$1;
exports.entries = entries;
exports.get = get;
exports.keys = keys;
exports.names = names;
exports.removeAll = removeAll;
exports.symbols = symbols;
Object.defineProperty(exports, '__esModule', { value: true });
})));
},{"@tonaljs/core":7,"@tonaljs/pcset":14}],5:[function(require,module,exports){
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tonaljs/chord-detect'), require('@tonaljs/chord-type'), require('@tonaljs/core'), require('@tonaljs/pcset'), require('@tonaljs/scale-type')) :
typeof define === 'function' && define.amd ? define(['exports', '@tonaljs/chord-detect', '@tonaljs/chord-type', '@tonaljs/core', '@tonaljs/pcset', '@tonaljs/scale-type'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Chord = {}, global.chordDetect, global.chordType, global.core, global.pcset, global.scaleType));
}(this, (function (exports, chordDetect, chordType, core, pcset, scaleType) { 'use strict';
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var NoChord = {
empty: true,
name: "",
symbol: "",
root: "",
rootDegree: 0,
type: "",
tonic: null,
setNum: NaN,
quality: "Unknown",
chroma: "",
normalized: "",
aliases: [],
notes: [],
intervals: [],
};
// 6, 64, 7, 9, 11 and 13 are consider part of the chord
// (see https://github.com/danigb/tonal/issues/55)
var NUM_TYPES = /^(6|64|7|9|11|13)$/;
/**
* Tokenize a chord name. It returns an array with the tonic and chord type
* If not tonic is found, all the name is considered the chord name.
*
* This function does NOT check if the chord type exists or not. It only tries
* to split the tonic and chord type.
*
* @function
* @param {string} name - the chord name
* @return {Array} an array with [tonic, type]
* @example
* tokenize("Cmaj7") // => [ "C", "maj7" ]
* tokenize("C7") // => [ "C", "7" ]
* tokenize("mMaj7") // => [ null, "mMaj7" ]
* tokenize("Cnonsense") // => [ null, "nonsense" ]
*/
function tokenize(name) {
var _a = core.tokenizeNote(name), letter = _a[0], acc = _a[1], oct = _a[2], type = _a[3];
if (letter === "") {
return ["", name];
}
// aug is augmented (see https://github.com/danigb/tonal/issues/55)
if (letter === "A" && type === "ug") {
return ["", "aug"];
}
// see: https://github.com/tonaljs/tonal/issues/70
if (!type && (oct === "4" || oct === "5")) {
return [letter + acc, oct];
}
if (NUM_TYPES.test(oct)) {
return [letter + acc, oct + type];
}
else {
return [letter + acc + oct, type];
}
}
/**
* Get a Chord from a chord name.
*/
function get(src) {
if (src === "") {
return NoChord;
}
if (Array.isArray(src) && src.length === 2) {
return getChord(src[1], src[0]);
}
else {
var _a = tokenize(src), tonic = _a[0], type = _a[1];
var chord_1 = getChord(type, tonic);
return chord_1.empty ? getChord(src) : chord_1;
}
}
/**
* Get chord properties
*
* @param typeName - the chord type name
* @param [tonic] - Optional tonic
* @param [root] - Optional root (requires a tonic)
*/
function getChord(typeName, optionalTonic, optionalRoot) {
var type = chordType.get(typeName);
var tonic = core.note(optionalTonic || "");
var root = core.note(optionalRoot || "");
if (type.empty ||
(optionalTonic && tonic.empty) ||
(optionalRoot && root.empty)) {
return NoChord;
}
var rootInterval = core.distance(tonic.pc, root.pc);
var rootDegree = type.intervals.indexOf(rootInterval) + 1;
if (!root.empty && !rootDegree) {
return NoChord;
}
var intervals = Array.from(type.intervals);
for (var i = 1; i < rootDegree; i++) {
var num = intervals[0][0];
var quality = intervals[0][1];
var newNum = parseInt(num, 10) + 7;
intervals.push("" + newNum + quality);
intervals.shift();
}
var notes = tonic.empty
? []
: intervals.map(function (i) { return core.transpose(tonic, i); });
typeName = type.aliases.indexOf(typeName) !== -1 ? typeName : type.aliases[0];
var symbol = "" + (tonic.empty ? "" : tonic.pc) + typeName + (root.empty || rootDegree <= 1 ? "" : "/" + root.pc);
var name = "" + (optionalTonic ? tonic.pc + " " : "") + type.name + (rootDegree > 1 && optionalRoot ? " over " + root.pc : "");
return __assign(__assign({}, type), { name: name,
symbol: symbol, type: type.name, root: root.name, intervals: intervals,
rootDegree: rootDegree, tonic: tonic.name, notes: notes });
}
var chord = core.deprecate("Chord.chord", "Chord.get", get);
/**
* Transpose a chord name
*
* @param {string} chordName - the chord name
* @return {string} the transposed chord
*
* @example
* transpose('Dm7', 'P4') // => 'Gm7
*/
function transpose(chordName, interval) {
var _a = tokenize(chordName), tonic = _a[0], type = _a[1];
if (!tonic) {
return chordName;
}
return core.transpose(tonic, interval) + type;
}
/**
* Get all scales where the given chord fits
*
* @example
* chordScales('C7b9')
* // => ["phrygian dominant", "flamenco", "spanish heptatonic", "half-whole diminished", "chromatic"]
*/
function chordScales(name) {
var s = get(name);
var isChordIncluded = pcset.isSupersetOf(s.chroma);
return scaleType.all()
.filter(function (scale) { return isChordIncluded(scale.chroma); })
.map(function (scale) { return scale.name; });
}
/**
* Get all chords names that are a superset of the given one
* (has the same notes and at least one more)
*
* @function
* @example
* extended("CMaj7")
* // => [ 'Cmaj#4', 'Cmaj7#9#11', 'Cmaj9', 'CM7add13', 'Cmaj13', 'Cmaj9#11', 'CM13#11', 'CM7b9' ]
*/
function extended(chordName) {
var s = get(chordName);
var isSuperset = pcset.isSupersetOf(s.chroma);
return chordType.all()
.filter(function (chord) { return isSuperset(chord.chroma); })
.map(function (chord) { return s.tonic + chord.aliases[0]; });
}
/**
* Find all chords names that are a subset of the given one
* (has less notes but all from the given chord)
*
* @example
*/
function reduced(chordName) {
var s = get(chordName);
var isSubset = pcset.isSubsetOf(s.chroma);
return chordType.all()
.filter(function (chord) { return isSubset(chord.chroma); })
.map(function (chord) { return s.tonic + chord.aliases[0]; });
}
var index = {
getChord: getChord,
get: get,
detect: chordDetect.detect,
chordScales: chordScales,
extended: extended,
reduced: reduced,
tokenize: tokenize,
transpose: transpose,
// deprecate
chord: chord,
};
Object.defineProperty(exports, 'detect', {
enumerable: true,
get: function () {
return chordDetect.detect;
}
});
exports.chord = chord;
exports.chordScales = chordScales;
exports.default = index;
exports.extended = extended;
exports.get = get;
exports.getChord = getChord;
exports.reduced = reduced;
exports.tokenize = tokenize;
exports.transpose = transpose;
Object.defineProperty(exports, '__esModule', { value: true });
})));
},{"@tonaljs/chord-detect":3,"@tonaljs/chord-type":4,"@tonaljs/core":7,"@tonaljs/pcset":14,"@tonaljs/scale-type":18}],6:[function(require,module,exports){
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Collection = {}));
}(this, (function (exports) { 'use strict';
// ascending range
function ascR(b, n) {
var a = [];
// tslint:disable-next-line:curly
for (; n--; a[n] = n + b)
;
return a;
}
// descending range
function descR(b, n) {
var a = [];
// tslint:disable-next-line:curly
for (; n--; a[n] = b - n)
;
return a;
}
/**
* Creates a numeric range
*
* @param {number} from
* @param {number} to
* @return {Array<number>}
*
* @example
* range(-2, 2) // => [-2, -1, 0, 1, 2]
* range(2, -2) // => [2, 1, 0, -1, -2]
*/
function range(from, to) {
return from < to ? ascR(from, to - from + 1) : descR(from, from - to + 1);
}
/**
* Rotates a list a number of times. It"s completly agnostic about the
* contents of the list.
*
* @param {Integer} times - the number of rotations
* @param {Array} collection
* @return {Array} the rotated collection
*
* @example
* rotate(1, [1, 2, 3]) // => [2, 3, 1]
*/
function rotate(times, arr) {
var len = arr.length;
var n = ((times % len) + len) % len;
return arr.slice(n, len).concat(arr.slice(0, n));
}
/**
* Return a copy of the collection with the null values removed
* @function
* @param {Array} collection
* @return {Array}
*
* @example
* compact(["a", "b", null, "c"]) // => ["a", "b", "c"]
*/
function compact(arr) {
return arr.filter(function (n) { return n === 0 || n; });
}
/**
* Randomizes the order of the specified collection in-place, using the Fisher–Yates shuffle.
*
* @function
* @param {Array} collection
* @return {Array} the collection shuffled
*
* @example
* shuffle(["C", "D", "E", "F"]) // => [...]
*/
function shuffle(arr, rnd) {
if (rnd === void 0) { rnd = Math.random; }
var i;
var t;
var m = arr.length;
while (m) {
i = Math.floor(rnd() * m--);
t = arr[m];
arr[m] = arr[i];
arr[i] = t;
}
return arr;
}
/**
* Get all permutations of an collection
*
* @param {Array} collection - the collection
* @return {Array<Array>} an collection with all the permutations
* @example
* permutations(["a", "b", "c"])) // =>
* [
* ["a", "b", "c"],
* ["b", "a", "c"],
* ["b", "c", "a"],
* ["a", "c", "b"],
* ["c", "a", "b"],
* ["c", "b", "a"]
* ]
*/
function permutations(arr) {
if (arr.length === 0) {
return [[]];
}
return permutations(arr.slice(1)).reduce(function (acc, perm) {
return acc.concat(arr.map(function (e, pos) {
var newPerm = perm.slice();
newPerm.splice(pos, 0, arr[0]);
return newPerm;
}));
}, []);
}
var index = {
compact: compact,
permutations: permutations,
range: range,
rotate: rotate,
shuffle: shuffle,
};
exports.compact = compact;
exports.default = index;
exports.permutations = permutations;
exports.range = range;
exports.rotate = rotate;
exports.shuffle = shuffle;
Object.defineProperty(exports, '__esModule', { value: true });
})));
},{}],7:[function(require,module,exports){
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Core = {}));
}(this, (function (exports) { 'use strict';
/**
* Fill a string with a repeated character
*
* @param character
* @param repetition
*/
var fillStr = function (s, n) { return Array(Math.abs(n) + 1).join(s); };
function deprecate(original, alternative, fn) {
return function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
// tslint:disable-next-line
console.warn(original + " is deprecated. Use " + alternative + ".");
return fn.apply(this, args);
};
}