-
Notifications
You must be signed in to change notification settings - Fork 145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Two streams parallel #87
Comments
So it is possible to have multiple speaker streams in parallel. It should work like this (untested): var Speaker = require("speaker");
var lame = require("lame");
var fs = require("fs");
var volume = require("pcm-volume");
var readable = fs.createReadStream("coming-out.mp3");
// see node-lame documentation for more information
var decoder1 = new lame.Decoder({
channels: 2,
bitDepth: 16,
sampleRate: 44100,
bitRate: 128,
outSampleRate: 22050,
mode: lame.STEREO
});
var masterSpeaker = new Speaker();
var masterSpeaker2 = new Speaker();
// Create a volume instance
var v1 = new volume();
v1.pipe(masterSpeaker); // pipe volume to speaker
decoder1.pipe(v1); // pipe PCM data to volume
readable.pipe(decoder1); // pipe file input to decoder
setTimeout(function() {
// Create a volume instance
// see node-lame documentation for more information
var decoder2 = new lame.Decoder({
channels: 2,
bitDepth: 16,
sampleRate: 44100,
bitRate: 128,
outSampleRate: 22050,
mode: lame.STEREO
});
var v2 = new volume();
v2.pipe(masterSpeaker2); // pipe volume to speaker
decoder2.pipe(v2); // pipe PCM data to volume
readable.pipe(decoder2); // pipe file input to decoder
}, 2000); |
Hi, I'm trying to play two streams simultaneously but when I pipe the second speaker it stops the first one. I tried with your code @Mexxxo and I still have this issue. Did it worked for you @ChristianFranke ? |
Hi @remscli , It is maybe possible to combine two streams as one, as possible workaround. |
On a Mac, I have trouble playing two streams at the same time as well. The program does not return. See example here https://gist.github.com/ylh888/51cda38e2b5cfbaa0fa009ed8ef17d53 The code works well as long as the different 'notes' don't overlap in time. When they do, the code does not return. Any help to work around, or at least to avoid infinite loop, would be appreciated. |
Hi! Is it possible to play two pcm-streams parallel? Like..
The text was updated successfully, but these errors were encountered: