Reputation: 2704
I have a problem with the code that worked perfectly in Chrome but nowadays I assume due to Chrome update it stopped working.
var audioContext = new(window.audioContext || window.webkitAudioContext);
var oscillator = audioContext.createOscillator();
oscillator.type = 0;
oscillator.connect(audioContext.destination);
oscillator.noteOn(0);
setTimeout(function () {
oscillator.noteOff(0);
}, 5000 );
The error message is the following
The provided value '0' is not a valid enum value of interface OscillatorType.
Uncaught TypeError: oscillator.noteOn is not a function
I didn't find any clue why this stopped working. I appreciate you help.
Upvotes: 1
Views: 813
Reputation: 1903
Valid values for oscillator.type are 'sine', 'square', 'sawtooth', 'triangle'. Some browsers also implement 'custom'.
http://webaudio.github.io/web-audio-api/#attributes-28
Upvotes: 1