update AI engines
[uweb.git] / zh / searchurl / js / beep.js
blob4d75260d372c5109d346521a792961f1427aeca8
1 //data:charset=utf-8,
2 var audioCtx = new window.AudioContext;
3 function beep(duration, frequency, volume, type, callback) {
4 var oscillator = audioCtx.createOscillator();
5 var gainNode = audioCtx.createGain();
7 oscillator.connect(gainNode);
8 gainNode.connect(audioCtx.destination);
10 if (volume){gainNode.gain.value = volume;}
11 if (frequency){oscillator.frequency.value = frequency;}
12 if (type){oscillator.type = type;}
13 if (callback){oscillator.onended = callback;}
15 oscillator.start(audioCtx.currentTime);
16 oscillator.stop(audioCtx.currentTime + ((duration || 500) / 1000));
18 beep();
19 self.close();