<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Pithawat Tan Vachiramon on Medium]]></title>
        <description><![CDATA[Stories by Pithawat Tan Vachiramon on Medium]]></description>
        <link>https://medium.com/@pithawattanvachiramon?source=rss-8825c4f285ac------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*SlbdxstbBoBaQJqm.</url>
            <title>Stories by Pithawat Tan Vachiramon on Medium</title>
            <link>https://medium.com/@pithawattanvachiramon?source=rss-8825c4f285ac------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 22:34:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pithawattanvachiramon/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How I Built High Quality Audio System from Raspberry Pi]]></title>
            <link>https://medium.com/@pithawattanvachiramon/how-i-built-high-quality-audio-system-from-raspberry-pi-308ba999e26a?source=rss-8825c4f285ac------2</link>
            <guid isPermaLink="false">https://medium.com/p/308ba999e26a</guid>
            <category><![CDATA[diy]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[raspberry-pi]]></category>
            <category><![CDATA[audio]]></category>
            <category><![CDATA[audiophile]]></category>
            <dc:creator><![CDATA[Pithawat Tan Vachiramon]]></dc:creator>
            <pubDate>Sun, 16 Oct 2016 20:31:54 GMT</pubDate>
            <atom:updated>2017-06-12T03:32:06.919Z</atom:updated>
            <content:encoded><![CDATA[<p>Back in August 2016, I had a chance to meet my old friend who just moved back to London, and brought with him two Genelec G4s active speakers, driven by Audiolab M-DAC and Auralic Aries LE music streamer. Basically a $5000 worth of amazing quality audio equipment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/1*IVTIGxuzPI5nF95HOpydNA.jpeg" /></figure><p>He was also the only person I know who has a <a href="http://tidal.com/">Tidal</a> subscription, a ridiculously fast broadband and upgraded his router just so he could stream uncompressed music.</p><p>I selected “Crystals” by Of Monster and Men, was blown away by the music quality. Honestly, it made my spine tingle. I realized my poor Sonos Play 1 back at home had to go.</p><h3>The Budget</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S1Rl8DZzwLsbnVqF1Op7Vg.jpeg" /></figure><p>How much to spend on a system? Long story short, I settled on $5000, the same as my friend’s system.</p><h3>The Hardware</h3><p>Modern audio hardware can be broken down into three main parts: speakers, integrated amplifier and audio source.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vIRdt6ZRlIAcwgjRDxmijA.png" /></figure><p>Because speakers technology changes slowly, at least relative to amplifiers (and way slower than audio sources. RIP compact discs), this was my plan:</p><ul><li>Allocate the most budget on speakers.</li><li>Choose an amplifier that matches with the speaker characteristics.</li><li>Thanks to plenty of high quality music streaming services available, spend what is left on a music streamer.</li></ul><p>After quite a bit of time at <a href="http://houseofmusicsf.com/">House of Music</a>, a high end audio store in San Francisco, I was very pleased with Bowers &amp; Wilkins CM8 S2 beautiful compact floor standing speakers. They were paired with not-so-shabby Marantz PM7005 integrated with a great internal DAC, SPDIF and USB audio interface.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lxhWiaduaBjhUebloEf3nQ.jpeg" /></figure><p>Plus a Sonos Connect ($350), decent speaker wires ($500) and digital coax cable ($100), the total came out to be just under $5000.</p><p>Yeah right.</p><p>First, speaker wires are the <a href="http://www.audioholics.com/gadget-reviews/speaker-cable-and-audio-interconnects">least important</a> component of an audio system. You really only need to consider DC resistance. Second, under 1m distance any old coax is more than good enough. Instant $600 saving.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3iw1gpxRaK-1HkvQAi993Q.jpeg" /><figcaption>Seriously, this is 99.999% as good as any $600 worth of cables</figcaption></figure><p>One day, when I have my own <a href="http://www.tek.com/spectrum-analyzer/rsa5000">spectrum analyzer</a>, I love to write an article about this.</p><p>With $600 extra spending power, I was tantalizingly close to CM9 S2 ex-demo price range. After a week of deliberation I decided to get the CM9s by foregoing the Connect and build a music streamer from a Raspberry Pi.</p><p><em>How hard can it be?</em></p><h3>Music Streaming Options</h3><p>I spent a week iterating through a number of potential solutions. They were all Spotify based, mainly because I found the service to be very reliable and has excellent audio quality at 320kbit/s.</p><p>These were the things I tried:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sUBCh2u_2A-3ozKSzrDAgg.jpeg" /></figure><p><strong>Chromecast. </strong>Supported <a href="https://www.spotify.com/us/connect/">Spotify Connect</a>, pluged into my TV, then Toshlink out to amp. Unknown bit rate and did not sound very good even using digital pass through.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D5oExXlYXDfGB_uwp01gTw.png" /></figure><p><strong>Spotify Connect on OSMC box</strong>. Since I already had <a href="https://osmc.tv/">OSMC</a> running on Raspberry Pi 3, I installed <a href="https://discourse.osmc.tv/t/howto-setup-a-spotify-connect-web-server-on-a-raspberry-pi-with-osmc/15818">spotify-connect-web-server package</a> and got a really great audio output through HDMI, much better than Chromecast. I also tried connecting the PM7005 via USB, but kept hearing popping and audio dropping out every few minutes or so. Seems like there were some unresolved USB audio driver issues.</p><h3>Volumio</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dJs1mNTh1k8vS_jFPnBugA.png" /></figure><p><a href="http://www.volumio.com/">Volumio</a> is a linux distribution made specifically to turn a Raspberry Pi into an “open audiophile music player”. It supported out of the box:</p><ul><li>A web-based UI for media management and audio control</li><li>USB and I2S based DACs (including Toshlink / SPDIF output)</li><li>Extensible via plug-in system</li><li>Compatible with Spotify premium</li><li>Completely open sourced and pleasantly hackable</li><li>Stable releases with vibrant user and development community</li></ul><p>I really liked this distro, but there were pain points that took a lot of research to over come some issues.</p><h3>Raspberry Pi Hardware</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*AAMkYVZp8y_oOqd49GiXXQ.jpeg" /></figure><ul><li>Raspberry Pi 2 or 3 (I had RBP2 lying around)</li><li>8GB+ microSD card. I used 64GB Sandisk</li><li><a href="https://www.hifiberry.com/digiplus/">Hifiberry DIGI+</a> I got a clones from amazon (<a href="https://www.amazon.com/gp/product/B01DDFKEZ4/ref=oh_aui_detailpage_o00_s01?ie=UTF8&amp;psc=1">Kuman SC07C</a>) which includes infrared remote receiver</li><li>Toshlink or Coax able to connect to your DAC or integrated amp</li><li>Quality 5V micro USB power supply</li><li>Ethernet cable and optional wireless USB dongle</li><li>Volumio distro for Raspberry Pi (<a href="http://www.volumio.com/">here</a>). My version of the image was 0.979</li></ul><h3>Setting up</h3><p>I connected the Hifiberry, plug in the coax to the Marantz and connected the Pi to my router via the Ethernet cable. After burning the Volumio image onto microSD (<a href="https://www.raspberrypi.org/documentation/installation/installing-images/mac.md">instructions</a>), I connected the USB power cable. A few minutes later I was able to go to <a href="http://volumio.local/">http://volumio.local/</a> on my browser.</p><p>That was easy!</p><h3>Spotify</h3><p>I went to the <a href="http://volumio.local/plugin-manager">plugins page</a> and installed Spotify plugin. It took a while to download all the necessary packages. Once that was done, I clicked on the settings icon and enter my premium account log in credentials.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TBxmnNVbdPesBpsaK4XBFg.png" /></figure><p>After a reboot, I was able to choose Spotify from the Browse tab.</p><p>I went to Playback Options menu, chose Internal Audio and plugged in my headphones.Playing a track from Spotify I heard sweet sweet music.</p><h3>Hifiberry DIGI+</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t_bv5h6BkEOPeUNYwCEwpA.png" /></figure><p>Theoretically the DIGI+ should work out of the box by going into the Playback Options and turn on I2S DAC. Unfortunately the Marantz remained quiet.</p><p><em>[Update] I reinstalled Volumio recently and seems like the newest version fixed the wrong ALSA hardware selection. You should not have to follow the steps below anymore. If you still want to disable the built in audio then follow the instructions </em><a href="https://support.hifiberry.com/hc/en-us/articles/205377651-Configuring-Linux-4-x-or-higher"><em>here</em></a><em>.</em></p><p>After a lengthly debugging session, I found this was caused by MPD (the music service that plays internal media) and SPOPD (the Spotify service) had been configured to play audio through ALSA hw:0. The DIGI+ would sometime load as hw:1.</p><p>Rebooting helped, but to be super sure that the box is rock solid, I went ahead and disabled the internal audio driver:</p><ul><li>SSH into the box using <strong><em>ssh volumio@volumio.local</em></strong>. Default password was “volumio”</li><li>Blacklist internal audio with <strong><em>sudo pico /etc/modprobe.d/alsa-blacklist.conf</em></strong> and added this line to the end of the file</li></ul><blockquote>blacklist snd_bcm2835</blockquote><ul><li>Hmm. Might as well changed the default password with <strong><em>passwd</em></strong> and <strong><em>sudo passwd</em></strong></li><li>Reboot</li></ul><p>At long last, digital output!</p><p>I was able to do everything Sonos Connect could do, search for music, access Spotify playlist, listen to web radio. I did not care for multi room playback so that wasn’t a problem.</p><h3>Fine Tuning</h3><p>The default digital audio volume was super loud on PM7005. The volume control on Volumio did not work (there was a <a href="https://volumio.org/forum/volume-control-issues-for-spotify-t1948-20.html">hack</a> to user software volume and ALSA voodoo. I tried but could not get Spotify service SPOPD to start reliably).</p><p>The best solution was to add negative volume gain to SPOPD config file.</p><ul><li>SSH into the box using <strong><em>ssh volumio@volumio.local</em></strong></li><li>Edit the config file with <strong><em>sudo pico /etc/spopd.conf</em></strong> and add a new line in the [sox] section</li></ul><blockquote>effects = gain -21</blockquote><ul><li>Reboot</li></ul><p>The gain -21 parameter was tested by trial and error.</p><h3><strong>Infrared Remote Receiver (Technical)</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*6Kaa7nN-dwK4F70EYuBInA.gif" /><figcaption>Me trying to get LIRC to work.</figcaption></figure><p>Since my DAC came with an IR receiver, wouldn’t it be nice to have remote control support?</p><p>Well, that was more complicated than I expected.</p><p>First, I had to get the IR receiver hardware to work. Since the Kuman DAC did not come with documentations, I had do some guessing from the PCB trace for the GPIO pin (for the record, it was pin 26):</p><ul><li>Install LIRC with <strong><em>sudo apt-get install lirc</em></strong></li><li><strong><em>sudo pico /boot/config.txt</em></strong> then added this line</li></ul><blockquote>dtoverlay=lirc-rpi,gpio_in_pin=26</blockquote><ul><li><strong><em>sudo pico /etc/lirc/hardware.conf</em></strong> then used these settings:</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b926c235c8a1a3fed131c268cc0c6198/href">https://medium.com/media/b926c235c8a1a3fed131c268cc0c6198/href</a></iframe><ul><li>Reboot</li></ul><p>I tested the setup by SSH and entering <strong><em>mode2 -d /dev/lirc0</em></strong> in the command line. This would print any received IR commands in the terminal. After pressing a button on the Marantz remote, I saw whole bunch text, which meant the hardware was working!</p><p>To interpret the presses, I copied the Marantz CD4000 remote codes from database <a href="https://sourceforge.net/p/lirc-remotes/code/ci/master/tree/remotes/marantz/RC4000CD.lircd.conf">here</a> and pasted in <strong>/etc/lirc/lircd.conf</strong>. This mapped key presses to key names.</p><p>Ok, time to test if LIRC can decode the IR signal. I enabled LIRC daemon using <strong><em>sudo /usr/sbin/lircd -d /dev/lirc0 -n</em></strong>. No errors, that’s good. In a separate terminal I ran <strong><em>irw</em></strong> command. Pressing a pause button on the remote:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*4h4jexgR8AK43NCDoLhIgQ.png" /></figure><p>Yes! It worked!</p><p>Now to control Spotify, I used <strong><em>irexec</em></strong> to interpret the key presses and send commands to SPOPD. As it turned out, the best way to do so was to issue <a href="https://github.com/Schnouki/spop">TELNET commands</a>.</p><p>I created a new file using <strong><em>sudo pico /root/.lircrc </em></strong>with the content shown below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/31c6edf39b3f2e508ec50e1bbff03a9a/href">https://medium.com/media/31c6edf39b3f2e508ec50e1bbff03a9a/href</a></iframe><p>Where “button = KEY_PLAY” was defined in <strong>/etc/lirc/lircd.conf</strong>. For the “config = echo play …” you can go to <a href="https://github.com/Schnouki/spop">this link</a> to see which commands are available. I mapped play, toggle, next and prev which pretty much covered 99% of what I needed.</p><p>Ok, time to test the controls. Making sure <strong><em>sudo /usr/sbin/lircd -d /dev/lirc0 -n</em></strong> was running, I ran <strong><em>sudo -u root irexec -d</em></strong>. After pressing the play button on my remote, it played a song from Spotify!</p><p>Finally, I added these two lines with <strong><em>sudo pico /etc/rc.local</em></strong>. Just before the “exit 0” line:</p><blockquote>sudo /usr/sbin/lircd -d /dev/lirc0<br>sudo -u root irexec -d</blockquote><p>Now everything works. Beautifully.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/1*XFV6AftsjO9xbSCTx8_r5w.gif" /></figure><h3><strong>Epilog</strong></h3><p>Building my own music streamer was a bit more involved that I anticipated, largely because I went down a few wrong paths. But having gone through the exercise I learnt a lot about ALSA, LIRC, Spotify Connect and SPOPD.</p><p>So what’s next? I am contemplating enabling Alexa to turn off the music from my bedroom (just like I am able to with my modified Roomba).</p><p>In the mean time:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CStHk4gm6PKkuPR5HRKQUg.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=308ba999e26a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>