diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-02-24 04:20:13 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-02-24 04:20:13 +0100 |
| commit | afe0263215ec7cfd256716997deb77eee9c4d6c8 (patch) | |
| tree | 4a8e7067e0a540b56778b3b57a90e677ab783140 /client/lib/organ.js | |
| parent | 1ddb0f40f00131ce8c35f19655566c248226f532 (diff) | |
add conway life
Diffstat (limited to 'client/lib/organ.js')
| -rw-r--r-- | client/lib/organ.js | 27 |
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 } + |
