PC audio & music to Squeezebox without the hassle

I've wanted for a while to play music / all audio from my linux PC on my Squeezeboxes, with ease. I've tried in the past to do this with BPA's Squeezebox WaveInput plugin but this route isn't for the faint hearted. It also limits the audio source just to the Squeezebox Server local machine unless you are advanced. Here is a very simple method which allows you to stream from any linux PC on your network to your Squeezebox. It relies on Video Lan Client VLC, Pulseaudio and Alsa. Here's how...



This approach effectively takes an analog monitor of your sound card and uses VLC to encode it to an MP3 stream and pipe it to a destination MP3 file. The MP3 file is then read via the Squeezebox HTTP client.

Step 1. First find the audio monitor for your soundcard, this uses a pulseaudio command:

pacmd list-sources | awk '/name:.+\.monitor/'

The output should be something like...

    name:
    name:
    name:
    name:
    name:
    name:


I have a more involved setup with 4 soundcards and a couple of network pulseaudio destinations.

Step 2. Adjust your firewall to open port 8081, so the Squeezebox can  access and read the stream:

sudo ufw allow from 192.168.1.0/24 to any port 8081 proto tcp
Step 3. Set VLC to monitor your soundcard and encode the audio:

Edit the pulse:// section (in blue) to use your soundcard, you may need a bit of trial and error here if you have multiple cards, in order to select the right card:

cvlc pulse://alsa_output.pci-0000_01_06.0.analog-stereo.monitor :sout='#transcode{vcodec=none,acodec=mp3,ab=320,ch annels=2,samplerate=44100}:http{dst=:8081/laptop.mp3}' :no-sout-rtp-sap :no-sout-standard-sap


Step 4. Set the Squeezebox to play from URL and enter the URL as:

http://192.168.1.XX:8081/laptop.mp3


Where XX is the IP address of the machine that you wish to send the audio from.
Step 5. Listen = Done! 


The same approach should be easy to replicate with Windows to using these principles.

Note:
1) there's circa a 6 second delay for me due to encoding, network transmission and buffering
2) if you hear no sound check that your music program is using the soundcard you have select to encode with pulse, this can be checked on the output tab of pavucontrol / the sound settings interface.
3) after a while the Squeezebox may stop monitoring the URL if there is no audio playing, in which case just restart the URL on the Squeezebox player, i.e. pause and then restart play.

5 comments:

Note: only a member of this blog may post a comment.