You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
689 B

const lowest = 27.5
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();
})