tvl-depot/tools/nsfv-setup/default.nix
Vincent Ambo aa122cbae7 style: format entire depot with nixpkgs-fmt
This CL can be used to compare the style of nixpkgs-fmt against other
formatters (nixpkgs, alejandra).

Change-Id: I87c6abff6bcb546b02ead15ad0405f81e01b6d9e
Reviewed-on: https://cl.tvl.fyi/c/depot/+/4397
Tested-by: BuildkiteCI
Reviewed-by: sterni <sternenseemann@systemli.org>
Reviewed-by: lukegb <lukegb@tvl.fyi>
Reviewed-by: wpcarro <wpcarro@gmail.com>
Reviewed-by: Profpatsch <mail@profpatsch.de>
Reviewed-by: kanepyork <rikingcoding@gmail.com>
Reviewed-by: tazjin <tazjin@tvl.su>
Reviewed-by: cynthia <cynthia@tvl.fyi>
Reviewed-by: edef <edef@edef.eu>
Reviewed-by: eta <tvl@eta.st>
Reviewed-by: grfn <grfn@gws.fyi>
2022-01-31 16:11:53 +00:00

29 lines
1.1 KiB
Nix

# 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.
{ depot, pkgs, ... }:
let
inherit (pkgs) ripgrep pulseaudio;
inherit (depot.third_party) 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=${nsfv}/lib/ladspa/librnnoise_ladspa.so control=42 rate=48000
''