1
0
mirror of https://gitlab.com/80486DX2-66/gists synced 2024-09-19 14:55:34 +05:30

bytebeat-render.js: rename *Name to *Path

This commit is contained in:
Intel A80486DX2-66 2024-01-05 20:12:57 +03:00
parent ab8843ee14
commit 0eaced9cde
Signed by: 80486DX2-66
GPG Key ID: 83631EF27054609B

View File

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