From 427cca3e4c01b1e430466b323d3894ab162cabf1 Mon Sep 17 00:00:00 2001 From: Intel A80486DX2-66 Date: Fri, 12 Jul 2024 03:14:00 +0300 Subject: [PATCH] bytebeat-render.js: define functions `min`, `max` --- js-programming/bytebeat-render.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/js-programming/bytebeat-render.js b/js-programming/bytebeat-render.js index f810c73..c9c16bb 100644 --- a/js-programming/bytebeat-render.js +++ b/js-programming/bytebeat-render.js @@ -56,6 +56,8 @@ var cosh = Math.cosh var floor = Math.floor var log = Math.log var log2 = Math.log2 +var max = Math.max +var min = Math.min var PI = Math.PI var pow = Math.pow var random = Math.random @@ -105,12 +107,12 @@ let filePath = generateRandomFilePath() writeFileSync(filePath, Buffer.alloc(0)) // the loop of sequential file writing, created to ease load on RAM -const max = Math.floor((PRODUCT + (BUFFER_SIZE - 1)) / BUFFER_SIZE), - needTwoBuffers = max > 1, needSingleBuffer = !needTwoBuffers +const buffer_max = Math.floor((PRODUCT + (BUFFER_SIZE - 1)) / BUFFER_SIZE), + needTwoBuffers = buffer_max > 1, needSingleBuffer = !needTwoBuffers let audioData = new Uint8Array(needSingleBuffer ? PRODUCT : BUFFER_SIZE) -for (let seq = 0; seq < max; seq++) { +for (let seq = 0; seq < buffer_max; seq++) { if (needTwoBuffers && (t + BUFFER_SIZE) >= PRODUCT) { let calculatedSize = PRODUCT - t audioData = new Uint8Array(calculatedSize)