From cdc687d35b2ab4824f90a0ae2061349754adb480 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Fri, 26 Jun 2020 04:38:26 +0100 Subject: feat(tools/nsfv-setup): Move NSFV setup script out of //users This program can be used for noise-cancelling in arbitrary audio streams. See CL/576 and CL/577 for more details. This moves the script out of my users folder and to //tools, and adds two changes: * Existing sinks will be removed & reinitialised * The sink is changed from stereo->mono (which seems to make little difference but is more reliable) * The parameter has changed from 50 to 42 because I felt like it Change-Id: Id9ff285fefd682ccc4d9f18e46b5fde9cd056aa7 Reviewed-on: https://cl.tvl.fyi/c/depot/+/578 Reviewed-by: glittershark --- tools/nsfv-setup/default.nix | 27 +++++++++++++++++++++++++++ users/tazjin/nsfv-setup/default.nix | 18 ------------------ 2 files changed, 27 insertions(+), 18 deletions(-) create mode 100644 tools/nsfv-setup/default.nix delete mode 100644 users/tazjin/nsfv-setup/default.nix diff --git a/tools/nsfv-setup/default.nix b/tools/nsfv-setup/default.nix new file mode 100644 index 0000000000..aa3567c56a --- /dev/null +++ b/tools/nsfv-setup/default.nix @@ -0,0 +1,27 @@ +# Configures a running Pulseaudio instance with an LADSP filter that +# creates a noise-cancelling sink. +# +# This can be used to, for example, cancel noise from an incoming +# video conferencing audio stream. +# +# There are some caveats, for example this will not distinguish +# between noise from different participants and I have no idea what +# happens if the default sink goes away. +# +# If this script is run while an NSFV sink exists, the existing sink +# will first be removed. +{ pkgs, ... }: + +let + inherit (pkgs) ripgrep pulseaudio nsfv; +in pkgs.writeShellScriptBin "nsfv-setup" '' + export PATH="${ripgrep}/bin:${pulseaudio}/bin:$PATH" + + if pacmd list-sinks | rg librnnoise_ladspa.so >/dev/null; then + pactl unload-module module-ladspa-sink + fi + + SINK=$(${pulseaudio}/bin/pacmd info | ${ripgrep}/bin/rg -r '$1' '^Default sink name: (.*)$') + echo "Setting up NSFV filtering to sink ''${SINK}" + ${pulseaudio}/bin/pacmd load-module module-ladspa-sink sink_name=NSFV sink_master=''${SINK} label=noise_suppressor_mono plugin=${pkgs.nsfv}/lib/ladspa/librnnoise_ladspa.so control=42 +'' diff --git a/users/tazjin/nsfv-setup/default.nix b/users/tazjin/nsfv-setup/default.nix deleted file mode 100644 index 65f94034da..0000000000 --- a/users/tazjin/nsfv-setup/default.nix +++ /dev/null @@ -1,18 +0,0 @@ -# Configures a running Pulseaudio instance with an LADSP filter that -# creates a noise-cancelling sink. -# -# This can be used to, for example, cancel noise from an incoming -# video conferencing audio stream. -# -# There are some caveats, for example this will not distinguish -# between noise from different participants and I have no idea what -# happens if the default sink goes away. -{ pkgs, ... }: - -let - inherit (pkgs) ripgrep pulseaudio nsfv; -in pkgs.writeShellScriptBin "nsfv-setup" '' - SINK=$(${pulseaudio}/bin/pacmd info | ${ripgrep}/bin/rg -r '$1' '^Default sink name: (.*)$') - echo "Setting up NSFV filtering to sink ''${SINK}" - ${pulseaudio}/bin/pacmd load-module module-ladspa-sink sink_name=NSFV sink_master=''${SINK} label=noise_suppressor_stereo plugin=${pkgs.nsfv}/lib/ladspa/librnnoise_ladspa.so control=50 -'' -- cgit 1.4.1