No audio Input/Output after custom config.pipewire

I tried to adapt and merge the conf described on the noise-suppression-for-voice gh page. It works if i comment the custom section.
P.S. I would’t like to use noisetorch.

pipewire.nix
{ config, pkgs, ... }:



{


# Enable sound with pipewire.
sound.enable = true;
hardware.pulseaudio.enable = false;
security.rtkit.enable = true;
services.pipewire = {
  enable = true;
  alsa.enable = true;
  alsa.support32Bit = true;
  pulse.enable = true;
  # If you want to use JACK applications, uncomment this
  #jack.enable = true;

  # use the example session manager (no others are packaged yet so this is enabled by default,
  # no need to redefine it in your config for now)
  #media-session.enable = true;
  config.pipewire = {

"context.properties" = {
  "link.max-buffers" = 16;
  "core.daemon" = true;
  "core.name" = "pipewire-0";
  "default.clock.min-quantum" = 16;
  "vm.overrides" = {
    "default.clock.min-quantum" = 1024;
  };
};
"context.spa-libs" = {
  "audio.convert.*" = "audioconvert/libspa-audioconvert";
  "api.alsa.*" = "alsa/libspa-alsa";
  "api.v4l2.*" = "v4l2/libspa-v4l2";
  "api.libcamera.*" = "libcamera/libspa-libcamera";
  "api.bluez5.*" = "bluez5/libspa-bluez5";
  "api.vulkan.*" = "vulkan/libspa-vulkan";
  "api.jack.*" = "jack/libspa-jack";
  "support.*" = "support/libspa-support";
};
"context.modules" = [

###CUSTOM SECTION
{   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}/lib/librnnoise.so";
                  label = "noise_suppressor_mono";
                  control = {
                      "VAD Threshold (%)" = 50;
                      "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;
      };
  };
}
###END

  {
    name = "libpipewire-module-rt";
    args = {
      "nice.level" = -11;
    };
    flags = [
      "ifexists"
      "nofail"
    ];
  }
  {
    name = "libpipewire-module-protocol-native";
  }
  {
    name = "libpipewire-module-profiler";
  }
  {
    name = "libpipewire-module-metadata";
  }
  {
    name = "libpipewire-module-spa-device-factory";
  }
  {
    name = "libpipewire-module-spa-node-factory";
  }
  {
    name = "libpipewire-module-client-node";
  }
  {
    name = "libpipewire-module-client-device";
  }
  {
    name = "libpipewire-module-portal";
    flags = [
      "ifexists"
      "nofail"
    ];
  }
  {
    name = "libpipewire-module-access";
    args = {
      
    };
  }
  {
    name = "libpipewire-module-adapter";
  }
  {
    name = "libpipewire-module-link-factory";
  }
  {
    name = "libpipewire-module-session-manager";
  }
];
"context.objects" = [
  {
    factory = "spa-node-factory";
    args = {
      "factory.name" = "support.node.driver";
      "node.name" = "Dummy-Driver";
      "node.group" = "pipewire.dummy";
      "priority.driver" = 20000;
    };
  }
  {
    factory = "spa-node-factory";
    args = {
      "factory.name" = "support.node.driver";
      "node.name" = "Freewheel-Driver";
      "priority.driver" = 19000;
      "node.group" = "pipewire.freewheel";
      "node.freewheel" = true;
    };
  }
];
"context.exec" = [
  
];
  
#
  };
  
};


}


fixed plugin location to , and still not working.
plugin = "${pkgs.rnnoise-plugin}/lib/ladspa/librnnoise_ladspa.so";

I think i almost got it now.

{

	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_mono";
              control = { "VAD Threshold (%)" = 50.0; };
            }];
          };
          capture.props = { 
		node.name =  "capture.rnnoise_source";
		node.passive = true; };
          playback.props = { 
		node.name =  "rnnoise_source";
		media.class = "Audio/Source"; };
        };
      }

[E][02471.269794] mod.filter-chain | [module-filter-ch: 1901 load_graph()] missing filter.graph property
[E][02471.269940] mod.filter-chain | [module-filter-ch: 2152 pipewire__module_init()] can't load graph: Invalid argument
[E][02471.270172] pw.conf      | [          conf.c:  560 load_module()] 0x55623154e600: could not load mandatory module "libpipewire-module-filter-chain": Invalid argument
[E][02471.270251] default      | [      pipewire.c:  125 main()] failed to create context: Invalid argument

2 Likes

You need to quote dotted attribute names: filter.graph = ..."filter.graph" = ....

Otherwise Nix will translate it to { "filter": { "graph":... } } which is not what you want.

1 Like

thnx, still got some errors but unrelated.