How to use node-lame - 4 common examples

To help you get started, we’ve selected a few node-lame examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github collective-soundworks / soundworks / src / server / utils / Slicer.js View on Github external
// const actualChunkDuration = baseChunkDuration + (Math.random() * 0.5 - 0.25) * baseChunkDuration;
        const chunked = this.getChunk(metaBuffer, chunkStart, baseChunkDuration + overlapDuration);
        // chunk times rounded to actual samples: updated values
        chunkStart = chunked.chunkStart;
        const chunkDuration = chunked.chunkDuration;
        const chunkBuffer = chunked.chunkBuffer;

        const overlapStart = chunkStart > overlapDuration ? overlapDuration : 0;
        overlapEnd = chunkStart + chunkDuration + overlapDuration < totalDuration ? overlapDuration : 0;

        const filename = `${chunkIndex}-${input.name}.${outputExtension}`;
        const chunkPath = path.join(outputDir, filename);

        if (outputExtension === 'mp3') {
          // need to encode segmented wav buffer to mp3
          const encoder = new Lame({
            output: chunkPath,
            bitrate: this.bitrate,
          });

          encoder.setBuffer(chunkBuffer);
          // @todo - limit the number of processes
          const promise = encoder.encode().catch((error) => {
            console.error(`Error with lame ${error.message}`);
            throw error;
          });

          encoderPromises.push(promise);
        } else {
          // wav output
          fs.writeFile(chunkPath, chunkBuffer, (error) => {
            if (error) {
github Kefir100 / radio-ch1ller / src / tools / mp3converter.js View on Github external
const resampleFileAsync = ({ file, path }, cb) => {
  const [fileNameNoFormat, format] = file.split('.');
  const input = `${path}/${fileNameNoFormat}.${format}`;
  const output = getOutputPath(`${fileNameNoFormat}.mp3`);

  const encoder = new Lame({
    output,
    bitrate: 128,
    resample: 44.1,
    meta: createId3TagsSchema({ fileName: file }),
  }).setFile(input);

  return encoder.encode()
    .then(() => {
      cb({ file, path});
    });
};
github generative-music / generative.fm / node_scripts / wav-to-mp3.js View on Github external
files.forEach(filename => {
    const basename = path.basename(filename, '.wav');
    const decoder = new Lame({
      output: `./samples/vsco2-violins-susvib-mp3/${basename}.mp3`,
    }).setFile(filename);
    decoder.decode();
  });
});
github deermichel / spotify-recorder / recorder.js View on Github external
const encode = (wavFile, mp3File, trackMetadata) => {
    return new lame.Lame({
        bitrate: 320,
        output: mp3File,
        quality: 2,
        meta: trackMetadata
    }).setFile(wavFile).encode()
}

node-lame

LAME MP3 encoder for Node.js

ISC
Latest version published 3 years ago

Package Health Score

51 / 100
Full package analysis

Popular node-lame functions