{"id":345,"date":"2015-01-16T16:26:06","date_gmt":"2015-01-16T15:26:06","guid":{"rendered":"https:\/\/blogs.gentoo.org\/mgorny\/?p=345"},"modified":"2015-01-20T01:15:04","modified_gmt":"2015-01-20T00:15:04","slug":"surround-sound-over-network-with-windows-8","status":"publish","type":"post","link":"https:\/\/blogs.gentoo.org\/mgorny\/2015\/01\/16\/surround-sound-over-network-with-windows-8\/","title":{"rendered":"Surround sound over network with Windows 8"},"content":{"rendered":"<p>I&#8217;ve got a\u00a0notebook with some fancy HD Audio sound card (stereo!), and\u00a0a\u00a0single output jack \u2014 not a\u00a0sane way to get surround sound (sure, cool kids use HDMI these days). Even worse, connecting an\u00a0external amplifier to the\u00a0jack results in\u00a0catching a\u00a0lot of\u00a0electrical interference. Since I also have a\u00a0PC which has surround speakers connected, I figured it would be a\u00a0good idea to stream the\u00a0audio over the\u00a0network.<\/p>\n<p>On\u00a0non-Windows, the\u00a0streaming would be\u00a0trivial to setup. Likely PulseAudio on\u00a0both machines, few setup bits and\u00a0done. If you are looking for a\u00a0guide on\u00a0how to do\u00a0such a\u00a0thing in\u00a0Windows, you&#8217;re likely end up setting up an\u00a0icecast server listening to the\u00a0stereo mix. Bad twice. Firstly, stereo-only. Secondly, poor latency. Now imagine playing a\u00a0game or watching a\u00a0movie with sound noticeably delayed after picture (well, in\u00a0the\u00a0movie player you could at\u00a0least play with A\/V delay to work-around that). But there must be another way\u2026<\/p>\n<p><!--more--><\/p>\n<h2>The\u00a0ingredients<\/h2>\n<p>In\u00a0order to get a\u00a0working surround sound system, you need to have:<\/p>\n<ol>\n<li>two <a rel=\"external\" href=\"http:\/\/jackaudio.org\/\">JACK2<\/a> servers \u2014 one on\u00a0each computer,<\/li>\n<li><a rel=\"external\" href=\"http:\/\/www.asio4all.com\/\">ASIO4ALL<\/a>,<\/li>\n<li>and\u00a0an\u00a0ASIO-friendly virtual sound device such as\u00a0<a rel=\"external\" href=\"http:\/\/vb-audio.pagesperso-orange.fr\/Cable\/index.htm\">VB-Audio Hi-Fi Cable<\/a>.<\/li>\n<\/ol>\n<p>Install the\u00a0JACK server on the\u00a0computer with speakers, and\u00a0all the\u00a0tools on\u00a0the\u00a0other machine.<\/p>\n<h2>Setting up the\u00a0JACK slave (on speaker-PC)<\/h2>\n<p>I&#8217;m going to start with setting up the\u00a0speaker-PC since it&#8217;s simpler. It can run basically any operating system, though I&#8217;m using Gentoo Linux for this guide. JACK is set up pretty much the\u00a0same everywhere, with the\u00a0only difference in\u00a0used audio driver.<\/p>\n<p>The\u00a0choice of\u00a0master vs.\u00a0slave is\u00a0pretty much arbitrary. The\u00a0slave needs to either combine a\u00a0regular audio driver with\u00a0<em>netadapter<\/em>, or\u00a0the\u00a0<em>net<\/em> driver with\u00a0<em>audioadapter<\/em>. I&#8217;ve used the\u00a0former.<\/p>\n<p>First, install JACK2. In\u00a0Gentoo, it can be found in\u00a0the\u00a0<a rel=\"external\" href=\"http:\/\/proaudio.tuxfamily.org\/wiki\">pro-audio project<\/a> overlay. A\u00a0good idea is to disable D-Bus support (<code>USE=-dbus<\/code>) since I wasn&#8217;t able to get JACK running with it and\u00a0the\u00a0ebuild doesn&#8217;t build regular jackd when D-Bus support is enabled.<\/p>\n<p>Afterwards, start JACK with the desired sound driver and\u00a0a\u00a0surround-capable device. You will want to specify a\u00a0sample rate and\u00a0bit depth too. Best fit it with the\u00a0application you&#8217;re planning to use. For example:<\/p>\n<pre><code>$ jackd -R -d alsa -P surround40 -r 48000 -S<\/code><\/pre>\n<p>This starts the\u00a0JACK daemon with real-time priority support (important for low latency), using ALSA playback device <em>surround40<\/em> (4-speaker surround), 48 kHz sample rate and\u00a016-bit samples.<\/p>\n<p>Afterwards, load <em>netadapter<\/em> with matching number of\u00a0capture channels, and\u00a0connect them to the\u00a0output channels:<\/p>\n<pre><code>$ jack_load netadapter -i '-C 4'\r\n$ jack_connect netadapter:capture_1 system:playback_1\r\n$ jack_connect netadapter:capture_2 system:playback_2\r\n$ jack_connect netadapter:capture_3 system:playback_3\r\n$ jack_connect netadapter:capture_4 system:playback_4<\/code><\/pre>\n<p>At\u00a0this point, slave is\u00a0ready. JACK will wait for a\u00a0master to start, and\u00a0will forward any audio received from the\u00a0master to the\u00a0local sound card surround output. Since JACK2 supports zero-configuration networking, you don&#8217;t need to specify any IP addresses.<\/p>\n<h2>Setting up the\u00a0virtual device<\/h2>\n<p>After getting the\u00a0slave up, it&#8217;s time to set the\u00a0sound source. After installing all the components, the\u00a0first goal is to set up the\u00a0virtual audio device. Once the\u00a0Hi-Fi Cable package is insalled (no need to reboot), the\u00a0system should start seeing two new devices \u2014 playback device called \u2018Hi-Fi Cable Input\u2019 and\u00a0recording device called \u2018Hi-Fi Cable Output\u2019. Now open the\u00a0sound control panel applet and:<\/p>\n<ol>\n<li>select \u2018Hi-Fi Cable Input\u2019 as the\u00a0default output device.<\/li>\n<li>Right-click it and\u00a0configure speakers. Select whatever configuration is appropriate for your real speaker set (e.g. quad speakers).<\/li>\n<li>(Optionally) right-click it and\u00a0open properties. On the\u00a0advanced tab select sample rate and\u00a0bit depth. Afterwards, open properties of\u00a0the\u00a0\u2018Hi-Fi Cable Output\u2019 recording device and set the\u00a0same parameters.<\/li>\n<\/ol>\n<p><img src=\"http:\/\/dev.gentoo.org\/~mgorny\/articles\/win-jack\/control-sound.png\" style=\"width: 459px;height: 462px\" alt=\"Control Panel sound settings with virtual Hi-Fi Cable Input device\" \/><img src=\"http:\/\/dev.gentoo.org\/~mgorny\/articles\/win-jack\/control-sound-advanced.png\" style=\"width: 459px;height: 462px\" alt=\"Advanced Hi-Fi Cable Input device properties (sample rate and\u00a0bit depth setting)\" \/><\/p>\n<p>As you may notice, even after setting the\u00a0input to\u00a0multiple speakers, the\u00a0output will still be stereo. That&#8217;s a\u00a0bug (limitation?) we&#8217;re going to work-around soon\u2026<\/p>\n<h2>Setting up the\u00a0JACK master<\/h2>\n<p>Now that device is ready, we need to start setting up JACK. On Windows, the \u2018Jack Control\u2019 GUI is probably the\u00a0easiest way. Start with \u2018Setup\u2019. Ensure that the\u00a0\u2018portaudio\u2019 driver is selected, and\u00a0choose \u2018ASIO::ASIO4ALL v2\u2019 both as\u00a0input and\u00a0output device. The\u00a0right-arrow button right of\u00a0the\u00a0text inputs should provide a\u00a0list of\u00a0devices to select. Additionally select the\u00a0sample rate matching the\u00a0one set for the\u00a0virtual device and\u00a0the\u00a0JACk slave.<\/p>\n<p><img src=\"http:\/\/dev.gentoo.org\/~mgorny\/articles\/win-jack\/jackd-setup.png\" style=\"width: 593px;height: 466px\" alt=\"JACK setup window\" \/><\/p>\n<p>Now, we need to load the\u00a0<em>netmanager<\/em> module. Similarly to the\u00a0slave setup, this is done using jack_load. To get this fully automated, you can use the\u00a0\u2018Execute script after startup\u2019 option from the\u00a0\u2018Options\u2019 (right-arrow button is not helpful this time). Create a\u00a0new .bat file somewhere, and\u00a0put the\u00a0following command inside:<\/p>\n<pre><code>jack_load netmanager<\/code><\/pre>\n<p>Save the\u00a0file and\u00a0select is as post-startup script. Now the\u00a0module will be automatically loaded every time you start JACK via Jack Control. You may also fine-tune some of\u00a0the\u00a0\u2018Misc\u2019 settings to fit your preferences. Then confirm \u2018Ok\u2019 and\u00a0click \u2018Start\u2019. If everything went well so far, after clicking \u2018Connect\u2019 you should see both \u2018System\u2019 and\u00a0the\u00a0slave&#8217;s hostname (assuming it is up and\u00a0running). <em>Do not connect anything yet<\/em>, just verify that JACK sees the\u00a0slave.<\/p>\n<h2>Connecting the\u00a0virtual sound card to\u00a0JACK<\/h2>\n<p>Now that the\u00a0JACK is ready, it&#8217;s time to connect the\u00a0virtual sound card to the\u00a0remote host. The\u00a0traditional way of\u00a0doing that would be through connecting the\u00a0local recording device (stereo mix or\u00a0Virtual Cable Output) to the\u00a0respective remote pins. However, that would mean just stereo. Instead, we have to cheat a\u00a0little.<\/p>\n<p>One of\u00a0the\u00a0fancy features of\u00a0VB-Audio&#8217;s Virtual Hi-Fi Cable is that it supports using ASIO-compatible sound processors. In\u00a0other words, the\u00a0sound from virtual cable input is directed into ASIO output port for\u00a0processing. Good news is that the\u00a0stereo stripping occurs directly in\u00a0virtual cable output, so ASIO still gets all the\u00a0channels. All we have to do is to capture sound there\u2026<\/p>\n<p>Find VB-Cable&#8217;s \u2018ASIO Bridge\u2019 and\u00a0start it. If\u00a0the\u00a0button in\u00a0the\u00a0middle states \u2018ASIO OFF\u2019, switch it to enable ASIO. Then click on the\u00a0\u2018Select A.S.I.O. Device\u2019 text below it and\u00a0select \u2018JackRouter\u2019. If everything went well, \u2018VBCABLE_AsioBridge\u2019 should appear in\u00a0the\u00a0JACK connection panel.<\/p>\n<p><img src=\"http:\/\/dev.gentoo.org\/~mgorny\/articles\/win-jack\/asio-bridge.png\" style=\"width: 832px;height: 331px\" alt=\"ASIO Bridge window\" \/><\/p>\n<h2>The\u00a0final touches<\/h2>\n<p>Now that everything&#8217;s in\u00a0place, it&#8217;s just a\u00a0matter of\u00a0connecting the\u00a0right pins. To avoid having to\u00a0connect them manually every time, use the\u00a0\u2018Patchbay\u2019 panel. First, use \u2018Add\u2019 on\u00a0left-hand side to add an\u00a0output socket, select \u2018VBCABLE_AsioBridge\u2019 client and\u00a0keep clicking \u2018Add plug\u2019 for all the\u00a0input channels. Then, \u2018Add\u2019 on\u00a0right-hand side, your remote host as\u00a0client and\u00a0add all the\u00a0output channels. Now select both new sockets and\u00a0\u2018Connect\u2019.<\/p>\n<p><img src=\"http:\/\/dev.gentoo.org\/~mgorny\/articles\/win-jack\/jackd-patchbay.png\" style=\"width: 702px;height: 344px\" alt=\"JACK patchbay setup\" \/><\/p>\n<p>Save your new patchbay definition somewhere, and\u00a0\u2018Activate\u2019 it. If you did well, the\u00a0connections window should now show connections between respective local and\u00a0remote pins and\u00a0you should be able to hear sound from the\u00a0remote speakers.<\/p>\n<p><img src=\"http:\/\/dev.gentoo.org\/~mgorny\/articles\/win-jack\/jackd-connections.png\" style=\"width: 550px;height: 310px\" alt=\"JACK connections window after setup\" \/><\/p>\n<p>Now you can open \u2018Setup\u2019 again, and\u00a0on\u00a0the\u00a0\u2018Options\u2019 tab activate patchbay persistence. Select your newly created patchbay definition file and\u00a0from now on, starting JACK should enable the\u00a0patchbay, and\u00a0the\u00a0patchbay should ensure that the\u00a0pins are connected every time they reappear.<\/p>\n<h2>Maintenance notes<\/h2>\n<p>First of\u00a0all, you usually don&#8217;t need to set an\u00a0explicit connection between your virtual device and\u00a0real system audio device. On my system that connection is established automatically, so that the\u00a0sounds reach both remote host and\u00a0local speakers. If that&#8217;s unrequested, just mute the\u00a0sound card\u2026<\/p>\n<p>Secondly, note that now the\u00a0virtual sound card is the\u00a0default device, so applications will control its volume (both for remote and\u00a0local speakers). If you want to mute the\u00a0local speakers, you need to open the\u00a0mixer and\u00a0select your local sound card from device drop-down.<\/p>\n<p>Thirdly, VBCABLE_AsioBridge likes to disappear occasionally when restarting JACK. If you don&#8217;t see it in\u00a0the\u00a0connections, just turn it off and\u00a0on again (the\u00a0\u2018ASIO ON\u2019 button) and\u00a0it should reappear.<\/p>\n<p>Fourthly, if you hear skipping, you can try playing with \u2018Frames\/Period\u2019 in\u00a0JACK&#8217;s setup. Or\u00a0reduce the\u00a0sample rate.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve got a\u00a0notebook with some fancy HD Audio sound card (stereo!), and\u00a0a\u00a0single output jack \u2014 not a\u00a0sane way to get surround sound (sure, cool kids use HDMI these days). Even worse, connecting an\u00a0external amplifier to the\u00a0jack results in\u00a0catching a\u00a0lot of\u00a0electrical interference. Since I also have a\u00a0PC which has surround speakers connected, I figured it would &hellip; <a href=\"https:\/\/blogs.gentoo.org\/mgorny\/2015\/01\/16\/surround-sound-over-network-with-windows-8\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Surround sound over network with Windows 8&#8221;<\/span><\/a><\/p>\n","protected":false},"author":137,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[3],"tags":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/blogs.gentoo.org\/mgorny\/wp-json\/wp\/v2\/posts\/345"}],"collection":[{"href":"https:\/\/blogs.gentoo.org\/mgorny\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.gentoo.org\/mgorny\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.gentoo.org\/mgorny\/wp-json\/wp\/v2\/users\/137"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.gentoo.org\/mgorny\/wp-json\/wp\/v2\/comments?post=345"}],"version-history":[{"count":8,"href":"https:\/\/blogs.gentoo.org\/mgorny\/wp-json\/wp\/v2\/posts\/345\/revisions"}],"predecessor-version":[{"id":353,"href":"https:\/\/blogs.gentoo.org\/mgorny\/wp-json\/wp\/v2\/posts\/345\/revisions\/353"}],"wp:attachment":[{"href":"https:\/\/blogs.gentoo.org\/mgorny\/wp-json\/wp\/v2\/media?parent=345"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/mgorny\/wp-json\/wp\/v2\/categories?post=345"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/mgorny\/wp-json\/wp\/v2\/tags?post=345"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}