Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

generate sound javascript

// creates sounds using frequencies
	const audioContext = new AudioContext();
    const oscillator = audioContext.createOscillator();
    oscillator.type = "triangle"; // "square" "sine" "sawtooth"
    oscillator.frequency.value = frequency; // 440 is default (try different frequencies)
    oscillator.connect(audioContext.destination); // connects to your audio output
    oscillator.start(0); // immediately starts when triggered
    oscillator.stop(0.5); // stops after 0.5 seconds
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #generate #sound #javascript
ADD COMMENT
Topic
Name
3+2 =