master
Matthew Huntington 1 year ago
parent d772fe806e
commit cea1ed7da5

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

@ -3,6 +3,7 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title></title> <title></title>
<script src="http://unpkg.com/tone"></script>
<script src="app.js" defer></script> <script src="app.js" defer></script>
</head> </head>
<body> <body>

Loading…
Cancel
Save