Git Product home page Git Product logo

Comments (8)

Xeonzinc avatar Xeonzinc commented on July 26, 2024 1

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.

Xeonzinc avatar Xeonzinc commented on July 26, 2024

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.

nacgarg avatar nacgarg commented on July 26, 2024

Just submitted a PR to fix this (#154) since I was running into the same problem.

from node-speaker.

Xeonzinc avatar Xeonzinc commented on July 26, 2024

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.

nacgarg avatar nacgarg commented on July 26, 2024

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.

nacgarg avatar nacgarg commented on July 26, 2024

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.

Xeonzinc avatar Xeonzinc commented on July 26, 2024

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.

nacgarg avatar nacgarg commented on July 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.