Closed ivancevich closed 4 years ago
Obviously a very old issue (but still open). I managed to allow configurable output device selection with the ALSA backend (only tested & probably only working with ALSA).
Changes to index.js:
_open () {
// ...
if (this.device == null) {
debug('setting default %o: %o', 'device', 'default');
this.device = 'default';
}
// ...
}
// ...
_format (opts) {
// ...
if (opts.device != null) {
debug('setting %o: %o', 'device', opts.device)
this.device = opts.device
}
// ...
const r = binding.open(this.audio_handle, this.channels, this.sampleRate, format, this.device)
// ...
}
Changes to binding.cc:
NAN_METHOD(Open) {
// ...
String::Utf8Value str(info[4]->ToString());
ao->device = (char*)*str;
// ...
}
Run node-gyp rebuild
in the module directory to rebuild the bindings/C code.
Instantiate a speaker instance with the 'device' option:
// Create the Speaker instance
const Player = new Speaker({
channels: 1,
bitDepth: 16,
sampleRate: 16000,
// This is the bluez-alsa pseudo-device, & will make the audio stream go to the Bluetooth headset.
device: 'bluealsa:HCI=hci0,DEV=00:6A:8E:16:C5:F2,PROFILE=sco'
});
My fork at https://github.com/rhclayto/node-speaker does this. Hope that helps somebody.
@rhclayto Maybe you should file a pull request? This looks like exactly like what I was going to spend my Sunday doing.
Okie dokie, I created a pull request: https://github.com/TooTallNate/node-speaker/pull/104
This was fixed with #105 released as 0.4.1
All works fine when playing music through the MacBook speakers (on-board audio interface). But, when I switch to an external card (Native Instruments Audio 4 DJ, in my case) no sound is emitted. If I switch back to the internal card it sounds again.