summaryrefslogtreecommitdiff
path: root/client/lib/organ.js
diff options
context:
space:
mode:
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 }
+