Reputation: 11
Can't get the oscillator to make noise? Think I'm missing something obvious but no idea really. Following https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/createOscillator
<!DOCTYPE html>
<html>
<head>
<title>Audio API</title>
</head>
<body>
<script>
var audioContext = new (window.AudioContext || window.webkitAudioContext)();
var oscillator = audioContext.createOscillator();
oscillator.type = 'square';
oscillator.frequency.value = 3000;
oscillator.start();
</script>
</body>
</html>
Upvotes: 0
Views: 54
Reputation: 12161
You need to connect the oscillator node to an audio destination:
oscillator.frequency.value = 3000;
oscillator.connect( audioContext.destination );
oscillator.start();
Upvotes: 1