diff options
Diffstat (limited to 'client/lib')
| -rw-r--r-- | client/lib/organ.js | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/client/lib/organ.js b/client/lib/organ.js index fe2315c..0048abf 100644 --- a/client/lib/organ.js +++ b/client/lib/organ.js @@ -1,24 +1,24 @@ import Tone from 'tone' -import { choice } from './util' import output from './output' -const player_count = 4 - const oscillators = {} +let lastPlayed function play (freq) { const osc = oscillators[freq] = oscillators[freq] || {} if (!osc.el) { - osc.el = new Tone.Oscillator(freq , "sine") + osc.el = new Tone.Oscillator(freq, "sine") osc.el.connect(output) } osc.el.start() osc.playing = true + lastPlayed = osc return osc } -function pause(freq) { +function pause (freq) { + if (!oscillators[freq]) return const osc = oscillators[freq] = oscillators[freq] || {} - osc.el && osc.el.stop() + if (osc.el) osc.el.stop() osc.playing = false return osc } |
