Stream Turntable (Vinyl) to Chromecast

by simplicii in Circuits > Raspberry Pi

2391 Views, 0 Favorites, 0 Comments

Stream Turntable (Vinyl) to Chromecast

20230226_125558.jpg
FR2EQ2JLELEICJW.jpg
20230226_125654.jpg

Problem

I have multiple speakers from different types and brands around the house but they share chromecast built-in or Chromcast Audio attached to them.

  1. 2 B&O Penta with Chromecast audio attached to analog Cinch-In (works amazingly good as B&O active speakers recognize if there is a input and switch themselfs on and off, love it)
  2. 2 B&O Beolab 4000 with Chromecast Audio attached to analog Cinch-In
  3. 3 Raumfeld Speakers (Raumfeld One S, One M and Cube) with Chromecast built-in
  4. Logitech 5.1 Z906 5.1 in my office attached to Chomecast Audio over S/PDIF as well as to the PC of course)

Goal

So I wanted to stream my vinyl from my old (non -USB) REVOX B790 turntable to the "Party" Chromecast Group, containing 3 Speakers.


Solution 1

VinylCast unfortunately did not work for me, although I had bought Behringer UFO202 preamt digitalizer and USB-A -> USB-C OTG cable. Samsung S20 would not receive any input althought if recognised the UFO202.

Solution 2 (works)

So there was another Project on the Internet using a Raspberry Pi which works quite well now, but I like to give more detailed Info about how to set it up.

Source 1: How to stream your record player throughout your home (for cheap)

Source 2: How to Build an Internet Radio Station With Raspberry Pi, Darkice, and Icecast


Supplies

UFO202_P0A12_Front_XL.png
20230226_125558.jpg
20230226_125503.jpg
  • Behringer Analog->Digital /w PreAmp UFO202
  • Raspberry Pi 3 or any other

Prepare Raspberry Pi

Screenshot 2023-02-26 130643.png

Download Raspberry Pi OS from their site and write it on SD Card with official Raspberry Imager

  1. make sure you configure it "cogwheel" before writing
  2. enable SSH
  3. set Wireless connection info

Start Raspberry PI and find its IP adress on your router (Attached devices)

Use SSH (i.e Putty) to connect to your PI and update.

sudo apt-get update
sudo apt-get upgrade


Install Darkice on Pi

sudo apt-get install darkice


Install Icecast2 on Pi

sudo apt-get install icecast2

Connect Behringer to Pi and Check Its "device" ID

Connect your Behringer UFO202 or similar device (maybe one without preamp) to your Pi with USB

arecord -l

Will give you a ourput similar to this:

**** List of CAPTURE Hardware Devices ****
card 0: CODEC [USB Audio Codec], device 0: CDC PCM Codec-0 []
 Subdevices: 0/1
 Subdevice #0: subdevice #0


So this is your Behringer: in config you will see often people use numers like hw:0,0. I would not do this a Pi starts up the device may get another address.

So: use the string behind your card #: -> i.e CODEC

=> plughw:CODEC,0

will be your device location.

Configure Darkice

in /home/pi

nano darkice.cfg

add insert following config:

[general]
duration = 0 # duration in s, 0 forever
bufferSecs = 1 # buffer, in seconds
reconnect = yes # reconnect if disconnected

[input]
device = plughw:CODEC,0 # Soundcard device for the audio input
sampleRate = 48000 # sample rate 11025, 22050 or 44100
bitsPerSample = 16 # bits
channel = 2 # 2 = stereo

[icecast2-0]
bitrateMode = cbr # constant bit rate ('cbr' constant, 'abr' average)
#quality = 1.0 # 1.0 is best quality (use only with vbr)
format = mp3 # format. Choose 'vorbis' for OGG Vorbis
bitrate = 320 # bitrate
server = localhost # or IP
port = 8000 # port for IceCast2 access
password = hackme # source password for the IceCast2 server
mountPoint = vinyl.mp3 # mount point on the IceCast2 server .mp3 or .ogg
name = Raspberry Pi

Remember to change "device" if you get some different result in previous step for the device address. I changes sampleRate to 48000 as Behringer UFO202 delivers 48k.


Optional: You can change format to vorbis, giving you less delay on playing the sound. But try first mp3 untill it works.

format          = vorbis
mountPoint = rapi.ogg

Startup Script for Darkice

In the source descriptions they create a cron job to launch darkice. I don't like that and use service.

in /home/pi

nano darkice.sh

insert:

#!/bin/bash
sudo /usr/bin/darkice -c /home/pi/darkice.cfg


sudo chmod 755 /home/pi/darkice.sh

Create service:

sudo nano /etc/systemd/system/darkice.service

insert:

[Unit]
Description=Darkice Service
After=network-online.target

[Service]
Type=simple
ExecStart=/bin/bash /home/pi/darkice.sh
Restart=on-failure
RestartSec=20s

[Install]
WantedBy=multi-user.target

reload services

sudo systemctl daemon-reload

enable service

sudo systemctl enable darkice.service

Start Icecast2

sudo service icecast2 start

Start Darkice

sudo systemctl start darkice.service

Check status:

sudo systemctl status darkice.service

Connect Turntable

  1. connect Turntable to Behringer
  2. connect Behringer to Raspberry USB
  3. Power Raspberry
  4. wait a little bit
  5. Check for the IP on your Router
  6. Make a IP fixed, "reserved IP on your router" so it is always the same (in my case 192.168.2.91)
  7. Connect to your Icecast running on your Raspberry using the IP you figured out.
  8. i.e http://192.168.2.91:8000/
  9. You should see a entry in "mountpoint" if not, check darkice config and status of darkice (maybe there is a typo)
  10. Turn on Turntable and play a LP . You can test your stream on your PI adress, in my case (http://192.168.2.91:8000/vinyl.mp3) in your Browser.

Send Stream Address to Chromecast

Screenshot 2023-02-26 135508.png
Screenshot 2023-02-26 140545.png

In "Source 1:How to stream your record player throughout your home (for cheap)" Guy wrote a simple Mobile app, which sends the Stream URL to your Chromecast.

I have Home Assistant at home and prefer to have a "Button" there.

Make sure you have Chromecast Integration activated.

Home Assistant: Settings -> Integrations -> ChromeCast (chech the "name" of your Chromecast Player r Group you want to use)

(if not there add Chromcast Integration)


In Home Assistant:

  1. Settings-> Devices and Services -> Helpers -> Create Helper
  2. Button -> Name "Vinyl Cast"

Home Assistant Overview:

  1. Edit Dashboard
  2. Add Card
  3. Button
  4. Show Code Editor
  5. copy paste following
  6. Or use the attached image to fill out information via Visual editor.
show_name: true
show_icon: true
type: button
tap_action:
  action: call-service
  service: media_player.play_media
  target:
    entity_id:
      - media_player.party
  data:
    media_content_id: http://192.168.2.91:8000/vinyl.mp3
    enqueue: play
    media_content_type: audio/mp3
entity: input_button.vinyl_cast
name: Vinyl Cast
show_state: false


Make sure your "Chromecast player" or "Chromecast group" is name correctly:

    entity_id:
      - media_player.party

and your Media URL is correct!

media_content_id: http://192.168.2.91:8000/vinyl.mp3


Optional: if you use ogg vorbis, change

media_content_id: http://192.168.2.91:8000/vinyl.ogg


media_content_type: audio/ogg

Test It

The mp3 encoding in my case has 10s delay, so be patient if you press the button the first time.

You may try to change to ogg vorbis.

Optional: Smart Button to Start the Streaming

20230311_134455.jpg

If you have a Smart Home System like Home Assistant or OpenHab, you can program a Button that starts the streaming.

Move the Action to a script and then trigger it by a Button (like the Aqara Button mini).

So, if you want to listen LP, just plug in the Raspberry and Turntable, put on your Music and press the Button to stream it :-)