From: Christian Heller <c.heller@plomlompom.de>
Date: Wed, 24 Feb 2021 01:02:23 +0000 (+0100)
Subject: For Raspbian setup, add ALSA config.
X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/%7B%7Bprefix%7D%7D/%7B%7Bdb.prefix%7D%7D/foo.html?a=commitdiff_plain;h=41bfb6062fb9c80113a1cebf1557cbae81c91fcd;p=config

For Raspbian setup, add ALSA config.
---

diff --git a/.asoundrc b/.asoundrc
new file mode 100644
index 0000000..46eb301
--- /dev/null
+++ b/.asoundrc
@@ -0,0 +1,73 @@
+# using hdmi0 for TV stereo, hdmi1 for a 5.1 speaker set-up
+# unfortunately, a non-square speaker number creates some noise
+# therefore for hdmi1 we declare 8 speakers, but re-map them to 6 speakers 
+pcm.hdmi0 {
+  type hw
+  card 0
+}
+pcm.hdmi1 {
+  type route
+  slave {
+    pcm "hw:1,0"
+    channels 8
+  }
+  ttable {
+    0.0 = 1
+    1.1 = 1
+    2.2 = 1
+    3.3 = 1
+    4.4 = 1
+    5.5 = 1
+    6.0 = 0.5
+    6.2 = 0.5
+    7.1 = 0.5
+    7.3 = 0.5
+  }
+}
+
+# upmix stereo to 5.1 – so we can watch stereo YouTube on all speakers
+# with this: $ chromium-browser --alsa-output-device=stereo51
+# (numbers taken from <https://www.volkerschatz.com/noise/alsa.html>)   
+pcm.stereo51  {
+  type route
+  slave {
+    pcm "hw:1,0"
+    channels 8
+  }
+  ttable {
+    0.0 = 1
+    0.2 = -0.6
+    0.3 = -0.39
+    0.4 = 0.5
+    0.5 = 0.5
+    1.1 = 1
+    1.2 = -0.6
+    1.3 = -0.39
+    1.4 = 0.5
+    1.5 = 0.5
+  }
+}
+
+# default to hdmi0, overwrite with AUDIO_HDMI=1 env prefix
+pcm.!default {
+  type plug 
+  slave.pcm {
+    @func concat
+    strings [
+      "hdmi"
+      {
+        @func getenv
+        vars [ AUDIO_HDMI ]
+        default "0"
+      }
+    ]
+  } 
+}
+ctl.!default {
+  type hw 
+  card {
+    @func getenv
+    vars [ AUDIO_HDMI ]
+    default 0 
+  }
+}