diff --git a/hosts/micronix/sound.nix b/hosts/micronix/sound.nix index 9774050..a2d6a11 100644 --- a/hosts/micronix/sound.nix +++ b/hosts/micronix/sound.nix @@ -1,10 +1,9 @@ {...}: { services.pipewire = { enable = true; - audio = { + wireplumber = { enable = true; }; - wireplumber = {enable = true;}; jack = { enable = true; }; @@ -15,7 +14,119 @@ enable = true; support32Bit = true; }; - extraConfig.pipewire-pulse = { + extraConfig.client.quality = { + "context" = { + "properties" = { + "mem.allow-mlock" = true; + "mem.mlock-all" = true; + "log.level" = 0; + }; + "spa-libs" = { + "audio.convert.*" = "audioconvert/libspa-audioconvert"; + "support.*" = "support/libspa-support"; + }; + "modules" = [ + {"name" = "libpipewire-module-protocol-native";} + {"name" = "libpipewire-module-client-node";} + {"name" = "libpipewire-module-client-device";} + {"name" = "libpipewire-module-adapter";} + {"name" = "libpipewire-module-metadata";} + {"name" = "libpipewire-module-session-manager";} + ]; + }; + "filter" = { + "properties" = { + "node.latency" = "1024/48000"; + }; + }; + "stream" = { + "properties" = { + "node.latency" = "1024/48000"; + "node.autoconnect" = true; + "resample.quality" = 14; + "channelmix.normalize" = true; + }; + }; + }; + extraConfig.client-rt.quality = { + "context" = { + "properties" = { + "mem.allow-mlock" = true; + "mem.mlock-all" = true; + "log.level" = 0; + }; + "spa-libs" = { + "audio.convert.*" = "audioconvert/libspa-audioconvert"; + "support.*" = "support/libspa-support"; + }; + "modules" = [ + { + "name" = "libpipewire-module-rt"; + "args" = { + "rt.prio" = 80; + "rt.time.soft" = -1; + "rt.time.hard" = -1; + }; + "flags" = ["ifexists" "nofail"]; + } + {"name" = "libpipewire-module-protocol-native";} + {"name" = "libpipewire-module-client-node";} + {"name" = "libpipewire-module-client-device";} + {"name" = "libpipewire-module-adapter";} + {"name" = "libpipewire-module-metadata";} + {"name" = "libpipewire-module-session-manager";} + ]; + }; + "filter" = { + "properties" = { + "node.latency" = "1024/48000"; + }; + }; + "stream" = { + "properties" = { + "node.latency" = "1024/48000"; + "node.autoconnect" = true; + "resample.quality" = 14; + "channelmix.normalize" = true; + }; + "rules" = [ + { + "matches" = [ + { + "application.name" = "pw-cat"; + "node.name" = "~Google Chrome$"; + } + ]; + "actions" = { + "update-props" = { + "node.latency" = "512/48000"; + }; + }; + } + ]; + }; + "alsa" = { + "properties" = { + "alsa.volume-method" = "cubic"; + }; + "rules" = [ + { + "matches" = [ + { + "application.process.binary" = "resolve"; + } + ]; + "actions" = { + "update-props" = { + "alsa.buffer-bytes" = 131072; + }; + }; + } + ]; + }; + }; + + extraConfig.pipewire-pulse.quality = { "context" = { "properties" = { "mem.allow-mlock" = true; @@ -101,84 +212,15 @@ "pulse.allow-module-loading" = true; "pulse.default.format" = "F32"; }; - "properties.rules" = [ - { - "matches" = [ - { - "cpu.vm.name" = "!null"; - } - ]; - "actions" = { - "update-props" = { - "pulse.min.quantum" = "1024/192000"; - }; - }; - } - ]; }; - "pulse.rules" = [ - { - "matches" = [ - { - "client.name" = "Firefox"; - } - ]; - "actions" = { - "update-props" = { - "node.latency" = "512/192000"; - }; - }; - } - { - "matches" = [ - { - "application.process.binary" = "teams"; - } - { - "application.process.binary" = "teams-insiders"; - } - { - "application.process.binary" = "skypeforlinux"; - } - ]; - "actions" = { - "quirks" = ["force-s16-info"]; - }; - } - { - "matches" = [ - { - "application.process.binary" = "firefox"; - } - ]; - "actions" = { - "quirks" = ["remove-capture-dont-move"]; - }; - } - { - "matches" = [ - { - "application.name" = "~speech-dispatcher.*"; - } - ]; - "actions" = { - "update-props" = { - "pulse.min.req" = "512/192000"; - "pulse.min.quantum" = "512/192000"; - "pulse.idle.timeout" = 5; - }; - }; - } - ]; "stream.properties" = { - "node.latency" = "1024/192000"; "node.autoconnect" = true; "resample.quality" = 14; "channelmix.normalize" = true; }; }; }; - extraConfig.pipewire = { + extraConfig.pipewire.quality = { "context" = { "properties" = { "library.name.system" = "support/libspa-support"; @@ -202,8 +244,8 @@ ]; "core.daemon" = true; "core.name" = "pipewire-0"; - "default.clock.rate" = 192000; - "default.clock.allowed-rates" = [192000]; + "default.clock.rate" = 48000; + "default.clock.allowed-rates" = [48000]; "module.x11.bell" = true; "module.access" = true; "module.jackdbus-detect" = true;