From 0df2f8f4a0aebfe264eb87a39f008a5330ca19f3 Mon Sep 17 00:00:00 2001 From: Intel A80486DX2-66 Date: Sat, 13 Jul 2024 15:41:38 +0300 Subject: [PATCH] bytebeat-render.js: use different `lastCorrectSample` values for different audio types --- js-programming/bytebeat-render.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/js-programming/bytebeat-render.js b/js-programming/bytebeat-render.js index c6f62c3..d0db6d3 100644 --- a/js-programming/bytebeat-render.js +++ b/js-programming/bytebeat-render.js @@ -76,7 +76,18 @@ const generateAudio = t => { const clamp = (a, b, c) => max(min(a, c), b) -let lastCorrectSample = 127 // FIXME: guessed value +let lastCorrectSample +switch (SELECTED_TYPE) { +case TYPE_BYTEBEAT: + lastCorrectSample = 127 + break; +case TYPE_SIGNED_BYTEBEAT: + lastCorrectSample = 0 + break; +case TYPE_FLOATBEAT: + lastCorrectSample = 0.0 + break; +} const constrainValue = sample => { if (isNaN(sample) || sample < 0)