|
|
|
@ -8,15 +8,17 @@ const maxInput = document.querySelector('#generate-tone input:nth-of-type(2)')
|
|
|
|
const synth = new Tone.Synth().toDestination()
|
|
|
|
const synth = new Tone.Synth().toDestination()
|
|
|
|
|
|
|
|
|
|
|
|
let newTone
|
|
|
|
let newTone
|
|
|
|
let lowest = 27.5
|
|
|
|
let lowest = 'a0'
|
|
|
|
let highest = 4186
|
|
|
|
let highest = 'c8'
|
|
|
|
|
|
|
|
|
|
|
|
minInput.setAttribute('placeholder', lowest)
|
|
|
|
minInput.setAttribute('placeholder', lowest)
|
|
|
|
maxInput.setAttribute('placeholder', highest)
|
|
|
|
maxInput.setAttribute('placeholder', highest)
|
|
|
|
|
|
|
|
|
|
|
|
generateButton.addEventListener('click', () => {
|
|
|
|
generateButton.addEventListener('click', () => {
|
|
|
|
Tone.start()
|
|
|
|
Tone.start()
|
|
|
|
newTone = (Math.random() * (highest - lowest)) + lowest
|
|
|
|
const minFreq = teoria.note(lowest).fq()
|
|
|
|
|
|
|
|
const maxFreq = teoria.note(highest).fq()
|
|
|
|
|
|
|
|
newTone = (Math.random() * (maxFreq - minFreq)) + minFreq
|
|
|
|
toneDisplay.innerHTML = newTone
|
|
|
|
toneDisplay.innerHTML = newTone
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
@ -29,9 +31,9 @@ stopButton.addEventListener('click', ()=>{
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
minInput.addEventListener('change', ()=>{
|
|
|
|
minInput.addEventListener('change', ()=>{
|
|
|
|
lowest = parseFloat(minInput.value)
|
|
|
|
lowest = minInput.value
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
maxInput.addEventListener('change', ()=>{
|
|
|
|
maxInput.addEventListener('change', ()=>{
|
|
|
|
highest = parseFloat(maxInput.value)
|
|
|
|
highest = maxInput.value
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|