On Wed, 27 May 2020, Clemens Ladisch via Alsa-user wrote:

> Robert Bielik wrote:
> > I’d like to know if there is any way to get the following sound chain 
> > through ALSA:
> >
> > Mediaplayer -> dmix -> LADSPA -> plughw:0,0
> 
> The dmix plugin plays shared-memory tricks with the ring buffer and therefore
> requires to run on top of a hw device.
> 
> It might be possible to run dmix on a virtual loopback sound card and route
> that one to the LADSPA plugin, but I guess using PulseAudio would be a better
> idea.

It's possible, and I don't see anything wrong with the idea except at the 
moment it seems to be frightfully buggy.

Here's a snipped of .asoundrc that creates a "local" audio bus which is 
combined with:

  $ modprobe snd-aloop
  $ echo "0,0,0" > /proc/asound/Loopback/timer_source     # your soundcard
  $ alsaloop -C local -P plug:master
  $ aplay -D plug:local music.wav

You'll need to define your "master" device with the LADSPA plugin.

The problems I am having are the "alsaloop" program terminates 
unexpectedly, gets in 100% CPU spin and won't exit, or some lock is taken 
in the kernel that hangs X11 and prevents process termination (kernel 
5.6.14)

I couldn't make head nor tail of alsaloop flow, so I wrote my own code to 
copy audio from one device to another which so far seems much more 
reliable for my case.

#
# The bus for local audio so it can be routed to other applications
#
# Pin the sample rate and format so that the Loopback device isn't
# affected by whichever side is first to open and with which parameters.
#

pcm.local {
        type asym

        #
        # Mix incoming audio from multiple sources
        #

        playback.pcm {
                type dmix
                ipc_key 3187

                slave {
                        rate 48000
                        channels 2
                        format S16_LE
                        buffer_size 4096
                        period_size 256

                        pcm {
                                type hw
                                card "Loopback"
                                device 0
                                subdevice 3
                        }
                }
        }

        #
        # Make it accessable to anyone who wants it
        #

        capture.pcm {
                type dsnoop
                ipc_key 23811

                slave {
                        rate 48000
                        channels 2
                        format S16_LE
                        buffer_size 4096
                        period_size 256

                        pcm {
                                type hw
                                card "Loopback"
                                device 1
                                subdevice 3
                        }
                }
        }
}

pcm.master {
        type ladspa;

        ...   # your chosen configuration here
}

-- 
Mark
_______________________________________________
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user

Reply via email to