mirror of
https://gitlab.com/80486DX2-66/gists
synced 2024-11-08 18:02:23 +05:30
bytebeat-render.js: define functions min
, max
This commit is contained in:
parent
233a5704ce
commit
427cca3e4c
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user