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/