diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-02-21 14:44:43 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-02-21 14:44:43 +0100 |
| commit | 486d1d22f64fb930bd15707ffbde10a68f37ea7d (patch) | |
| tree | 8c0ef9fa86d8c20be07db2312ea72c5e68f050f7 /client/index.js | |
| parent | 4965ee2d60b8f671b2ea243f32c69f249b41caab (diff) | |
refining glass sound
Diffstat (limited to 'client/index.js')
| -rw-r--r-- | client/index.js | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/client/index.js b/client/index.js index fbe0491..0b5f16b 100644 --- a/client/index.js +++ b/client/index.js @@ -21,10 +21,11 @@ const ws = w/s, hs = h/s let samplers = {} requestAudioContext( () => { - samplers['smash'] = new Sampler('samples/smash/g{}.mp3', 12) - samplers['glass'] = new Sampler('samples/glass/0{}Particle.mp3', 90) }) +samplers['smash'] = new Sampler('samples/smash/g{}.mp3', 12) +samplers['glass'] = new Sampler('samples/glass/0{}Particle.mp3', 90) + let last_index = 0 keys.listen(index => { index = Math.abs(index+10) @@ -63,20 +64,21 @@ mouse.register({ move: (x, y, dx, dy) => { let count = Math.abs(dx + dy) / 40 if (count < 1) return - count = clamp(count, 1, 5) + count = clamp(count, 1, 10) if (Math.abs(dx) + Math.abs(dy) > 100) { samplers['smash'].play(randrange(50, 300) + 100 * (x/window.innerWidth + y/window.innerHeight), 0) draw.clear() draw.triangle(x, y, 500) } let now = Tone.now() - let when, i + let when, i, player for (i = 0; i < count; i++) { when = Math.random()/2000 + (i+ Math.random()/10)/randrange(2,5) - samplers['glass'].play( - 100 * randrange(2,5) / randrange(2,5), + player = samplers['glass'].play( + 100 * randrange(2,5) / randrange(2,5) * randrange(0.5,1.5), now + when ) + player.volume.value = -i*i } setTimeout( () => { draw.triangle(x, y, Math.abs(dx) + Math.abs(dy)) |
