For my audio system I’m making use of Logitech Squeezeboxes, as I’ve converted most of my CD’s (yes I’m old ;)) to MP3 format. In this way I’m able to play/stream the same music throughout my house. Spotify is also integrated into this set-up so I’m able to play that as well.
But I also have a record player (old remember ;)) with vinyl records. It would be nice to play them through the same system….
Turns out it’s quite easy to realise.
I’m using a Raspberry Pi to monitor and control some of the domotics in my house which is sitting quite close to the record player, hence Using a remote USB serial device locally (Linux). So this Raspberry Pi seems to be a nice target to use for this project.
First I needed a quality sound-card to feed the audio from the record player into the Raspberry Pi. I ended up buying a behringer one, the U-Control UCA222 (https://www.behringer.com/product.html?modelCode=P0A31)
The sound card is connected to an amplifier (which in turn is connected to the record player). With this set-up the sound flows into the Raspberry Pi. The sound-card is detected and used via Alsa (https://alsa-project.org/wiki/Main_Page)
On the Raspberry Pi I’ve installed IceCast (https://icecast.org) which is being used to stream the audio towards the Squeezebox players. DarkIce (http://darkice.org) is being used to record to the incoming audio, convert it and hand it over to IceCast.
First IceCast needs to be configured. This is simply editing /etc/icecast2/icecast.xml. Most of the things can be kept default.
The authentication info needs to be set, so DarkIce is able to push the encoded stream towards IceCast.
Note, the used passwords are not secure in any way.
<authentication> <!-- Sources log in with username 'source' --> <source-password>ph0n0</source-password> <!-- Relays log in with username 'relay' --> <relay-password>ph0n0</relay-password> <!-- Admin logs in with the username given below --> <admin-user>admin</admin-user> <admin-password>icecast</admin-password> </authentication>
Now we’ve configured IceCast, we can configure DarkIce. This is also pretty straightforward, just edit the DarkIce configuration file /etc/darkice.cfg. Below the config file I’m using
# DarkIce configuration file, edit for your needs before using # see the darkice.cfg man page for details # this section describes general aspects of the live streaming session [general] duration = 0 # duration of encoding, in seconds. 0 means forever bufferSecs = 5 # size of internal slip buffer, in seconds reconnect = yes # reconnect to the server(s) if disconnected realtime = yes # run the encoder with POSIX realtime priority rtprio = 4 # scheduling priority for the realtime threads # this section describes the audio input that will be streamed [input] device = hw:1,0 # soundcard device for the audio input sampleRate = 44100 # sample rate in Hz. try 11025, 22050 or 44100 #bitsPerSample = 16/32 # bits per sample. try 16 16 = mono 32 = stereo bitsPerSample = 16 # bits per sample. try 16 16 = mono 32 = stereo channel = 2 # channels. 1 = mono, 2 = stereo # this section describes a streaming connection to an IceCast2 server # there may be up to 8 of these sections, named [icecast2-0] ... [icecast2-7] # these can be mixed with [icecast-x] and [shoutcast-x] sections [icecast2-0] bitrateMode = vbr bitrate = 320 format = mp3 # format of the stream quality = 0.8 server = localhost # host name of the server port = 8000 # port of the IceCast2 server, usually 8000 password = ph0n0 # source password to the IceCast2 server mountPoint = phono # mount point of this stream on the IceCast2 server name = Platenspeler description = DarkIce stream platenspeler url = http://some.internal.host genre = Various # genre of the stream public = no # advertise this stream? lowpass = -1 highpass = -1
This configuration will capture from the USB sound card. Because a Raspberry Pi has a sound device of it’s own I specify the device via a hardware id. To determine the id, just execute aplay -l in my case this outputs
**** List of PLAYBACK Hardware Devices **** card 0: Headphones [bcm2835 Headphones], device 0: bcm2835 Headphones [bcm2835 Headphones] Subdevices: 8/8 Subdevice #0: subdevice #0 Subdevice #1: subdevice #1 Subdevice #2: subdevice #2 Subdevice #3: subdevice #3 Subdevice #4: subdevice #4 Subdevice #5: subdevice #5 Subdevice #6: subdevice #6 Subdevice #7: subdevice #7 card 1: CODEC [USB Audio CODEC], device 0: USB Audio [USB Audio] Subdevices: 1/1 Subdevice #0: subdevice #0
As you see, card one is the USB audio device.
After firing up both IceCast and DarkIce, the only thing left is to create a favourite within the SqueezeBoxServer pointing towards IceCast at the Raspberry Pi. In my case this is http://some.internal.host:8000/phono
Of course you can point any player which will play mp3 streams towards that location and you get the captured sound streamed towards you.
So a nice addition to my music set-up.