Skip to content

Mix two or more audio tracks into one. 一个可以将多个音轨合并成一个音轨的库。

Notifications You must be signed in to change notification settings

poplark/audio-track-mixer

Repository files navigation

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();

About

Mix two or more audio tracks into one. 一个可以将多个音轨合并成一个音轨的库。

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •