aboutsummaryrefslogtreecommitdiffstats
path: root/spread.asoundrc
blob: 15d77a8ff79875688146a6894a403c409e94443a (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
# From https://wiki.archlinux.org/title/Advanced_Linux_Sound_Architecture/Configuration_examples#Loopback_interface_with_dmix_external_interface

# Use this to output to external
pcm.dmixerout {
 type dmix
 ipc_key 1024
 ipc_key_add_uid false
 slave {
  pcm "hw:CARDNAME,0"
  channels 2
  period_time 0
  period_size 1024
  buffer_size 4096
  rate 44100
 }
 bindings {
  0 0
  1 1
 }
}

# Use this to output to loopback
pcm.dmixerloop {
 type dmix
 ipc_key 2048
 ipc_key_add_uid false
 slave {
  pcm "hw:Loopback,0,0"
  channels 2
  period_time 0
  period_size 1024
  buffer_size 4096
  # If format is absent ALSA gives me slave PCM not usable, but it works w/o it for others
  format S32_LE
  rate 44100
 }
 bindings {
  0 0
  1 1
 }
}

# Sends to the two dmix interfaces
pcm.quad {
 type multi
 # Necessary to have both slaves be dmix; both as hw doesn't give errors, but wouldn't 
 slaves.a.pcm "dmixerout"
 slaves.a.channels 2
 slaves.b.pcm "dmixerloop"
 slaves.b.channels 2
 bindings {
  0 { slave a; channel 0; }
  1 { slave a; channel 1; }
  2 { slave b; channel 0; }
  3 { slave b; channel 1; }
 }
}

# Duplicates to quad, use this to output to loopback & external
pcm.stereo2quad {
 type route
 slave.pcm "quad"
 # ttable.A.B G
 # where A - input channel
 #       B - output channel
 #       G - volume gain (1.0 = original)
 ttable.0.0 1
 ttable.1.1 1
 ttable.0.2 1
 ttable.1.3 1
}

# Listens to loopback
# trying to play to stereo2quad when something is already listening gives me slave PCM not usable
# but listening when something is already playing on stereo2quad works
# and so does starting to listen, then playing to dmixerloop
pcm.loopin {
 type dsnoop
 ipc_key 1111
 ipc_key_add_uid false
 slave.pcm "hw:Loopback,1"
}

pcm.!default {
 type asym
 playback.pcm "plug:stereo2quad"
 capture.pcm "plug:loopin"
}