This repository was archived by the owner on Mar 19, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
54 lines (49 loc) · 1.24 KB
/
test.js
File metadata and controls
54 lines (49 loc) · 1.24 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
var context = new AudioContext()
var o = null
var g = null
document.addEventListener('DOMContentLoaded', function () {
$(".js_play_sound").on("click", function (e) {
e.preventDefault()
var $target = $(e.target)
eval($target.data("source"))
})
$(".js_stop_sound").on("click", function (e) {
e.preventDefault()
o.stop()
})
}, false)
function example1() {
o = context.createOscillator()
o.type = "sine"
o.connect(context.destination)
o.start()
}
function example2() {
o = context.createOscillator()
g = context.createGain()
o.connect(g)
g.connect(context.destination)
o.start(0)
}
function example2Stop(decreaseTime) {
g.gain.exponentialRampToValueAtTime(0.00001, context.currentTime + decreaseTime)
}
function example3(type, x) {
o = context.createOscillator()
g = context.createGain()
o.connect(g)
o.type = type
g.connect(context.destination)
o.start(0)
g.gain.exponentialRampToValueAtTime(0.00001, context.currentTime + x)
}
function example4(frequency, type) {
o = context.createOscillator()
g = context.createGain()
o.type = type
o.connect(g)
o.frequency.value = frequency
g.connect(context.destination)
o.start(0)
g.gain.exponentialRampToValueAtTime(0.00001, context.currentTime + 1)
}