Can a local server stream FLAC to Roon?


#1

Does anyone know if I can set up a local server for streaming flac to the new radio interface in Roon?


Digitise vinyl playback on the fly
Issues with Roon that stop me buying
Internet Radio FLAC Stations Swap Meet
Connecting a phono ADC to Roon
Turntable output to Roon
Showing (off) your Roon setup - description and photos
Using a Turntable with sonos and Kef LS 50 Wireless
(Andrew Cox) #2

Sure. Try Icecast. It’s free, open source software.


#3

I am wondering, why do you want to stream instead of have the core access the FLAC files directly?


(Henry) #4

Because he wants to apply an external source to Roon and the new FLAC capability makes this possible with something approaching full fidelity. :wink:


#5

Yes, correct. While waiting for ‘the input device’ in Roon the new flac streaming can maybe be a workaround.


#6

Anybody able to stream FLAC from Soundflower (2ch) output to Roon. I“m eagerly waiting to stream Qobuz through Roon to my endpoints. Could Icecast do this? Or is there any other SW able to do it on a Mac?


(Johan N) #7

Would you happen to know which Icecast source clients that support FLAC?

EDIT: Liquidsoap seems to be capable of that.


(Johan N) #8

Got it to work. :smiley:

Analog XLR from phono preamp -> MYTEK ADC-192 -> AES/EBU into Mutec 1.2 -> USB Into NUC with Ubuntu 18.4 LTS -> Liquidsoap -> Icecast -> FLAC in Roon (and other streaming clients).

I’ll describe all the steps involved later but basically it involved installing and setting up Icecast & Liquidsoap and then add your radio station to Roon.

Had to remove liquidsoap-plugin-opus, which came with liquidsoap-plugin-all, to get it to work.
If you see this error in the log “Source /phono failed while streaming: Ogg.Not_enough_data!”, they may help you too.


#9

This is very nice @qdtjni! Thank you! Looking forward to a more detailed description when you have time.


(Johan N) #10

So here we go. One of the few things I’ve been missing in Roon is the ability to get any source like a phono, player, CD, player, etc and have that distributed to multiple rooms. I wasn’t particularly keen to do this with lossy formats. However, now when Internet Radio with FLAC is possible, I’ve been keen to do this for a while.
I just never got around to do it but this thread triggered my interest and Andy’s pointer to Icecast, finally got me going. My use case is that I want to be able to distribute input from Turntables in living room, dining room and office through Roon to all my Roon Zones.

I used Icecast2 as Radio Streaming seriice and Liquidsoap to capture audio in and acting as an icecast client sending that to the Icecast server. Initially I had both running in the same server, an NUC-like Dell. Since that Dell is not in anywhere close any of my Turntables, I changed the setup to run liquidsoap in an RPI3, which is located close to one of my phono pre-amps.

For this to work (with my setup examples) you need:

  • Roon up and running flawlessly
  • No network issues in your LAN
  • Server intended for Icecast up and running with Ubuntu (server) 18.04 LTS
  • Server intended for Liquidsoap, an RPI3, up and running with the latest Raspbian Stretch Lite
  • Both servers need internet access to download software (and patches)
  • A USB ADC or other digital input device is connected to the RPI3 (and some audio playing into it)

Login to your server intended to be Icecast server with ssh,

This server does not need to be connected to your ADC
In my case this is a Dell similar to NUC i5 running Ubuntu Server 18.04 LTS

Get latest patches and install Icecast2

sudo apt update && sudo apt dist-upgrade -y
sudo apt install icecast2 -y
#Enable start at boot, start and check status of the iceast2 service
sudo nano /etc/default/icecast2 
sudo service icecast2 start
sudo service icecast2 status

If everything went ok you should see the service running now
In case your concerned with security change the admins an client passwords but for instruction purposes I left it default keeping this setup simple
#sudo vi /etc/icecast2/icecast.xml
#sudo service icecast2 restart

Check the error log to see that it seems to be running and for error from Client connections, etc.
tail -f /var/log/icecast2/error.log

With a browser you should now be able to access your Icecast server on http://ipaddress_of_youriecastserver:8000
When prompted for username and password, username is admin and password hackme

In another Terminal Window login to server you intend to use as Liquidsoap server and Icecastclient
With the setup here your ADC (or other digital input) must be connected to this server
In my case, this is an RPI3 running latest Raspbian Stretch Lite

Install latest pacthes and install alsa, in case it’s not already installed

sudo apt update && sudo apt dist-upgrade -y
sudo apt install alsa-utils -y 
#Add user pi to group audio so you can run alsa stuff without sudo at next login
sudo usermod -a -G audio pi

#Install Liquidsoap and plugins for alsa, flac and ogg        
sudo apt install liquidsoap  liquidsoap-plugin-alsa liquidsoap-plugin-flac liquidsoap-plugin-ogg -y

#Add liquidsoap user to audio group (see above) and pi to  liquidsoap group for similar reasons 
sudo usermod -a -G audio liquidsoap 
sudo usermod -a -G liquidsoap pi

Change permissions on various liquid soap directories and files, probably a bit too open

    sudo chmod 666 /etc/logrotate.d/liquidsoap
    sudo chmod 777 /var/log/liquidsoap
    touch /var/log/liquidsoap/phono.log
    sudo chmod 666 /var/log/liquidsoap/phono.log
    sudo chmod 777 /run/liquidsoap
    sudo chown liquidsoap:liquidsoap /etc/logrotate.d/liquidsoap
    sudo chown root:root /var/log/liquidsoap
    sudo chown liquidsoap:liquidsoap /var/log/liquidsoap/phono.log
    sudo chown liquidsoap:liquidsoap /var/run/liquidsoap
    sudo touch /etc/liquidsoap/phono.liq
    sudo chmod +x /etc/liquidsoap/phono.liq

Now we can setup liquidsoap
First we check what’s the device number for your ADC

`sudo aplay -l`
#This was the output for me
pi@liquidsoap:~ $ aplay -l
**** List of PLAYBACK Hardware Devices ****
card *1: M20 [MC-1.2 USB 2.0], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

As can be seen device number was 1 for me, this will be used in the setup below
Then we check if your icecast server is reachable via name or ip.
Remember to change mydell.local to your icecast servers hostname or ip address.

ping mydell.local

Finally we edit the iquidsoap script

#sudo vi /etc/liquidsoap/phono.liq
sudo nano /etc/liquidsoap/phono.liq

You can paste the below

#!/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="plughw: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='Phono FLAC', 
  password='hackme',  host='mydell.loca'l, port=8000, url='http://mydell.local:8000/phono', 
  genre ='Misc', phono)

Then change
“plughw:1” to use the device number from aplay -l and mydell.local to resolvable hostname or ip address of your icecast server. Now, save and exit from the editor

(Those fluent in alsa will notice that I used plughw, if you can get hw:1 to work that might suit you better.)

You can start liquid-soap now.

/etc/liquidsoap/phono.liq

If everything is set up correctly, it should start, if not, it will return with our without error message
To find out more

tail -400f /var/log/liquidsoap/phono.log

Given that it went fine you should now see the mount point /phono at http://ipaddress_of_youriecastserver:8000/admin/
Copy the value of the server_url, then click “+Add a Station” in Roon “Internet Radio Stations”, paste the url and click Add Station, and confirmed
Now you should have a Radio Station in Roon that plays whatever you send input into your liquidsoap server

Comments.
To my surprise liquid soap didn’t need any setup at all to auto start at boot, it just worked after reboot.
Meaning no extra setup for restart at boot This may or may not be the case for you.

To get liquidsoap to work in Ubuntu 18.04 LTS, I had to deinstall the opus plugin, i.e.
apt remove liquidsoap-plugin-opus -y

If the stream stops Roon May throw an error message and you need to press play again.
I have not looked into why yet but pretty sure there’s a setting in icecast and or liquidsoap.

Credits
Credit goes to Icecast & Liquidsoap teams, IOT-Solutions and of course Roon and Andy. Cheers guys!

http://www.icecast.org/

http://liquidsoap.info


Support ADC -> RAAT streaming
(Johan N) #11

The instructions for setup of ice cast above works in Raspbian too.
So you can install both icecast and liquidsoap in the same RPI, should you prefer it. :slight_smile:


(Andrew Cox) #12

Hi Johan,
Thanks for posting this. I’ve never tried to setup Icecast, I just knew of its existence as the software underlying a number of working stations, so cudos to you for doing so.


(Reader of the Internets) #13

I’m a little surprised no one has packaged this yet. Surely Allo could take an ADC, a phono pre-amp stage, some electrical engineering, and a RPi with Liquidsoap and Icecast, and offer a plug-n-play FLAC streamer for turntables?


#14

That is a brilliant idea. Maybe the RIAA correction could be done digitally to simplify the phono stage. I know SoX does RIAA correction. What about it @allo.com?


(Reader of the Internets) #15

Or maybe this: http://www.tinyosshop.com/bluetooth-audio-receiver-board-apt-x

With this board, plus Liquidsoap and Icecast, you now have a Bluetooth endpoint so that guest can stream from their phones into your Roon setup.


(Johan N) #16

Great idea.

Although, I think just a RPI bundled with ADC and SW but no RIAA is a better approach rather than having the very low level signals of the phono preamp inside an RPI an all the potential problems it brings. It also opens it up for other analog input signals.


#17

The quality of AD conversion and the analog input stage is of course the most important, Maybe a compromise with MM sensitivity and line level inputs switchable and no passive RIAA correction, just digital. Those with low output MC pickups (like myself) can opt for a step-up transformer.
The SoX RIAA filter can handle 44.1, 48, 88.2 and 96kHz, I guess the current Roon FLAC radio streaming is limited to 16/44.1 so it would not matter.
We should also keep in mind that Roon at some point probably will introduce ‘the input device’ which will allow for higher resolutions.


(Henry) #18

It may be limited to 16 bits but it goes up to 192k.


(Reader of the Internets) #19

Sure. But given the lag times I see in these forums for promised features, I wouldn’t hold your breath while waiting for it. God helps those who help themselves, is what they told me in Sunday school.


#20

Thanks Henry. 16/96 is certainly better than 16/44.1!