mixing two streams works fine
This commit is contained in:
parent
20cf18ec4c
commit
2aaea9450f
@ -27,15 +27,35 @@ mixer.pipe(speaker);
|
|||||||
* Decode mp3 and add the stream as mixer input:
|
* Decode mp3 and add the stream as mixer input:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var file = fs.createReadStream('example0.mp3');
|
var file0 = fs.createReadStream('example0.mp3');
|
||||||
|
|
||||||
var decoder = new lame.Decoder();
|
var decoder0 = new lame.Decoder();
|
||||||
var mp3stream = file.pipe(decoder);
|
var mp3stream0 = file0.pipe(decoder0);
|
||||||
|
|
||||||
decoder.on('format', function (format) {
|
decoder0.on('format', function (format) {
|
||||||
console.log(format);
|
console.log(format);
|
||||||
|
|
||||||
mp3stream.pipe(mixer.input({
|
mp3stream0.pipe(mixer.input({
|
||||||
|
sampleRate: format.sampleRate,
|
||||||
|
channels: format.channels,
|
||||||
|
bitDepth: format.bitDepth
|
||||||
|
}));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Decode mp3 and add the stream as mixer input:
|
||||||
|
*/
|
||||||
|
|
||||||
|
var file1 = fs.createReadStream('example1.mp3');
|
||||||
|
|
||||||
|
var decoder1 = new lame.Decoder();
|
||||||
|
var mp3stream1 = file1.pipe(decoder1);
|
||||||
|
|
||||||
|
decoder1.on('format', function (format) {
|
||||||
|
console.log(format);
|
||||||
|
|
||||||
|
mp3stream1.pipe(mixer.input({
|
||||||
sampleRate: format.sampleRate,
|
sampleRate: format.sampleRate,
|
||||||
channels: format.channels,
|
channels: format.channels,
|
||||||
bitDepth: format.bitDepth
|
bitDepth: format.bitDepth
|
||||||
|
BIN
example/example1.mp3
Executable file
BIN
example/example1.mp3
Executable file
Binary file not shown.
Loading…
Reference in New Issue
Block a user