From aae534308a46db3f52885119575bc30b21a2c70c Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Wed, 25 Dec 2024 09:13:34 -0500 Subject: [PATCH] Add noise supression to microphone. --- nix/configuration/flake.lock | 20 +++++----- .../flakes/zsh-histdb/flake.lock | 6 +-- .../flakes/zsh-histdb/package.nix | 1 + nix/configuration/network.nix | 1 + nix/configuration/roles/sound/default.nix | 38 +++++++++++++++++++ 5 files changed, 53 insertions(+), 13 deletions(-) diff --git a/nix/configuration/flake.lock b/nix/configuration/flake.lock index e64af3f..ed44628 100644 --- a/nix/configuration/flake.lock +++ b/nix/configuration/flake.lock @@ -139,11 +139,11 @@ }, "impermanence": { "locked": { - "lastModified": 1734200366, - "narHash": "sha256-0NursoP4BUdnc+wy+Mq3icHkXu/RgP1Sjo0MJxV2+Dw=", + "lastModified": 1734945620, + "narHash": "sha256-olIfsfJK4/GFmPH8mXMmBDAkzVQ1TWJmeGT3wBGfQPY=", "owner": "nix-community", "repo": "impermanence", - "rev": "c6323585fa0035d780e3d8906eb1b24b65d19a48", + "rev": "d000479f4f41390ff7cf9204979660ad5dd16176", "type": "github" }, "original": { @@ -181,11 +181,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1734323986, - "narHash": "sha256-m/lh6hYMIWDYHCAsn81CDAiXoT3gmxXI9J987W5tZrE=", + "lastModified": 1734991663, + "narHash": "sha256-8T660guvdaOD+2/Cj970bWlQwAyZLKrrbkhYOFcY1YE=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "394571358ce82dff7411395829aa6a3aad45b907", + "rev": "6c90912761c43e22b6fb000025ab96dd31c971ff", "type": "github" }, "original": { @@ -229,11 +229,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1734424634, - "narHash": "sha256-cHar1vqHOOyC7f1+tVycPoWTfKIaqkoe1Q6TnKzuti4=", + "lastModified": 1734649271, + "narHash": "sha256-4EVBRhOjMDuGtMaofAIqzJbg4Ql7Ai0PSeuVZTHjyKQ=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "d3c42f187194c26d9f0309a8ecc469d6c878ce33", + "rev": "d70bd19e0a38ad4790d3913bf08fcbfc9eeca507", "type": "github" }, "original": { @@ -345,7 +345,7 @@ }, "locked": { "lastModified": 1, - "narHash": "sha256-vPz7cJzdLAWFWQQ/KSXGB+HsUfO8CnPX4AO4zjf9llo=", + "narHash": "sha256-Cf8NVSnjPiAi29Df1Tb1Ea6uqISWps5nx3qJl5yAbOo=", "path": "flakes/zsh-histdb", "type": "path" }, diff --git a/nix/configuration/flakes/zsh-histdb/flake.lock b/nix/configuration/flakes/zsh-histdb/flake.lock index b3604a4..a904960 100644 --- a/nix/configuration/flakes/zsh-histdb/flake.lock +++ b/nix/configuration/flakes/zsh-histdb/flake.lock @@ -20,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1734875076, - "narHash": "sha256-Pzyb+YNG5u3zP79zoi8HXYMs15Q5dfjDgwCdUI5B0nY=", + "lastModified": 1734991663, + "narHash": "sha256-8T660guvdaOD+2/Cj970bWlQwAyZLKrrbkhYOFcY1YE=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "1807c2b91223227ad5599d7067a61665c52d1295", + "rev": "6c90912761c43e22b6fb000025ab96dd31c971ff", "type": "github" }, "original": { diff --git a/nix/configuration/flakes/zsh-histdb/package.nix b/nix/configuration/flakes/zsh-histdb/package.nix index 6a43797..d2ea553 100644 --- a/nix/configuration/flakes/zsh-histdb/package.nix +++ b/nix/configuration/flakes/zsh-histdb/package.nix @@ -21,6 +21,7 @@ stdenv.mkDerivation { sha256 = "sha256-vtG1poaRVbfb/wKPChk1WpPgDq+7udLqLfYfLqap4Vg="; }; buildInputs = [ sqlite ]; + phases = [ "installPhase" ]; installPhase = '' mkdir -p $out/share/zsh/plugins/zsh-histdb cp -r $src/histdb-* $src/*.zsh $src/db_migrations $out/share/zsh/plugins/zsh-histdb/ diff --git a/nix/configuration/network.nix b/nix/configuration/network.nix index 3bd4002..562e560 100644 --- a/nix/configuration/network.nix +++ b/nix/configuration/network.nix @@ -42,5 +42,6 @@ iw iwd ldns # for drill + arp-scan # To find devices on the network ]; } diff --git a/nix/configuration/roles/sound/default.nix b/nix/configuration/roles/sound/default.nix index f9fa9d8..88a729b 100644 --- a/nix/configuration/roles/sound/default.nix +++ b/nix/configuration/roles/sound/default.nix @@ -21,5 +21,43 @@ pulse.enable = true; # If you want to use JACK applications, uncomment this #jack.enable = true; + + 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 + audio.rate = 48000 + # Optionally specify a specific input: (ID from `pactl list`) + # target.object = "alsa_input.usb-Shure_Incorporated_Shure_Digital-00.analog-stereo" + } + playback.props = { + node.name = "rnnoise_source" + media.class = Audio/Source + audio.rate = 48000 + } + } + } + ] + '') + ]; }; }