Skip to content

PCM audio mixer with customizable parameters

License

Notifications You must be signed in to change notification settings

AlexPl3331/node-audio-mixer

Repository files navigation

Node.js Audio Mixer

Npm packet

About

Audio mixer that allows mixing PCM audio streams with customizable parameters.

Installation

Node.js 18.0.0 or newer is required.

npm:

npm install node-audio-mixer

pnpm:

pnpm install node-audio-mixer

yarn:

yarn install node-audio-mixer

Example usage

import {createReadStream, createWriteStream} from "fs";
import {AudioMixer} from "node-audio-mixer";

const mixer = new AudioMixer({
    sampleRate: 48000,
    bitDepth: 16,
    channels: 1,
    autoClose: true,
});

const firstInput = mixer.createAudioInput({
    sampleRate: 48000,
    bitDepth: 16,
    channels: 1,
});
const secondInput = mixer.createAudioInput({
    sampleRate: 48000,
    bitDepth: 16,
    channels: 1,
});

const outputAudio = createWriteStream("mixed.pcm");

const firstAudio = createReadStream("firstAudio.pcm");
const secondAudio = createReadStream("secondAudio.pcm");

mixer.pipe(outputAudio);

firstAudio.pipe(firstInput);
secondAudio.pipe(secondInput);

More examples you can find here

API Documentation

You can find it here

Changelog

You can view the changelogs on GitHub releases

License

MIT