From dc7948a0ef71dfaafb515f2ebc5d26789896503f Mon Sep 17 00:00:00 2001 From: Minijackson Date: Fri, 2 Aug 2024 22:26:55 +0200 Subject: usecases/audio-production: configure low-latency pipewire --- usecases/desktop/graphical/audio-production.nix | 48 +++++++++++++++++++------ 1 file changed, 38 insertions(+), 10 deletions(-) (limited to 'usecases') diff --git a/usecases/desktop/graphical/audio-production.nix b/usecases/desktop/graphical/audio-production.nix index dfbe2b2..94f7501 100644 --- a/usecases/desktop/graphical/audio-production.nix +++ b/usecases/desktop/graphical/audio-production.nix @@ -1,11 +1,7 @@ -inputs: { - pkgs, - lib, - ... -}: { - imports = [ - "${inputs.musnix}" - ]; +inputs: +{ pkgs, lib, ... }: +{ + imports = [ "${inputs.musnix}" ]; musnix.enable = true; @@ -63,10 +59,10 @@ inputs: { soundfont-ydp-grand soundfont-fluid ]; - extraGroups = ["audio"]; + extraGroups = [ "audio" ]; }; - environment.pathsToLink = ["/share/soundfonts"]; + environment.pathsToLink = [ "/share/soundfonts" ]; # TODO: upstream adding user-specific packages environment.variables = { @@ -77,4 +73,36 @@ inputs: { VST_PATH = lib.mkForce "$HOME/.vst:$HOME/.nix-profile/lib/vst:/run/current-system/sw/lib/vst:/etc/profiles/per-user/$USER/lib/vst"; VST3_PATH = lib.mkForce "$HOME/.vst3:$HOME/.nix-profile/lib/vst3:/run/current-system/sw/lib/vst3:/etc/profiles/per-user/$USER/lib/vst3"; }; + + # https://wiki.nixos.org/wiki/PipeWire#Low-latency_setup + services.pipewire.extraConfig = { + pipewire."92-low-latency" = { + "context.properties" = { + "default.clock.rate" = 48000; + "default.clock.quantum" = 128; + "default.clock.min-quantum" = 128; + "default.clock.max-quantum" = 128; + }; + }; + + pipewire-pulse."92-low-latency" = { + "context.properties" = [ + { + name = "libpipewire-module-protocol-pulse"; + args = { }; + } + ]; + "pulse.properties" = { + "pulse.min.req" = "128/48000"; + "pulse.default.req" = "128/48000"; + "pulse.max.req" = "128/48000"; + "pulse.min.quantum" = "128/48000"; + "pulse.max.quantum" = "128/48000"; + }; + "stream.properties" = { + "node.latency" = "32/48000"; + "resample.quality" = 1; + }; + }; + }; } -- cgit v1.2.3