summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--scale.mjs20
1 files changed, 10 insertions, 10 deletions
diff --git a/scale.mjs b/scale.mjs
index 485d0c5..de25d14 100644
--- a/scale.mjs
+++ b/scale.mjs
@@ -1,13 +1,3 @@
-const ringHandler = {
- get(target, prop) {
- return target[prop % target.length] || Reflect.get(...arguments);
- }
-};
-
-export const chromaticScale = new Proxy(
- ['A', 'A♯', 'B', 'C', 'C♯', 'D', 'D♯', 'E', 'F', 'F♯', 'G', 'G♯'],
- ringHandler);
-
function notesBetween(a, b) {
const [tonicA, tonicB] = [a[0], b[0]]
const abs = tonicB.charCodeAt() - tonicA.charCodeAt();
@@ -18,6 +8,16 @@ function notesBetween(a, b) {
}
}
+const ringHandler = {
+ get(target, prop) {
+ return target[prop % target.length] || Reflect.get(...arguments);
+ }
+};
+
+export const chromaticScale = new Proxy(
+ ['C', 'C♯', 'D', 'D♯', 'E', 'F', 'F♯', 'G', 'G♯', 'A', 'A♯', 'B'],
+ ringHandler);
+
// todo: handle tonics with a flat ‘♭’, so we can deal with [BE]♭.
function scaleFromIntervals(tonic, intervals) {
const scaleIndex = chromaticScale.indexOf(tonic);