basic octave selection done

This commit is contained in:
Emanuel Rodriguez 2023-10-01 02:04:18 -07:00
parent 5acec7e461
commit ad2a00e9c7
1 changed files with 22 additions and 0 deletions

View File

@ -43,12 +43,34 @@ window.onload = function () {
}
}
function handleOctaveSelectionChange() {
let selectedRadioButton = document.querySelector(
"input[name='octavechoice']:checked"
);
if (selectedRadioButton) {
selectedOctave = selectedRadioButton.value;
if (osc) {
osc.frequency.setValueAtTime(
octavehz(parseFloat(freq.value), parseFloat(selectedOctave)),
audioContext.currentTime
);
}
console.log(selectedWave);
} else {
console.log("No radio button is selected.");
}
}
document
.querySelectorAll("input[name='wavechoice']")
.forEach((radioButton) => {
radioButton.addEventListener("change", handleWaveformSelectionChange);
});
document.querySelectorAll("input[name='octavechoice']").forEach((rb) => {
rb.addEventListener("change", handleOctaveSelectionChange);
});
document.getElementById("start").addEventListener("click", () => {
if (!osc) {
osc = audioContext.createOscillator();