Miss any of our Open RFC calls?Watch the recordings here! »

audio-track-mixer

0.3.4 • Public • Published

Audio Track Mixer

English | 中文

Mix audio tracks (MediaStreamTrack) into one.

Installation

package manager

Install with npm or yarn

npm:

npm install audio-track-mixer --save

yarn:

yarn add audio-track-mixer

script label

<script src="index.js"></script>

Importing

ES6

import AudioTrackMixer from 'audio-track-mixer';

ES5 with npm

const AudioTrackMixer = require('audio-track-mixer');

script

When use script label, AudioTrackMixer will be a global Object.

Usage

const mixer = new AudioTrackMixer();
 
mixer.addTrack(trackA);
mixer.addTrack(trackB);
 
const mixedTrack = mixer.getMixedTrack();

API

See full APIs.

Some Basic Methods of AudioTrackMixer

1. addTrack

Add audio track into the mixer.

examples
mixer.addTrack(trackA);
mixer.addTrack(trackB);

It's a chain function, so you can also use it just like this

mixer.addTrack(trackA).addTrack(trackB);

2. getMixedTrack

Get mixed audio track from the mixer after adding tracks.

examples
const track = mixer.getMixedTrack();

3. removeTrack

Remove audio track if it has been already added into the mixer or will do nothing.

examples
mixer.removeTrack(trackA);
mixer.removeTrack(trackB);

It's a chain function, so you can also use it just like this

mixer.removeTrack(trackA).removeTrack(trackB);

4. destroy

Clear cache of the mixer to destroy it.

examples
const result = mixer.destroy();

Install

npm i audio-track-mixer

DownloadsWeekly Downloads

30

Version

0.3.4

License

MIT

Unpacked Size

10.1 kB

Total Files

5

Last publish

Collaborators

  • avatar