How do I add LADSPA plugin into pipewire configuration to be used for audio postprocessing?
There are number of existing ladspa plugins.
The ladspa plugin must work on stereo (two channels) audio.
There is an existing pipewire module that can encapsulate any number of ladspa plugins called filter-chain
First we need to add filter-chain module in our build system. In yocto bitbake recipe it is added like this:
RDEPENDS_libpipewire += " \
${PN}-modules-client-node \
+ ${PN}-modules-filter-chain \
.....
Then add appropriate pipewire.conf block using the filter-chain to add the specific ladspa plugin when pipewire is started:
{ name = libpipewire-module-filter-chain
args = {
node.name = "processing_name"
node.description = "Specifc postprocessing"
media.name = "Specifc postprocessing"
filter.graph = {
nodes = [
{
type = ladspa
name = plugin_name
plugin = libplugin_name
label = plugin_name #this needs to correspond to ladspa plugin code
control = {
"Some control" = 1234
}
}
]
}
capture.props = {
node.passive = true
media.class = Audio/Sink
audio.channels=2
audio.position=[FL,FR]
}
playback.props = {
media.class = Audio/Source
audio.channels=2
audio.position=[FL,FR]
}
}
}
The main point of integration is the label
part in the node block. This must correspond with ladspa plugin code. I think ladspa id can be used instead.
Then the capture/playback props determine if the ladspa plugins will have stereo channels for processing and they describe type of nodes that are created for output and input.
Every postprocessing node has implicitly two nodes - one for input and another one for output.
Afterwards the ladspa plugin needs to be connected with the session manager of choice. In case of wireplumber
we may use lua script to detect and connect the plugin nodes to appropriate sinks (alsa sink for example) and client nodes.
Example graph: