タイトルとURLをコピーしました
oscillator.frequency.value = freq;
oscillator.connect(gainNode);
gainNode.connect(audioCtx.destination);
oscillator.start();
gainNode.gain.setValueAtTime(1, audioCtx.currentTime);
gainNode.gain.exponentialRampToValueAtTime(0.0001, audioCtx.currentTime + duration);
oscillator.stop(audioCtx.currentTime + duration);
}
const beat = 60 / 100;
document.getElementById("one").addEventListener("click", function () {
playTone(2000, beat * 0.75);
});
document.getElementById("a").addEventListener("click", function () {
playTone(2000, beat * 0.25);
});
document.getElementById("two").addEventListener("click", function () {
playTone(2000, beat * 1);
});