bmc0 / dsp

An audio processing program with an interactive mode.
ISC License
219 stars 31 forks source link

dmix not working with dsp #70

Closed xeaal closed 1 month ago

xeaal commented 2 months ago

Hello. Thank you for this great project, I haven't even know something like this was made for alsa, that life changing. I only wanted to use equalizer and it worked fine for me, somehow I was able to set it up on my own, however, I ran into some problems. It seems that having only dsp configured in .asoundrc doesn't enable dmix by default (at least for me). I tried to set it up as well, integrate it into the config, but it always doesn't work, I just don't really understand where and how do I have to put it in the config for it to work. Configuration with only dmix works fine, though it's pointless I suppose as dmix works by default for me (without dsp). I also found some other issue here that contained a config with dmix, but this didn't work for me. Here's how my configuration file looks like, with different variants of this setup (none of which worked):

#pcm.dsp {
#   type plug
#   slave.pcm {
#       type dmix
#       ipc_key 1024
#       slave {
#           format FLOAT
#           rate unchanged
#           channels unchanged
#           pcm {
#               type ladspa
#               path "/usr/lib/ladspa"
#               playback_plugins [{
#                   label "ladspa_dsp:epz"
#               }]
#               slave.pcm {
#                   type.plug
#                   slave {
#                       pcm "hw:0,0"
#                       rate unchanged
#                       channels unchanged
#                   }
#               }
#           }
#       }
#       bindings {
#           0 0
#           1 1
#       }
#   }
#}

#pcm.dmixer {
#   type dmix
#   ipc_key 1024
#   slave.pcm {
#       pcm "hw:0,0"
#       rate unchanged
#       channels unchanged
#   }
#   bindings {
#       0 0
#       1 1
#   }
#}

pcm.dsp {
    type plug
    slave {
        format FLOAT
        rate unchanged
        channels unchanged
        pcm {
            type ladspa
            path "/usr/lib/ladspa"
            playback_plugins [{
                label "ladspa_dsp:epz"
            }]
            slave.pcm {
                type plug
                slave.pcm "dmix"
            }
        }
    }
}

pcm.!default {
    type copy
    slave.pcm "dsp"
}
xeaal commented 2 months ago

Nevermind, I got it to work, turns out small mistakes here and there, and system specific moments, or probably even my stupidity, I forgot to reload alsa a couple of times which is why it was giving me some errors. Just in case, here's my final configuration, maybe it will be useful for someone else:

pcm.snd_card {
    type hw
    card "AUDIO"
}

ctl.!default {
    type hw
    card "AUDIO"
}

pcm.dmixer {
    type dmix
    ipc_key 1
    slave {
        pcm "snd_card"
#       rate unchanged
#       channels unchanged
    }
    bindings {
        0 0
        1 1
    }
}

pcm.dsp {
    type plug
    slave {
        format FLOAT
        rate unchanged
        channels unchanged
        pcm {
            type ladspa
            path "/usr/lib/ladspa"
            playback_plugins [{
                label "ladspa_dsp:epz"
            }]
            slave.pcm {
                type plug
                slave {
                    pcm "dmixer"
#                   rate unchanged
#                   channels unchanged
                }
            }
        }
    }
}

pcm.!default {
    type copy
    slave.pcm "dsp"
}
xeaal commented 2 months ago

Sadly I return with issue still being partially unresolved. I am not sure if this is the right place to report this issue, but I hope it's not excessive to post it here. I got sound working from multiple sources working but only partially, for example I can use firefox, cmus and run speaker-test in terminal and hear all of these programs. But for some reason it doesn't work with certain programs, mostly with steam and non-native (though few native too) games. I get the sound from them if I run them first thing the os launches, but then everywhere else the sound doesn't work (same programs described previously), says device or resource is busy. And if I first run some other program like firefox or cmus, steam and games don't have sound. I checked and with configuration like this it works perfectly fine, all of it and at the same time:

defaults.pcm.card 0;
defaults.ctl.card 0;

I don't really understand what's wrong with my setup.

xeaal commented 1 month ago

I suppose this might have something in common with issue #49. though not entirely I guess, because I can get the sound but then nothing else can play. Anyway, just in case I tried building with options you provided, but it didn't give any result, it just said there's nothing to make.

xeaal commented 1 month ago

So, apparently the problem is in steam itself. I read the output (read it before, now more carefully) that it gives when launching a game with proton and there's a message that alsa can't find plugin. That's because all these games are now run in containers and you have to manually add plugins to runtime files, I think, so that everything runs without trouble. So one solution is launching the games directly through wine (or proton, at least not from steam), and the second one is to somehow add files to runtime, but I wasn't successful at that. Another problem is 32-bit version of plugin. After looking at issue #49 I tried to run CS:CZ and it didn't have any sound. I then tried the command you provided there and it didn't want to do anything. After running make clean it actually did build it and after moving plugin to /usr/lib under a name ladspa_dsp_32.so CS:CZ had sound working. It would be great if you would include building and installing a 32-bit version of the plugin by default, so that there is no confusion and need to run additional commands. Thank you.