audio-track-mixer
v1.0.1
Published
A mixer which can mix two (or more) audio tracks (MediaStreamTrack) into one.
Downloads
1,803
Maintainers
Readme
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();