blob: 26e0d9db45786fb2a33c5f7cf22e2898d7ca115b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
{pkgs, ...}: {
programs.obs-studio = {
enable = true;
enableVirtualCamera = true;
plugins = with pkgs.obs-studio-plugins; [
obs-pipewire-audio-capture
];
};
# Enable sound with pipewire.
hardware.pulseaudio.enable = false;
security.rtkit.enable = true;
# Latency optimization
boot.kernelParams = ["threadirqs"];
boot.kernel.sysctl."vm.swappiness" = 10;
environment.systemPackages = with pkgs; [
helvum
qpwgraph # better than helvum?
supercollider-with-plugins
#supercollider-with-sc3-plugins
pamixer # cli volume control
patchage # another connection manager
pwvucontrol # gui for quick adjustments
];
# Virtual sinks for routing audio
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
jack.enable = true;
wireplumber.enable = true;
extraConfig.pipewire = {
"10-loopback" = {
# loopback my mic into my headphones so i can hear myself, this creates
# an auditory space that encourages focus and thinking
"context.properties" = {
"default.clock.rate" = 48000;
"default.clock.quantum" = 128; # lower for less latency
"default.clock.min-quantum" = 32;
"default.clock.max-quantum" = 8192;
};
"context.exec" = [
{
"path" = "${pkgs.writeShellScript "setup-mic-monitor" ''
sleep 1
${pkgs.pipewire}/bin/pw-link \
"alsa_input.usb-Antlion_Audio_Antlion_USB_Microphone-00.pro-input-0:capture_AUX0" \
"input.mic-monitor:input_FL"
${pkgs.pipewire}/bin/pw-link \
"alsa_input.usb-Antlion_Audio_Antlion_USB_Microphone-00.pro-input-0:capture_AUX0" \
"input.mic-monitor:input_FR"
''}";
}
];
"context.modules" = [
{
name = "libpipewire-module-loopback";
args = {
"node.name" = "mic-monitor";
"node.description" = "Microphone Monitor";
"capture.props" = {
"target.object" = "alsa_input.usb-Antlion_Audio_Antlion_USB_Microphone-00.pro-input-0";
"channelmix.normalize" = true;
"audio.channels" = 1;
"audio.position" = ["FR" "FL"];
};
"playback.props" = {
"target.object" = "alsa_output.usb-Focusrite_Scarlett_Solo_USB-00.HiFi__Line1__sink";
"node.passive" = true;
"channelmix.normalize" = true;
"audio.channels" = 2;
"audio.position" = ["FR" "FL"];
};
};
}
];
};
"10-combined" = {
"context.modules" = [
{
name = "libpipewire-module-loopback";
args = {
"node.name" = "combined-audio";
"node.description" = "Combined Mic+Desktop Audio";
"capture.props" = {
"media.class" = "Audio/Sink";
"audio.class" = 2;
"audio.position" = ["FL" "FR"];
"channelmix.normalize" = true;
};
"playback.props" = {
"media.class" = "Audio/Source";
"audio.channels" = 2;
"audio.position" = ["FL" "FR"];
"channelmix.normalize" = true;
};
};
}
];
"context.exec" = [
{
"path" = "${pkgs.writeShellScript "setup-audio-routing" ''
sleep 1
${pkgs.pipewire}/bin/pw-link \
"alsa_input.usb-Antlion_Audio_Antlion_USB_Microphone-00.pro-input-0:capture_AUX0" \
"input.combined-audio:playback_FL"
${pkgs.pipewire}/bin/pw-link \
"alsa_input.usb-Antlion_Audio_Antlion_USB_Microphone-00.pro-input-0:capture_AUX0" \
"input.combined-audio:playback_FR"
${pkgs.pipewire}/bin/pw-link \
"input.combined-audio:monitor_FL" \
"alsa_output.usb-Focusrite_Scarlett_Solo_USB-00.HiFi__Line1__sink:playback_FL"
${pkgs.pipewire}/bin/pw-link \
"input.combined-audio:monitor_FR" \
"alsa_output.usb-Focusrite_Scarlett_Solo_USB-00.HiFi__Line1__sink:playback_FR"
''}";
}
];
};
};
};
}
|