Coder Social home page Coder Social logo

Comments (20)

deliciouslytyped avatar deliciouslytyped commented on May 22, 2024 3

Sweet! I got it to work!
In pavucontrol, after starting Bonzomatic, an entry showed up under the Recording tab, and I was able to select Monuitor of Built-in Audio Analog Stereo as the input device.

image

from bonzomatic.

mackron avatar mackron commented on May 22, 2024 1

I've gone ahead and added some logging to dlopen/dlsym upstream. It's in the dev branch at the moment, but I'll merge it to master soonish.

Unfortunately, miniaudio (the audio library Bonzomatic uses) only looks at the default devices

This isn't exactly true. This is only on select backends where it's either not possible or not practical. The ALSA and PulseAudio backends have full support for device enumeration and selection.

from bonzomatic.

deliciouslytyped avatar deliciouslytyped commented on May 22, 2024

My end goal is to loop back my speaker output - my audio configuration does appear to have a monitor device already.

from bonzomatic.

PoroCYon avatar PoroCYon commented on May 22, 2024

Unfortunately, miniaudio (the audio library Bonzomatic uses) only looks at the default devices, and there's no environment variable to override it (unlike with, say, SDL).

On ALSA (when NOT using PulseAudio), the default is dsnoop (or dsnoop:0 or dsnoop:0,0), and if that fails, miniaudio tries to open hw:0,0.

On PulseAudio and JACK, it simply uses whatever the default device is the APIs are giving it.

You could try modifying this code if you want it to force-select a certain backend or device.

from bonzomatic.

deliciouslytyped avatar deliciouslytyped commented on May 22, 2024

I tried poking around there yesterday but I couldn't really find a way to enumerate devices with miniaudio. I tried changing the backends away from NULL but that always failed. I'm also not too great with C++.

from bonzomatic.

Gargaj avatar Gargaj commented on May 22, 2024

I tried poking around there yesterday but I couldn't really find a way to enumerate devices with miniaudio. I tried changing the backends away from NULL but that always failed. I'm also not too great with C++.

Look for ma_context_get_devices

from bonzomatic.

deliciouslytyped avatar deliciouslytyped commented on May 22, 2024

The snippet I used was

    ma_device_info* devinfoarr;
    ma_uint32 devinfocnt;
    ma_context_get_devices(&context, NULL, NULL, &devinfoarr, &devinfocnt);
    printf("devcnt: %i\n");
    for(int i = 0; i < devinfocnt; i++) {
        printf("name:%s\n", (devinfoarr[i]).name);
        }`

but devinfocnt is zero.

EDIT: Yes the devcnt printf is missing it's integer argument.

from bonzomatic.

Gargaj avatar Gargaj commented on May 22, 2024

That's strange, on Windows that returns my correct number of devices.

from bonzomatic.

deliciouslytyped avatar deliciouslytyped commented on May 22, 2024

I guess there could be any number of reasons this goes wrong. The problem then is I'm not sure how to debug it and constrain the possibilities.

from bonzomatic.

Gargaj avatar Gargaj commented on May 22, 2024

Did you try other backends? (First parameter of ma_context_init)

from bonzomatic.

deliciouslytyped avatar deliciouslytyped commented on May 22, 2024
    ma_backend backends[] = { ma_backend_pulseaudio, ma_backend_alsa };
    ma_result result = ma_context_init( backends, 0, &context_config, &context );

gives [FFT] Failed to initialize context: -103

from bonzomatic.

deliciouslytyped avatar deliciouslytyped commented on May 22, 2024

I tried listing playback devices with the earlier snippet:

[FFT] MAL context initialized, backend is 'Null'
devcnt: 0
name:NULL Playback Device

Edit: devcnt says 0 but it should have said 1, see edit @ #104 (comment)

from bonzomatic.

deliciouslytyped avatar deliciouslytyped commented on May 22, 2024

miniaudio uses dlopen so I'll try to check that it's loading the libraries successfully. Setting LD_DEBUG=all in the env gives output that suggests it might not be finding libasound.so and libpulse.so.

from bonzomatic.

deliciouslytyped avatar deliciouslytyped commented on May 22, 2024

Ok, much better. I have devices now at least. Thanks for your patience.
Edit: (Temporarily fixed with LD_PRELOAD)

from bonzomatic.

Gargaj avatar Gargaj commented on May 22, 2024

Can you go into a bit more detail? I don't want this to be one of those threads where years down the line someone else has the same problem and then the final post is "k fixed" with no indication of what was wrong and how it got fixed :)

from bonzomatic.

deliciouslytyped avatar deliciouslytyped commented on May 22, 2024

Ah yeah, I usually do that, thanks for the reminder.
I'm actually working on an updated package for NixOS. We basically have everything in a nonstandard location. I don't remember how dlopen searches for paths (something something RPATH?) but after seeing no devices at all, I got suspicious that miniaudio wasn't seeing anything because it failed to load the audio libraries. So I threw LD_DEBUG=all at it and looked for mentions of libasound.so. I found some, and there weren't any log messages containing search paths that looked right, so I passed a path I knew was correct manually via LD_PRELOAD.

Does miniaudio have some kind of "enable debug messages" mode? It would have been nice to see something like a list of loaded / not loaded backends.

I still have to figure out how to get the right device though.

I'm hoping I can just set the default input device in pavucontrol or something. (technically that's pulseaudio, not alsa, but it doesn't make a difference to me).

from bonzomatic.

Gargaj avatar Gargaj commented on May 22, 2024

Does miniaudio have some kind of "enable debug messages" mode? It would have been nice to see something like a list of loaded / not loaded backends.

Yes, put this before #include <miniaudio.h>:

#define MA_LOG_LEVEL <Level>
  Sets the logging level. Set level to one of the following:
    MA_LOG_LEVEL_VERBOSE
    MA_LOG_LEVEL_INFO
    MA_LOG_LEVEL_WARNING
    MA_LOG_LEVEL_ERROR

from bonzomatic.

deliciouslytyped avatar deliciouslytyped commented on May 22, 2024

I put #define MA_LOG_LEVEL MA_LOG_LEVEL_VERBOSE on the first line of FFT.cpp but it doesn't seem to leave any more messages than before.

from bonzomatic.

Gargaj avatar Gargaj commented on May 22, 2024

There's not a lot of logging going on in MA; if you feel there's an issue on their side, you could probably head over to https://github.com/dr-soft/miniaudio and see if you can suggest something on their end.

from bonzomatic.

deliciouslytyped avatar deliciouslytyped commented on May 22, 2024

I think I'll open an issue requesting more logging then.

By the way, here's an example of the output of my printf:

devinfocnt: 2
name:Discard all samples (playback) or generate zero samples (capture)
name:Default Audio Device (via PulseAudio)

from bonzomatic.

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.