diff --git a/app.js b/app.js index 302b959..451cf33 100644 --- a/app.js +++ b/app.js @@ -40,10 +40,10 @@ generateToneButton.addEventListener('click', () => { generateNoteButton.addEventListener('click', () => { Tone.start() - const lowOctave = parseInt(lowest.charAt(1)) * 12 - const lowNote = notes.findIndex(enharmonics => enharmonics.includes(lowest.charAt(0))) - const highOctave = parseInt(highest.charAt(1)) * 12 - const highNote = notes.findIndex(enharmonics => enharmonics.includes(highest.charAt(0))) + const lowOctave = parseInt(lowest.charAt(lowest.length - 1)) * 12 + const lowNote = notes.findIndex(enharmonics => enharmonics.includes(lowest.substring(0, lowest.length-1))) + const highOctave = parseInt(highest.charAt(highest.length - 1)) * 12 + const highNote = notes.findIndex(enharmonics => enharmonics.includes(highest.substring(0, highest.length-1))) const lowPitch = lowOctave + lowNote const highPitch = highOctave + highNote @@ -55,8 +55,8 @@ generateNoteButton.addEventListener('click', () => { const randomPitchNote = randomPitch % 12 newTone = notes[randomPitchNote][0] + randomPitchOctave - newTone = teoria.note(newTone).fq() toneDisplay.innerHTML = newTone + newTone = teoria.note(newTone).fq() }) playButton.addEventListener('click', ()=>{