summaryrefslogtreecommitdiff
path: root/client/lib/organ.js
diff options
context:
space:
mode:
authorJules <jules@asdf.us>2018-02-23 22:21:09 -0500
committerJules <jules@asdf.us>2018-02-23 22:21:09 -0500
commitbb5d129729bab5cfdcc44fcfaa295b1c7e6d4c19 (patch)
treea30de6acbfdf361772bea5bda6c25eab5ffa083f /client/lib/organ.js
parent2fada280f6cbe93831573f354192ce8014526d4b (diff)
parentafe0263215ec7cfd256716997deb77eee9c4d6c8 (diff)
Merge branch 'master' of ghghgh.us:triangle
Diffstat (limited to 'client/lib/organ.js')
-rw-r--r--client/lib/organ.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/client/lib/organ.js b/client/lib/organ.js
new file mode 100644
index 0000000..fe2315c
--- /dev/null
+++ b/client/lib/organ.js
@@ -0,0 +1,27 @@
+import Tone from 'tone'
+import { choice } from './util'
+import output from './output'
+
+const player_count = 4
+
+const oscillators = {}
+
+function play (freq) {
+ const osc = oscillators[freq] = oscillators[freq] || {}
+ if (!osc.el) {
+ osc.el = new Tone.Oscillator(freq , "sine")
+ osc.el.connect(output)
+ }
+ osc.el.start()
+ osc.playing = true
+ return osc
+}
+function pause(freq) {
+ const osc = oscillators[freq] = oscillators[freq] || {}
+ osc.el && osc.el.stop()
+ osc.playing = false
+ return osc
+}
+
+export default { play, pause, oscillators }
+