|
|
|
|
@ -3,10 +3,22 @@ const highest = 4186
|
|
|
|
|
const range = highest - lowest
|
|
|
|
|
|
|
|
|
|
const generateButton = document.querySelector('body > button')
|
|
|
|
|
const playButton = document.querySelector('section > button:nth-of-type(1)')
|
|
|
|
|
const stopButton = document.querySelector('section > button:nth-of-type(2)')
|
|
|
|
|
const toneDisplay = document.querySelector('section dd')
|
|
|
|
|
const synth = new Tone.Synth().toDestination()
|
|
|
|
|
let newTone
|
|
|
|
|
|
|
|
|
|
generateButton.addEventListener('click', () => {
|
|
|
|
|
newTone = Math.random() * range + lowest
|
|
|
|
|
toneDisplay.innerHTML = newTone
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
playButton.addEventListener('click', ()=>{
|
|
|
|
|
synth.triggerAttackRelease("C4");
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
stopButton.addEventListener('click', ()=>{
|
|
|
|
|
synth.triggerRelease();
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|