summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fretboard.mjs12
-rw-r--r--index.html10
-rw-r--r--scale.mjs5
3 files changed, 14 insertions, 13 deletions
diff --git a/fretboard.mjs b/fretboard.mjs
index 4254d3a..4f5344e 100644
--- a/fretboard.mjs
+++ b/fretboard.mjs
@@ -12,17 +12,17 @@ const strings = {
// true if not a natural note
function isAccidental(note) {
- return note[1] === '#' || note[1] === 'b';
+ return note[1] === '♯' || note[1] === '♭';
}
-// convert ‘Eb’ to ‘D#’ and vice versa.
+// convert ‘E♭’ to ‘D♯’ and vice versa.
function alternateAccidental(note) {
const root = chromaticScale.indexOf(note[0]);
switch (note[1]) {
- case '#':
- return `${chromaticScale[root+2]}b`;
- case 'b':
- return `${chromaticScale[root-1]}#`;
+ case '♯':
+ return `${chromaticScale[root+2]}♭`;
+ case '♭':
+ return `${chromaticScale[root-1]}♯`;
default:
return note;
}
diff --git a/index.html b/index.html
index 94e9a82..fc12e45 100644
--- a/index.html
+++ b/index.html
@@ -101,17 +101,17 @@
<label for='tonic'>tonic:</label>
<select id='tonic' name='tonic'>
<option value='A'>A</option>
- <option value='A#'>A#</option>
+ <option value='A♯'>A♯</option>
<option value='B'>B</option>
<option value='C' selected>C</option>
- <option value='C#'>C#</option>
+ <option value='C♯'>C♯</option>
<option value='D'>D</option>
- <option value='D#'>D#</option>
+ <option value='D♯'>D♯</option>
<option value='E'>E</option>
<option value='F'>F</option>
- <option value='F#'>F#</option>
+ <option value='F♯'>F♯</option>
<option value='G'>G</option>
- <option value='G#'>G#</option>
+ <option value='G♯'>G♯</option>
</select>
<label for='diatonic'>diatonic:</label>
<select id='diatonic' name='diatonic'>
diff --git a/scale.mjs b/scale.mjs
index 9e0e122..b4f043d 100644
--- a/scale.mjs
+++ b/scale.mjs
@@ -5,12 +5,13 @@ const ringHandler = {
};
export const chromaticScale = new Proxy(
- ['A', 'A#', 'B', 'C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#'],
+ ['A', 'A♯', 'B', 'C', 'C♯', 'D', 'D♯', 'E', 'F', 'F♯', 'G', 'G♯'],
ringHandler);
function scaleFromIntervals(tonic, intervals) {
const scaleIndex = chromaticScale.indexOf(tonic);
if (scaleIndex < 0) {
+ console.error('tonic not found in scale', tonic, chromaticScale);
return undefined;
}
@@ -24,7 +25,7 @@ function scaleFromIntervals(tonic, intervals) {
// accidentals.
if (note[0] === lastBase) {
const nextBase = chromaticScale[scaleIndex + steps + 1][0];
- scale.push(`${nextBase}b`)
+ scale.push(`${nextBase}♭`)
lastBase = nextBase[0];
} else {
scale.push(note);