-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAudioContext.js
More file actions
54 lines (48 loc) · 1.71 KB
/
AudioContext.js
File metadata and controls
54 lines (48 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
(function () {
'use strict';
var
AudioContext = window.AudioContext = window.AudioContext || window.webkitAudioContext,
AudioContextPrototype = AudioContext.prototype;
Object.defineProperties(AudioContextPrototype, {
createGain: {
value: AudioContextPrototype.createGain || AudioContextPrototype.createGainNode
},
createDelay: {
value: AudioContextPrototype.createDelay|| AudioContextPrototype.createDelayNode
},
createScriptProcessor: {
value: AudioContextPrototype.createScriptProcessor || AudioContextPrototype.createJavaScriptNode
}
});
var
audioContext = new AudioContext(),
oscillatorPrototype = audioContext.createOscillator().constructor.prototype,
bufferSourcePrototype = audioContext.createBufferSource().constructor.prototype,
gainGainConstructorPrototype = audioContext.createGain().gain.constructor.prototype;
Object.defineProperties(oscillatorPrototype, {
setPeriodicWave: {
value: oscillatorPrototype.setPeriodicWave || oscillatorPrototype.setWaveTable
},
start: {
value: oscillatorPrototype.start || oscillatorPrototype.noteOn
},
stop: {
value: oscillatorPrototype.stop || oscillatorPrototype.noteOff
}
});
Object.defineProperties(bufferSourcePrototype, {
start: {
value: bufferSourcePrototype.start || function start() {
return arguments.length > 1 ? bufferSourcePrototype.noteGrainOn.apply(this, arguments) : bufferSourcePrototype.noteOn.apply(this, arguments);
}
},
stop: {
value: bufferSourcePrototype.stop || bufferSourcePrototype.noteOff
}
});
Object.defineProperties(gainGainConstructorPrototype, {
setTargetAtTime: {
value: gainGainConstructorPrototype.setTargetAtTime || gainGainConstructorPrototype.setTargetValueAtTime
}
});
})();