forked from bychen9/vocal-range-detector
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow users to proceed through scales up and down
- Loading branch information
Showing
5 changed files
with
71 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
let fileName = location.href.split("/").slice(-1); | ||
let base = localStorage.getItem('baseNote'); | ||
let body = document.querySelector("body"); | ||
let text = document.createElement("p"); | ||
let node = document.createTextNode("Your base note was " + base + "."); | ||
text.append(node); | ||
body.insertBefore(text, body.childNodes[3]); | ||
|
||
let upNotes = ["A", "B", "C", "D", "E", "F", "G"]; | ||
let downNotes = ["G", "F", "E", "D", "C", "B", "A"]; | ||
let baseIndex; | ||
if (fileName[0] == "second-step.html") { | ||
baseIndex = upNotes.findIndex(element => { | ||
return element === base.charAt(0); | ||
}); | ||
} else { | ||
baseIndex = downNotes.findIndex(element => { | ||
return element == base.charAt(0); | ||
}); | ||
} | ||
|
||
let i = 1; | ||
|
||
let octaveNumber = base.charAt(1); | ||
function nextNote() { | ||
let note; | ||
if (fileName[0] == "second-step.html") { | ||
note = upNotes[(baseIndex + i) % 7]; | ||
if (note === "A") { | ||
octaveNumber++; | ||
} | ||
} else { | ||
note = downNotes[(baseIndex + i) % 7]; | ||
if (note === "G") { | ||
octaveNumber--; | ||
} | ||
} | ||
let singText = document.createElement("p"); | ||
let sing = document.createTextNode("Now, try to sing " + note + octaveNumber + "."); | ||
singText.append(sing); | ||
singText.setAttribute("id", "noteToSing"); | ||
body.insertBefore(singText, body.childNodes[4]); | ||
i++; | ||
} | ||
nextNote(); | ||
|
||
let pass = document.getElementById("pass"); | ||
pass.onclick = function() { | ||
let noteToSing = document.getElementById("noteToSing"); | ||
if (noteToSing != null) { | ||
noteToSing.parentNode.removeChild(noteToSing); | ||
} | ||
nextNote(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<link rel="stylesheet" href="style.css"> | ||
<title>Third Step</title> | ||
<head> | ||
<h2>Third Step: Sing Lower</h2> | ||
<body> | ||
<p>Sing from your base note to the bottom of your vocal range.</p> | ||
<button id="pass">Pass</button> | ||
</body> | ||
<script src="scales.js"></script> | ||
</html> |