diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-03-23 01:58:16 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-03-23 01:58:16 +0100 |
| commit | 1926101e77699bd2b5bd5e8c500bae1019ba8655 (patch) | |
| tree | d9f593a1b931c12a2756ef897c61224c812b0287 /client/lib | |
| parent | 8dab62fdfafb24e792bee09a04b5592704f33e92 (diff) | |
arrow keys move pattern around
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 } |
