From ee6c5287b419f20b7019bf3761ce64e6f8970e22 Mon Sep 17 00:00:00 2001 From: Geir Okkenhaug Jerstad Date: Wed, 18 Jun 2025 21:00:14 +0200 Subject: [PATCH] Fix PipeWire configuration: use extraConfig.pipewire and remove duplicates - Use proper services.pipewire.extraConfig.pipewire for noise suppression - Add rnnoise-plugin to system packages - Remove duplicate environment.etc configuration - Simplify configuration structure --- modules/sound/pipewire.nix | 157 ++++++++++++------------------------- 1 file changed, 49 insertions(+), 108 deletions(-) diff --git a/modules/sound/pipewire.nix b/modules/sound/pipewire.nix index 0d37a5a..b83fbe1 100644 --- a/modules/sound/pipewire.nix +++ b/modules/sound/pipewire.nix @@ -15,19 +15,61 @@ alsa.support32Bit = true; pulse.enable = true; jack.enable = true; - + # Enable WirePlumber session manager wireplumber.enable = true; - - # Add noise suppression and audio processing packages - extraPackages = with pkgs; [ - rnnoise-plugin # RNNoise noise suppression - easyeffects # Modern audio effects and filters - ]; + + # Extra configuration for noise suppression + extraConfig.pipewire."10-noise-suppression" = { + "context.properties" = { + "default.clock.rate" = 48000; + "default.clock.quantum" = 1024; + "default.clock.min-quantum" = 32; + "default.clock.max-quantum" = 2048; + }; + + "context.modules" = [ + { + name = "libpipewire-module-filter-chain"; + args = { + "node.description" = "Noise Canceling Source"; + "media.name" = "Noise Canceling Source"; + "filter.graph" = { + nodes = [ + { + type = "ladspa"; + name = "rnnoise"; + plugin = "${pkgs.rnnoise-plugin}/lib/ladspa/librnnoise_ladspa.so"; + label = "noise_suppressor_stereo"; + control = { + "VAD Threshold (%)" = 50.0; + "VAD Grace Period (ms)" = 200; + "Retroactive VAD Grace (ms)" = 0; + }; + } + ]; + }; + "capture.props" = { + "node.name" = "capture.rnnoise_source"; + "node.passive" = true; + "audio.rate" = 48000; + }; + "playback.props" = { + "node.name" = "rnnoise_source"; + "media.class" = "Audio/Source"; + "audio.rate" = 48000; + }; + }; + } + ]; + }; }; # Install audio management and GUI applications environment.systemPackages = with pkgs; [ + # Noise suppression plugin + rnnoise-plugin # RNNoise LADSPA plugin + # Audio control and monitoring pavucontrol # PulseAudio volume control (works with PipeWire) helvum # Graphical patchbay for PipeWire @@ -49,107 +91,6 @@ # carla # Audio plugin host ]; - # System-wide PipeWire configuration - environment.etc = { - # Main PipeWire configuration - "pipewire/pipewire.conf.d/10-noise-suppression.conf".text = '' - context.properties = { - default.clock.rate = 48000 - default.clock.quantum = 1024 - default.clock.min-quantum = 32 - default.clock.max-quantum = 2048 - } - - context.modules = [ - { - name = libpipewire-module-filter-chain - args = { - node.description = "Noise Canceling Source" - media.name = "Noise Canceling Source" - filter.graph = { - nodes = [ - { - type = ladspa - name = rnnoise - plugin = ${pkgs.rnnoise-plugin}/lib/ladspa/librnnoise_ladspa.so - label = noise_suppressor_stereo - control = { - "VAD Threshold (%)" = 50.0 - "VAD Grace Period (ms)" = 200 - "Retroactive VAD Grace (ms)" = 0 - } - } - ] - } - capture.props = { - node.name = "capture.rnnoise_source" - node.passive = true - audio.rate = 48000 - } - playback.props = { - node.name = "rnnoise_source" - media.class = "Audio/Source" - audio.rate = 48000 - } - } - } - ] - ''; - - # WirePlumber configuration for noise suppression - "wireplumber/wireplumber.conf.d/51-noise-suppression.conf".text = '' - monitor.alsa.rules = [ - { - matches = [ - { - device.name = "~alsa_card.*" - } - ] - actions = { - update-props = { - device.profile-set = "auto" - device.auto-profile = true - } - } - } - ] - - monitor.bluez.rules = [ - { - matches = [ - { - device.name = "~bluez_card.*" - } - ] - actions = { - update-props = { - bluez5.auto-connect = [ "hfp_hf" "hsp_hs" "a2dp_sink" ] - bluez5.hw-volume = [ "hfp_hf" "hsp_hs" "a2dp_sink" ] - } - } - } - ] - ''; - - # Audio quality and latency optimization - "pipewire/pipewire-pulse.conf.d/10-audio-quality.conf".text = '' - pulse.properties = { - pulse.min.req = 32/48000 - pulse.default.req = 1024/48000 - pulse.min.quantum = 32/48000 - pulse.max.quantum = 2048/48000 - } - - stream.properties = { - node.latency = 1024/48000 - resample.quality = 4 - channelmix.normalize = false - channelmix.mix-lfe = false - session.suspend-timeout-seconds = 0 - } - ''; - }; - # Enable real-time audio processing security.rtkit.enable = true;