High-end Vinyl Streaming to Squeezebox

High end vinyl streaming

High end vinyl streaming

Finally I found time to optimise my wireless vinyl streaming Raspberry Pi project. It uses now Liquidsoap and lossless FLAC streaming at 44100 kHz, 16 bit sampling for high end quality.

I am using the same raspberry pi setup as in my previous post. In that post I also explain how to tune your Squeezebox players to the stream, so I am not repeating it here again. Very important: only Logitech Media Servers 7.8 and higher support FLAC streaming in a OGG/Vorbis container. So, make sure that you are using the community edition and not one of the last official releases, or you wont be able to listen to the stream.

If you are running LMS 7.8, here are the step-by-step instructions how to set up liquidsoap on Raspbian Wheezy under the default user “pi”.

First, you need to update apt-get

$ sudo apt-get update

$ sudo apt-get upgrade

Then, you can install liquidsoap with all plugins including Ogg/Flac

$ sudo apt-get install liquidsoap

$ sudo apt-get install liquidsoap-plugin-all

Create a liquidsoap script, called “phono.liq”

$ sudo nano /etc/liquidsoap/phono.liq

Copy this script, replace [IP-ADDRESS] with your actual raspi’s IP address. Make sure that your DHCP server does not change it occasionally.

#!/usr/bin/liquidsoap

# set the path and permissions for the logfile

set(“log.file.path”,”/var/log/liquidsoap/phono.log”)

set(“log.file.perms”,777)

set(“log.unix_timestamps”,true)

#input from soundcard

phono = input.alsa(bufferize=true,fallible=false,device=”hw:1″)

#stream it to local icecast, default port and password

output.icecast(%ogg(%flac(samplerate=44100,channels=2,compression=5,bits_per_sample=16)), mount=”/phono”, name=”Phono”, format=”audio/ogg”, description=”Turntable FLAC”, url=”http://IP-ADDRESS”, genre = “Misc”, phono)

Save the script with CTRl-x, y ,

then make it executable

$ sudo chmod +x /etc/liquidsoap/phono.liq

Liquidsoap is extremely fragile, when it comes to owners and user rights. So, let’s make sure that we are ok here, otherwise it will not start.

$ sudo chmod 666 /etc/logrotate.d/liquidsoap

$ sudo chmod 777 /var/log/liquidsoap

$ sudo chmod 666 /var/log/liquidsoap/phono.log

$ sudo chmod 777 /run/liquidsoap

$ sudo chown liquidsoap /etc/logrotate.d/liquidsoap

$ sudo chgrp liquidsoap /etc/logrotate.d/liquidsoap

$ sudo chown root /var/log/liquidsoap

$ sudo chgrp root /var/log/liquidsoap

$ sudo chown liquidsoap /var/log/liquidsoap/phono.log

$ sudo chgrp liquidsoap /var/log/liquidsoap/phono.log

$ sudo chown liquidsoap /var/run/liquidsoap

$ sudo chgrp liquidsoap /var/run/liquidsoap

Let’s test the script

$ /etc/liquidsoap/phono.liq

If everything went well, you should see a long list of prompts. Check with your browser, if Icecast is running properly “http://IP-ADDRESS:8000/phono

Now press CTRL-c to stop liquidsoap. This is what you have to do to start your script automatically.

Open rc.local:

$ sudo nano /etc/rc.local

Add the following before “exit 0”

chmod 777 /run/liquidsoap

/etc/init.d/liquidsoap start

Save the changes with CTRl-x, y

We are not completely done. Have to change the user to run liquidsoap properly as a daemon.

$ sudo nano /etc/init.d/liquidsoap

#change user and group to default Raspberry Pi user “pi” and group “pi”

user = pi

group = pi

Save changes with CTRl-x, y

Now enable autostart and reboot

$ sudo update-rc.d liquidsoap enable

$ sudo reboot

You should now be able to listen to your turntable Flac stream. Enjoy!

Some useful Internet sources

# Liquidsoap home

http://liquidsoap.fm

# Raspberry Pi + Liquidsoap + Icecast (in French)

https://technic2radio.fr/tuto-raspberry-pi-liquidsoap-icecast/

# good step-by-step instructions

http://wiki.radioreference.com/index.php/Liquidsoap

# how-to autostart programs on raspberry-pi (German)

https://jankarres.de/2014/07/raspberry-pi-autostart-von-programmen-einrichten/

Advertisements

Wireless Vinyl Streaming to Squeezebox

A few years ago I got rid of my whole analog hifi equipment. I replaced it with a decent pair of active loudspeakers, a NAS running Logitech Squeezebox Server (LMS), a pair of Squeezebox Receivers, a Boom, a couple of Logitech Radios and a Squeezebox Classic all connected over Wifi.IMG_0176

Despite Logitech’s discontinuation of the Squeezebox product line and because everything is open source, I have kept this setup and have no plans to replace it in the near or distant future. I just love the flexibility and the audio quality.

But back to the story: With the introduction of Squeezeboxes into my home, I ripped all my CDs to MP3 and AAC and swore to myself I would never again tolerate a CD player. I have been a happy Deezer user (after ditching Spotify) for over three years and also swore to myself, I would never buy any music on physical media again.

Never say never. Last year I went to a hip(ster) Berlin restaurant where they played music from a turntable. They celebrated the record selection, the style of placing it on the turntable before finally playing it. I felt nostalgic, happy memories came to my mind of my huge vinyl collection from the late 70s and 80s that I had fortunately kept in a dry and clean place at my parents’ home. I knew I had to get myself a turntable again.

After checking new and used turntable options, I decided to buy a used Dual 731Q, arguably one of the best turntables from the late 70s, early 80s. I got one that was in a not too bad condition, it just needed some cleaning (mechanics and cover) and a new stylus.

But how to integrate a vintage turntable into my Squeezebox setup? I wanted it to stream directly into the LMS so that I could pick up the signal and distribute it to any Player also for synchronized playback. I needed something to convert the analog signal into a high quality digital signal and then to stream it through wifi to the Squeezebox clients.

Since LMS can connect to any Internet radio stream through a M3U file, the idea was born to create my own audio streaming server fed on-the-fly from the turntable.

But before you can think about digitizing a phono signal, bear in mind that turntable signals are much weaker than typical line-in analog signals and must get pre-amplified first. I use an Analogis Stereo Phono Pre-Amplifier to bring the signal to line-in levels. There might be better pre-amps around, but as I was anyhow going to digitize the signal, I found this to be good value for money.IMG_0177

I decided to use a Raspberry Pi to do the actual transcoding and streaming job together with a low-latency high-end USB A/D converter (since the Pi does not support audio in by default). I opted for a Behringer U-Control UCA222, which is not too expensive, samples up to 48kHz and is powered through USB (at least one power cord saved). The main benefit of the UCA222 is its ALSA compatibility, so that it does not require any additional drivers. You could also buy a Behringer UFO202, which comes already with a built-in phono pre-amp and save a few bucks.

IMG_0178An Edimax Wireless USB adapter is used to connect the Raspberry Pi to Wifi and a fast Class 10 8GB SD card serves as data storage.

The solution is small enough to hide it with all the cables behind a shelf. Listeners only see the turntable and no other equipment except for the loudspeakers, of course. I control everything through iPeng on my iPhone, but you can also use a Squeezebox Remote or the original Squeezebox app.

Now a few words about the actual streaming software. To convert the uncompressed Wave Input into streamable MP3, I use Darkice together with Icecast2 as streaming server on Raspbian OS.

Darkice is configured to convert the high quality digital signal into a 320kbps MP3 (only lossy compression formats are supported by Darkice, in this post I am decribing how to use Liquidsoap with lossless FLAC instead). Icecast2 provides streaming access on port 8000. Note, that my setup is only used behind my home network’s firewall, so I did not feel a need to change default users, passwords, or ports.

Here you can find the Internet-sources how to set it up

Download Raspbian Wheezy

https://www.raspberrypi.org/downloads/raspbian/

Setup Raspbian Wheezy headless and configure it through ssh

http://hertaville.com/2012/09/27/raspbian-raspberry-pi/

Configure Wifi

https://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md

Install and configure Darkice, Icecast on Raspian Wheezy using ALSA input

https://stmllr.net/blog/live-mp3-streaming-from-audio-in-with-darkice-and-icecast2-on-raspberry-pi/

edit /etc/Darkice.cfg

Mount Point: phono

Stream Title: Phono

Bitrate 320, cbr

Stream URL: http://raspberrypi.local:8000/phono

add Darkice to the autostart section

sudo nano /etc/rc.local

darkice &

exit 0

If you don’t want to go through all these tedious steps of setting up Raspian, Darkice and Icecast2 yourself, you can download my Raspberry Pi image from here soon.

Once you’ve set up your Raspberry Pi, all that is left to stream your records through LMS is to create a M3U file that points to the live stream. Below is how my file looks like. I stored it as “Phono.m3u” in the playlist folder of my LMS. Don’t forget to rescan your music library.

#CURTRACK 0
#EXTM3U
#EXTURL:http://IPADDRESS:8000/phono
#EXTINF:-1,Phono
http://IPADDRESS:8000/phono

You must replace IPADDRESS with the actual IP address that was assigned to your Raspberry Pi by your DHCP (mDNS does not work with original Squeezebox players, it does work with “our” Raspberry Pi players, though). You can retrieve it either with a Wifi Scan tool or by logging into your access point and browsing through the list of connected devices.

To listen to a record simply pick “Phono” from your playlists. That will direct LMS to your turntable’s stream. Thanks to LMS you can now even sync different players and listen to your records in different rooms simultaneously.  For easier access you can also add “Phono” to your favorites.

Direct comparison between a 320kbps MP3, a Deezer high quality stream (320kbps) and my 320kbps record stream reveals no real difference. The “analog” signal sounds probably a little less analytic, but warmer and more integrated. And nothing can compare to the joy of browsing through my vinyl collection, choosing a record, taking it out of the sleeve, flipping it to the correct side, placing it on the turntable, before carefully lifting the stylus down and then listening to the little crackling sound when the needle finds the track.

For less than 100€ I now stream records directly to my Squeezebox players in hi-fi quality. What I described here also allows to integrate a tape deck, a microphone or any other analog audio source (musical instrument) into a Squeezebox ecosystem. It can of course also be used with any other media player including Sonos or Teufel Raumfeld that can handle M3U files.

Parts List

Behringer UCA222, Analogis Phono Pre-Amp or Behringer UFO202
Raspberry Pi A+ or B+ with 2000mA power plug
EDIMAX EW-7811UN Wireless USB Adapter, 150 Mbit/s, IEEE802.11b/g/n
SanDisk Ultra Android 8GB microSDHC Class 10