From 486d1d22f64fb930bd15707ffbde10a68f37ea7d Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 21 Feb 2018 14:44:43 +0100 Subject: refining glass sound --- client/index.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'client/index.js') 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)) -- cgit v1.2.3-70-g09d2