1
0
mirror of https://gitlab.com/80486DX2-66/gists synced 2024-11-08 08:54:34 +05:30

bytebeat-render.js: define functions min, max

This commit is contained in:
Intel A80486DX2-66 2024-07-12 03:14:00 +03:00
parent 233a5704ce
commit 427cca3e4c
Signed by: 80486DX2-66
GPG Key ID: 83631EF27054609B

View File

@ -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)