mpv: downmix surround sound to stereo using a HRTF-aware filter (sofa)

This commit is contained in:
2024-07-20 13:44:33 +00:00
parent 2ee53fd5be
commit 5f1ac2afac
2 changed files with 11 additions and 0 deletions

View File

@@ -41,6 +41,7 @@
let
cfg = config.sane.programs.mpv;
myHrtf = "${pkgs.sofacoustics.listen.irc_1052}/share/sofa/listen-irc_1052.sofa";
uosc = pkgs.mpvScripts.uosc.overrideAttrs (upstream: {
version = "5.2.0-unstable-2024-03-13";
src = lib.warnIf (lib.versionOlder "5.2.0" upstream.version) "uosc outdated; remove patch?" pkgs.fetchFromGitHub {
@@ -144,6 +145,8 @@ in
# i use enable52Compat in order to get `table.unpack`.
# i think using `luajit` here instead of `lua` is optional, just i get better perf with it :)
lua = pkgs.luajit.override { enable52Compat = true; self = lua; };
# ship a ffmpeg with sofa enabled, for surround-sound downmixing
ffmpeg = pkgs.ffmpeg-full;
};
scripts = [
pkgs.mpvScripts.mpris
@@ -221,6 +224,7 @@ in
fs.".config/mpv/scripts/sane_cast/main.lua".symlink.target = ./sane_cast/main.lua;
fs.".config/mpv/scripts/sane_sysvol/main.lua".symlink.target = ./sane_sysvol/main.lua;
fs.".config/mpv/scripts/sane_sysvol/non_blocking_popen.lua".symlink.target = ./sane_sysvol/non_blocking_popen.lua;
fs.".config/mpv/hrtf.sofa".symlink.target = myHrtf;
fs.".config/mpv/input.conf".symlink.target = ./input.conf;
fs.".config/mpv/mpv.conf".symlink.target = ./mpv.conf;
fs.".config/mpv/script-opts/osc.conf".symlink.target = ./osc.conf;

View File

@@ -26,3 +26,10 @@ border=no
# # with `ao-volume`, the max actually is 100.
# # to go higher you'll have to use the system's native controls.
# volume-max=100
# libmysofa Head Related Transfer Function file to use to downmix surround -> stereo
# for specifically my skull
# see: <https://ffmpeg.org/ffmpeg-filters.html#sofalizer>
# TODO: this maybe belongs in pipewire instead of mpv.
# at least, provide a way to disable the downmixing, so i can still output 5.1 over HDMI?
af=sofalizer=sofa=/home/colin/.config/mpv/hrtf.sofa