1

I am trying to setup noise cacellation with pipewire on my laptop. I need the noise cancellation because I am recording myself for scholarship purposes.

I found this article below. @joelostblom posted instruction how to setup on pipewire:

  1. Realtime noise-removal with PulseAudio?

Its not working for me. The sound driver is disable.

Here is the code inside my pipewire.conf file:

context.modules = [
    #{ name = <module-name>
    #    [ args  = { <key> = <value> ... } ]
    #    [ flags = [ [ ifexists ] [ nofail ] ]
    #}
    #
    # Loads a module with the given parameters.
    # If ifexists is given, the module is ignored when it is not found.
    # If nofail is given, module initialization failures are ignored.
    #

    # Uses realtime scheduling to boost the audio thread priorities. This uses
    # RTKit if the user doesn't have permission to use regular realtime
    # scheduling.
    { name = libpipewire-module-echo-cancel
      args = {
          # library.name  = aec/libspa-aec-webrtc
          # node.latency = 1024/48000
          source.props = {
             node.name = "Echo Cancellation Source"
          }
          sink.props = {
             node.name = "Echo Cancellation Sink"
          }
       }
    }
    { name = libpipewire-module-rt
        args = {
            nice.level    = -11
            #rt.prio      = 88
            #rt.time.soft = -1
            #rt.time.hard = -1
        }
        flags = [ ifexists nofail ]
    }

    # The native communication protocol.
    { name = libpipewire-module-protocol-native }

    # The profile module. Allows application to access profiler
    # and performance data. It provides an interface that is used
    # by pw-top and pw-profiler.
    { name = libpipewire-module-profiler }

    # Allows applications to create metadata objects. It creates
    # a factory for Metadata objects.
    { name = libpipewire-module-metadata }

    # Creates a factory for making devices that run in the
    # context of the PipeWire server.
    { name = libpipewire-module-spa-device-factory }

    # Creates a factory for making nodes that run in the
    # context of the PipeWire server.
    { name = libpipewire-module-spa-node-factory }

    # Allows creating nodes that run in the context of the
    # client. Is used by all clients that want to provide
    # data to PipeWire.
    { name = libpipewire-module-client-node }

    # Allows creating devices that run in the context of the
    # client. Is used by the session manager.
    { name = libpipewire-module-client-device }

    # The portal module monitors the PID of the portal process
    # and tags connections with the same PID as portal
    # connections.
    { name = libpipewire-module-portal
        flags = [ ifexists nofail ]
    }

    # The access module can perform access checks and block
    # new clients.
    { name = libpipewire-module-access
        args = {
            # access.allowed to list an array of paths of allowed
            # apps.
            #access.allowed = [
            #    /usr/bin/pipewire-media-session
            #]

            # An array of rejected paths.
            #access.rejected = [ ]

            # An array of paths with restricted access.
            #access.restricted = [ ]

            # Anything not in the above lists gets assigned the
            # access.force permission.
            #access.force = flatpak
        }
    }

    # Makes a factory for wrapping nodes in an adapter with a
    # converter and resampler.
    { name = libpipewire-module-adapter }

    # Makes a factory for creating links between ports.
    { name = libpipewire-module-link-factory }

    # Provides factories to make session manager objects.
    { name = libpipewire-module-session-manager }

    # Use libcanberra to play X11 Bell
    { name = libpipewire-module-x11-bell
        args = {
            #sink.name = ""
            #sample.name = "bell-window-system"
            #x11.display = null
            #x11.xauthority = null
        }
        flags = [ ifexists nofail ]
    }
]
krillavilla
  • 420
  • 4
  • 18

2 Answers2

0

I have figure out my Solution! Below is the end results:

end results

I HAVE NOT TESTED IT YET!!!!

These article has helped me to my solution:

  1. Real-time Microphone Noise Cancellation on Linux

Here is Real-time Noise Suppression Plugin Github Respository for PipeWire:

  1. Real-time Noise Suppression Plugin

Here is simplify instruction I followed that has helped me. Feel free to correct my commands:

Go to your Download Folder:

cd ~/Downloads

Download the latest version for Real-time Noise Suppression Plugin in your Downloads folder:

Here is the link > Noise Suppression v1.03 (VST2, VST3, LV2, LADSPA, AU, AUv3

Noise

Extract linux-rnnoise.zip file in your Download folder

if you don't have /usr/lib/ladspa folder in your usr path, create one:

sudo mkdir /usr/lib/ladspa/

copy librnnoise_ladspa.so plugin in your /usr/lib/ladspa:

REPLACE <USERNAME> with your username!

sudo cp ~/Downloads/linux-rnnoise/ladspa/librnnoise_ladspa.so /usr/lib/ladspa

Create a configuration directory to store filter chain configuration files

mkdir -p ~/.config/pipewire/

Create a filter chain file with the name “input-filter-chain.conf”

gedit ~/.config/pipewire/input-filter-chain.conf

Paste these code in your input-filter-chain.conf file:

# Noise canceling source
#
# start with pipewire -c filter-chain/input-filter-chain.conf
#
context.properties = {
    log.level        = 0
}

context.spa-libs = {
    audio.convert.* = audioconvert/libspa-audioconvert
    support.*       = support/libspa-support
}

context.modules = [
    {   name = libpipewire-module-rtkit
        args = {
            #nice.level   = -11
            #rt.prio      = 88
            #rt.time.soft = 200000
            #rt.time.hard = 200000
        }
        flags = [ ifexists nofail ]
    }
    {   name = libpipewire-module-protocol-native }
    {   name = libpipewire-module-client-node }
    {   name = libpipewire-module-adapter }

    {   name = libpipewire-module-filter-chain
        args = {
            node.name =  "rnnoise_source"
            node.description =  "Noise Canceling source"
            media.name =  "Noise Canceling source"
            filter.graph = {
                nodes = [
                    {
                        type = ladspa
                        name = rnnoise
                        plugin = /usr/lib/ladspa/librnnoise_ladspa.so
                        label = noise_suppressor_stereo
                        control = {
                            "VAD Threshold (%)" 50.0
                        }
                    }
                ]
            }
            capture.props = {
                node.passive = true
            }
            playback.props = {
                media.class = Audio/Source
            }
        }
    }
]

MAKE SURE YOUR PLUGIN VARIABLE IS POINTING TO YOUR PLUGIN!

plugin = /usr/lib/ladspa/librnnoise_ladspa.so

Create the systemd user configuration directory if it does not exist.

mkdir -p ~/.config/systemd/user/

Create a new systemd unit file

gedit ~/.config/systemd/user/pipewire-input-filter-chain.service

Make sure to:

  1. Replace the file name if you have used a different name for the filter chain configuration file.

  2. Replace the <username> with your account username.

[Unit]
Description=PipeWire Input Filter Chain
After=pipewire.service
BindsTo=pipewire.service

[Service]
ExecStart=/usr/bin/pipewire -c /home/<username>/.config/pipewire/input-filter-chain.conf
Type=simple
Restart=on-failure

[Install]
WantedBy=pipewire.service

Reload systemd user unit files

systemctl --user daemon-reload

Enable the created systemd service

systemctl --user enable pipewire-input-filter-chain.service

Start the filter

systemctl --user enable pipewire-input-filter-chain.service

Verify pipewire-input-filter-chain.service status is running

systemctl --user status pipewire-input-filter-chain.service

restart pipewire

systemctl --user restart pipewire.service pipewire-pulse.service

You should be all set!

krillavilla
  • 420
  • 4
  • 18
0

If you're fine with using Flatpak (you just need to enable it in Discover), I'd recommend trying out EasyEffects - which is actually the new name for PulseEffects after a complete rework to target pipewire instead of PulseAudio; it comes with RNNoise out-of-the-box, and a lot of extra goodies, and it's basically plug-and-play and really easy to work with.

It basically wraps all the work you had to do with pipewire, filters and RNNoise in a "KISS" GUI.

Mismatch
  • 101