basic octave selection done
This commit is contained in:
parent
5acec7e461
commit
ad2a00e9c7
22
basic.js
22
basic.js
|
@ -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
|
document
|
||||||
.querySelectorAll("input[name='wavechoice']")
|
.querySelectorAll("input[name='wavechoice']")
|
||||||
.forEach((radioButton) => {
|
.forEach((radioButton) => {
|
||||||
radioButton.addEventListener("change", handleWaveformSelectionChange);
|
radioButton.addEventListener("change", handleWaveformSelectionChange);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
document.querySelectorAll("input[name='octavechoice']").forEach((rb) => {
|
||||||
|
rb.addEventListener("change", handleOctaveSelectionChange);
|
||||||
|
});
|
||||||
|
|
||||||
document.getElementById("start").addEventListener("click", () => {
|
document.getElementById("start").addEventListener("click", () => {
|
||||||
if (!osc) {
|
if (!osc) {
|
||||||
osc = audioContext.createOscillator();
|
osc = audioContext.createOscillator();
|
||||||
|
|
Loading…
Reference in New Issue