Skip to content

Commit f06dc87

Browse files
authoredOct 1, 2020
Merge pull request #1 from Raamyy/master
🔊 added sound for the visualisation
2 parents ec0a536 + f89d1e6 commit f06dc87

File tree

3 files changed

+205
-169
lines changed

3 files changed

+205
-169
lines changed
 

‎App/beep.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
a = new AudioContext() // browsers limit the number of concurrent audio contexts, so you better re-use'em
2+
3+
function beep(vol, freq, duration) {
4+
console.log({ vol, freq, duration })
5+
v = a.createOscillator()
6+
u = a.createGain()
7+
v.connect(u)
8+
v.frequency.value = freq
9+
v.type = "square"
10+
u.connect(a.destination)
11+
u.gain.value = vol * 0.01
12+
v.start(a.currentTime)
13+
v.stop(a.currentTime + duration * 0.001)
14+
}

0 commit comments

Comments
 (0)
Please sign in to comment.