English | δΈζ
Mix audio tracks (MediaStreamTrack) into one.
Install with npm
or yarn
npm:
npm install audio-track-mixer --save
yarn:
yarn add audio-track-mixer
<script src="index.js"></script>
import AudioTrackMixer from 'audio-track-mixer';
const AudioTrackMixer = require('audio-track-mixer');
When use script label, AudioTrackMixer will be a global Object.
const mixer = new AudioTrackMixer();
mixer.addTrack(trackA);
mixer.addTrack(trackB);
const mixedTrack = mixer.getMixedTrack();
See full APIs.
Add audio track into the mixer.
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);
Get mixed audio track from the mixer after adding tracks.
const track = mixer.getMixedTrack();
Remove audio track if it has been already added into the mixer or will do nothing.
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);
Clear cache of the mixer to destroy it.
const result = mixer.destroy();