I wrote a function that creates mp3 files from an array of buffers of audio content with all of them concatenated.
const generateAudioFile = async ({ fileName, audioContent }) => {
const writeFile = util.promisify(fs.writeFile);
await writeFile(
path.join(__dirname, 'output', `${fileName}.mp3`),
Buffer.concat(audioContent),
'binary'
);
};
While it does what it is supposed to do, there are no gaps between each audio content, and this is what I am trying to fix. I have tried padding some allocated space after each file like so but it does not do the job:
Buffer.concat([...audioContent.map(ac => Buffer.concat([ac, Buffer.alloc(10000)]))])
How can I add some silence between each audio buffer?