@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
25 lines (24 loc) • 808 B
JavaScript
;
export class NotesBuilder {
static list(startOctave, endOctave) {
let noteIndex = 0;
const noteHolders = [];
for (let octave = startOctave; octave <= endOctave; octave++) {
while (noteIndex < this.ALL_NOTES.length) {
const currentNote = this.ALL_NOTES[noteIndex];
const newNote = currentNote + octave;
noteHolders.push({ note: newNote, octave });
if (currentNote !== "B" && currentNote !== "E") {
const blackNote = currentNote + "#" + octave;
noteHolders.push({ note: blackNote, octave });
}
if (octave === endOctave && currentNote === "B")
break;
noteIndex++;
}
noteIndex = 0;
}
return noteHolders;
}
}
NotesBuilder.ALL_NOTES = ["C", "D", "E", "F", "G", "A", "B"];