Bursting Microphone

Currently, I have a dual-boot setup where I use both Windows and NixOS.

On Windows, my microphone works normally, without any noise and with the expected volume. However, on NixOS, my microphone is extremely bursty, with the volume being extremely high. With Pipewire, it’s impossible to use, and with PulseAudio, by slightly lowering the sound via pavucontrol, I can get to an okay volume (though still with some noise). Here are the settings I use for Pipewire:

services.pipewire = {
  enable = true;
  alsa = {
    enable = true;
    support32Bit = true;
  };
  pulse = {
    enable = true;
  };
  jack = {
    enable = true;
  };
};

security.rtkit = {
  enable = true;
};

The windows driver for that soundcard might do some noise reduction in software. I believe this sometimes happens for e.g. USB webcams with integrated low-quality microphones.

You can configure the same type of thing using the Pipewire filter-chain module.

Here’s an example:

{
  services.pipewire = {
    extraLv2Packages = [ pkgs.rnnoise-plugin ];
    configPackages = [
      (pkgs.writeTextDir "share/pipewire/pipewire.conf.d/20-rnnoise.conf" ''
        context.modules = [
        {   name = libpipewire-module-filter-chain
            args = {
                node.description = "Noise Canceling source"
                media.name = "Noise Canceling source"
                filter.graph = {
                    nodes = [
                        {
                            type = lv2
                            name = rnnoise
                            plugin = "https://github.com/werman/noise-suppression-for-voice#stereo"
                            label = noise_suppressor_stereo
                            control = {
                            }
                        }
                    ]
                }
                capture.props = {
                    node.name =  "capture.rnnoise_source"
                    node.passive = true
                }
                playback.props = {
                    node.name =  "rnnoise_source"
                    media.class = Audio/Source
                }
            }
        }
        ]
      '')
    ];
  };
}

Restart your pipewire and use pavucontrol to select the capture source.

Other plugins than rnnoise might be more suitable for your setup - I don’t know.

About the services.pipewire.configPackages option. This will declaratively configure pipewire through NixOS. However, while you are experimenting, it may be best to comment out configPackages and just edit files in ~/.config/pipewire/pipewire.conf.d/*.conf.