Comments (8)
I've managed to get the output selection working, the correct device name was being passed to the audio object constructor in index.js, but when the open event was called this has been replaced by another 'device' object which I was defining elsewhere. I must have some bad 'this' scoping somewhere, but it was resolved by a quick rename of my other device variable.
from node-speaker.
Just stumbled across this:
https://sourceforge.net/p/mpg123/bugs/288/
I'm not sure if this means it's not possible to select output devices under windows with node-speaker then?
from node-speaker.
Just submitted a PR to fix this (#154) since I was running into the same problem.
from node-speaker.
I've been testing your version (by forking and releasing privately), but don't seem to be having much luck. I threw in a couple of printf's to see whats going on, but it always seems to think I am not specifying a device. i.e. i always get "Test2b" not "Test2a" from the below:
if (ao->device) {
/* Find device id of device with the same name as ao->device */
/* Device names from waveOutGetDevCaps are limited to 32 */
/* characters, so truncate ao->device for comparison */
printf("Test2a");
ao->device[31] = '\0';
for (UINT i = 0; i < waveOutGetNumDevs(); ++i) {
WAVEOUTCAPS caps;
waveOutGetDevCaps(i, &caps, sizeof(WAVEOUTCAPS));
if (!strcmp(ao->device, caps.szPname)) {
dev_id = i;
break;
}
}
} else {
printf("Test2b");
ao->device = "WaveMapper";
}
@nacgarg did you initialise the speaker object and define the output device differently to my code below? I'm not sure why my device is not getting passed through. Dev_n is my long device name (e.g. "Speakers (USB PnP Sound Device)"), but even if that was spelt wrong it should still try to first if branch?
this.ospeaker = require('speaker');
this.audio_devices_array[a_num].ao = new this.ospeaker({
channels: 2,
bitDepth: 16,
sampleRate: 48000,
device: dev_n
});
from node-speaker.
Hmm, that's strange. I'm initializing the speaker object pretty much the same way as you. Can you check to see if ao->device is defined here (maybe add a printf("device: %s", ao->device)
)? https://github.com/TooTallNate/node-speaker/blob/master/src/binding.c#L60
from node-speaker.
Also, if you want to test my fork without going through the hassle of privately releasing, you can just add "speaker": "https://github.com/nacgarg/node-speaker"
to your package.json
IIRC.
from node-speaker.
It seems that " if (is_string(env, args[3])) {" is not resolving true, so line 60 never gets called. Not sure why right now, I'm learning C++ as we go! I'll see if I can get any more details out later.
Thanks on the second point, I thought my way seemed a bit excessive, I'm still getting to grips with Github
from node-speaker.
Interesting, do you want to try just passing the string in directly? Maybe there's something strange with your dev_n
string? So try something like
new this.ospeaker({
channels: 2,
bitDepth: 16,
sampleRate: 48000,
device: "Speakers (USB PnP Sound Device)"
});
from node-speaker.
Related Issues (20)
- TypeScript missing "device" option
- Memory Leak HOT 1
- Mac OS install error HOT 1
- Failed to install with another backend on Linux
- "binding.node" is not a valid Win32 appliaction
- Cannot use this module from TypeScript HOT 2
- Noise at the beginning of playback
- Change audio output device on Win32 Backend HOT 1
- Does Not Work With Node.js 15+ HOT 3
- Crashes when using in electron app HOT 3
- License listed as MIT, but some of the source lists LGPL HOT 5
- Can't install: mpg123_cpu not defined HOT 2
- Support M1 macOS HOT 6
- Need help for a setup HOT 2
- Trouble installing with M2 chip for Mac HOT 1
- npm install error
- Raspberry Pi 4 (Debian) node-gyp build fails HOT 6
- Installation Error om mac M2 HOT 2
- issues in installing node-speaker
- 'Error: Module did not self-register.' with Worker Threads
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-speaker.