From 0eaced9cde6632b3c5323f1408f401aced217f6f Mon Sep 17 00:00:00 2001 From: Intel A80486DX2-66 Date: Fri, 5 Jan 2024 20:12:57 +0300 Subject: [PATCH] bytebeat-render.js: rename `*Name` to `*Path` --- js-programming/bytebeat-render.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/js-programming/bytebeat-render.js b/js-programming/bytebeat-render.js index 8714fef..342d72f 100644 --- a/js-programming/bytebeat-render.js +++ b/js-programming/bytebeat-render.js @@ -72,7 +72,7 @@ const random_choice = choices => choices[Math.floor(Math.random() * choices.leng const randomFileNameAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-" -const generateRandomFileName = () => { +const generateRandomFilePath = () => { let res = tmpdir() + "/" + basename(__filename) + "_" for (let i = 0; i < 64; i++) res += random_choice(randomFileNameAlphabet) @@ -81,8 +81,8 @@ const generateRandomFileName = () => { let t = 0 -let fileName = generateRandomFileName() -writeFileSync(fileName, Buffer.alloc(0)) +let filePath = generateRandomFilePath() +writeFileSync(filePath, Buffer.alloc(0)) // the loop of sequential file writing, created to ease load on RAM for (let buffer = 0; t < PRODUCT; buffer++) { @@ -106,12 +106,12 @@ for (let buffer = 0; t < PRODUCT; buffer++) { audioData = truncatedArray } - appendFileSync(fileName, Buffer.from(audioData.buffer)) + appendFileSync(filePath, Buffer.from(audioData.buffer)) audioData = null } execSync( `ffmpeg -f u8 -ar ${FINAL_SAMPLE_RATE} -ac ${CHANNELS} ` + - `-i ${fileName} output_${+new Date()}.wav`) -unlinkSync(fileName) + `-i ${filePath} output_${+new Date()}.wav`) +unlinkSync(filePath)