web audio api
https://tomhazledine.com/web-audio-delay/
HTML
<button id="osc">sound</button>JS 1
const context = new AudioContext(); //allows access to web audio api
document.querySelector('#osc').addEventListener('click', function () {
note();
});
function note() {
var oscillator = context.createOscillator(); //creates oscillator
oscillator.type = "sawtooth"; //chooses the type of wave
oscillator.frequency.value = 100; //assigning the value of oscPitch to the oscillators frequency value
oscillator.connect(context.destination); //sends to output
oscillator.start(context.currentTime); //starts oscillator
oscillator.stop(context.currentTime + 1); //stops oscillator
};JS 2
JS more advanced
Was this helpful?