diff --git a/js-programming/bytebeat-render.js b/js-programming/bytebeat-render.js index 47ffe59..2e24d54 100644 --- a/js-programming/bytebeat-render.js +++ b/js-programming/bytebeat-render.js @@ -61,7 +61,14 @@ const generateAudio = t => { return t&t>>8 } +let lastCorrectSample = 127 // FIXME: guessed value + const constrainValue = sample => { + if (isNaN(sample) || sample < 0) + sample = lastCorrectSample + else + lastCorrectSample = sample + switch (SELECTED_TYPE) { case TYPE_BYTEBEAT: return sample & 255