nixos/users/malte/scarlett-solo.nix
Malte Tammena 9bada411db Move [marie|malte] -> /users/[marie|malte]
To prepare for an addiotional /users/modules
which can be shared between users.
2022-01-13 12:08:39 +01:00

60 lines
1.6 KiB
Nix

{ pkgs, ... }:
let
pipewire = "pipewire.service";
device = "dev-scarlett_solo.device";
alsa-input =
"alsa_input.usb-Focusrite_Scarlett_Solo_USB_Y7ENM550A6399B-00.pro-input-0";
channelMapService = { dev, name, desc, from, to }: {
Unit = {
Description = desc;
Requires = pipewire;
BindsTo = device;
After = [ pipewire device ];
};
Service = {
Type = "simple";
ExecStart = ''
${pkgs.pipewire}/bin/pw-loopback \
--capture-props="audio.position=[ ${from} ] \
stream.dont-remix=true" \
--playback-props='media.class=Audio/Source \
node.name="${dev}" \
node.description="${name}" \
audio.position=[ ${to} ]' \
-C ${alsa-input}
'';
};
Install.WantedBy = [ "default.target" device ];
};
in {
systemd.user.services = {
scarlett-voice = channelMapService {
dev = "scarlett-voice";
name = "Scarlett Voice";
desc = "Remap the left channel of the Scarlett Solo to mono";
from = "AUX0";
to = "MONO";
};
scarlett-instrument = channelMapService {
dev = "scarlett-instrument";
name = "Scarlett Instrument";
desc = "Remap the right channel of the Scarlett Solo to mono";
from = "AUX1";
to = "MONO";
};
scarlett-stereo = channelMapService {
dev = "scarlett-both";
name = "Scarlett Voice + Instrument";
desc = "Remix the channels of the Scarlett Solo";
from = "AUX0 AUX1";
to = "MONO";
};
};
}