From 7af6dfc46f9a94e3966cdfa4e0d353e989eb9070 Mon Sep 17 00:00:00 2001 From: julian laplace Date: Wed, 10 May 2023 15:13:47 +0200 Subject: add stars and velocity --- src/lib/sampler.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/lib/sampler.js') diff --git a/src/lib/sampler.js b/src/lib/sampler.js index 0db53e1..0a00792 100644 --- a/src/lib/sampler.js +++ b/src/lib/sampler.js @@ -27,7 +27,7 @@ export default class Sampler { }); } - play(time, options) { + play(time, options, velocity) { const sound = options.index ? this.samples[options.index] : choice(this.samples); @@ -41,6 +41,11 @@ export default class Sampler { (options.frequency * choice([0.5, 1]) + randrange(0, 10)) / sound.root; } + if (velocity) { + player.volume.value = (1 - velocity) * -18; + console.log(player.volume.value); + } + player.start(time || 0); } } -- cgit v1.2.3-70-g09d2