Skip to content

balenaPhono is a project for Raspberry Pi that takes the audio output from a turntable or any other audio device and creates a shoutcast/icecast network stream. This project is great for anyone looking for a cheap and simple way to play vinyl on Sonos speakers.

Notifications You must be signed in to change notification settings

SamEureka/balenaPhono

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

turntable image balenaPhono

A turntable phono/AUX/USB network streamer

balenaPhono is a project for Raspberry Pi that takes the audio output from a turntable or any other audio device and creates a shoutcast/icecast network stream. This project is great for anyone looking for a cheap and simple way to play vinyl on Sonos or Ikea Symfonisk speakers.

Caution

Updated: 5/29/2024

wifi-connect block has been removed. Please note that wifi-connect in balenaPhono was broken. wifi-connect will not retain your wifi settings between restarts requiring you to go through the setup again after every restart. For a system that restarts every 24 hours... that is no good! I could not find a configuration of wifi-connect that would fix this undesired behavior so I removed it. You will have to setup wifi when you create the device image or manually later. I welcome anyone more familiar with balena wifi-connect to fix and create a pull request. For now... no wifi-connect.

UPDATE! 1/3/2024:

  • There are breaking changes.
  • The stream mount point is now named phono.mp3 by default. You can change it by setting DARKICE_MOUNT_POINT and ICECAST_MOUNT_POINT to 'your-cool-mount.mp3'. Existing Sonos Stations and browser bookmarks will need to be updated.
  • I have updated the startup script. It will now attempt to discover your USB Audio device and set the DARKICE_DEVICE variable. The detection logic is not 💯 accurate, you may need to adjust.
  • The rough flow of the detection is: Look for a USB Audio Device (and ignore HDMI Audio), then find the card and device numbers, create the device slug from the discovered numbers. If the variable is already set and matches the detected device the stream will start. If the detection is flawed you can create a BYPASS_DEVICE_CHECK variable and then set DARKICE_DEVICE manually.

Equipment needed:


Installation INstructions

One click install:

Running this project is as simple as deploying it to a balenaCloud application. You can deploy it in one click by using the button below:

balena deploy button

Balena Deploy method:

  1. Ensure you have git and the balena-cli installed and logged into balenaCloud (INSTRUCTIONS HERE)

  2. Follow these steps to create a fleet. The steps here are generic, change as appropriate for your hardware. (INSTRUCTIONS HERE)

  3. Add a new device to your fleet and provision your hardware using balenaEtcher or similar software. (INSTRUCTIONS HERE)

  4. Clone this repo git clone https://github.com/SamEureka/balenaPhono.git

  5. Change into the balenaPhono directory cd balenaPhono

  6. Use balena push command to build and upload the container image to your device. balena push <name of your fleet> (example, my fleet is called 'balenaPhonoDev' balena push balenaPhonoDev)

  7. Wait for Charlie Unicorn to appear!


Post install setup:

  1. The balenaPhono startup script will attempt to discover your sound device and set it automagicaly.

    If the detection fails you may need to bypass the detection and set the DARKICE_DEVICE variable to match your device.

    • Create a BYPASS_DEVICE_CHECK device variable and set it to true
    • Create a DARKICE_DEVICE device variable and set it to match your hardware. Take a look here for troubleshooting tips.
  2. Get the local ip address for your device from the balenaCloud console.

  3. To play the stream in a browser window:

    http://<device-ip>/phono.mp3
    
  4. To add your phono stream to your Sonos system:

    Using the iPhone or Android app

    1. Download the Sonos App. Sonos Downloads (Tested with Sonos S1 Controller App)

    2. Tap into - Browse > TuneIn > My Radio Stations

    3. On the My Radio Stations page tap the top ... and then tap Add New Radio Station

    4. In the 'Streaming URL' field enter http://<device-ip>/phono.mp3 and in the 'Station Name' field enter balenaPhono then tap 'OK'

    Using the Unofficial Sonos Controller For Linux

    1. From the menu bar select - Player > Play URL

    2. Enter http://<device-ip>/phono.mp3 in the field and click 'OK'

Additional setup (not required)

Balena Booter

  • Use the REBOOT_TIME variable to specify the hour of the day you would like balenaPhono to reboot. This keeps the darkice stream from becoming unstable over time. Acceptable values are 0 through 23 representing the hour you want the device to reboot every day.

Available Device Variables:

For advanced configuration
Variable Example Value Note
BYPASS_DEVICE_CHECK true To bypass the automagical DARKICE_DEVICE setup, set this variable to true (be sure to also set DARKICE_DEVICE to match your audio hardware.)
REBOOT_TIME 4 Default is 4 (reboot every 24 hours at 4:00am in the America/Los_Angeles timezone). Acceptable values are 0 through 23 representing the hour you want the device to reboot every day. Darkice audio streams have a tendency to get corrupted after a few days of up time. A python script triggered by cron reboots the host once a day to keep things clean. Looking for a better way... if you have ideas.
TZ America/Los_Angeles Sets the timezone. Look up your timezone here. Default is America/Los_Angeles
ICECAST_LOCATION Interwebs Where your stream is hosted from or where you are located.
ICECAST_ADMIN_EMAIL balenaAdmin@localhost Used for the Icecast status page, doesn't need to be real
ICECAST_CLIENTS 10 How many clients can connect to your stream. Keep it low if you are using a Pi Zero
ICECAST_SOURCE_PASSWORD b@13n4! Password used by Darkice to connect to Icecast. Must be the same as DARKICE_PASSWORD
ICECAST_RELAY_PASSWORD b@13n4! Not exactly sure what this one is for. You can change it with this device variable!
ICECAST_ADMIN_NAME balenaAdmin Username for logging into the admin portal.
ICECAST_ADMIN_PASSWORD b@13n4-@dm1n! Password for the admin portal
ICECAST_HOSTNAME balenaPhono Hostname for the Icecast server
ICECAST_PORT 80 Port that Icecast server listens on. Needs to be the same as DARKICE_PORT
ICECAST_MOUNT_POINT phono.mp3 Should end in .mp3 for MP3 streams and .ogg for Ogg Vorbis encoding
ICECAST_STREAM_NAME balenaPhono Name of your stream.
ICECAST_STREAM_DESC A stream from AUX/Phono Description of your stream.
ICECAST_GENRE Vinyl The genre of your stream.
DARKICE_DURATION 0 Duration of the stream in seconds. Set this to 0 to disable.
DARKICE_BUFFER_SECONDS 1 How many seconds the stream buffers before playing. Minimum value: 1 (seems to work fine)
DARKICE_RECONNECT yes Automatically re-connect to Icecast
DARKICE_DEVICE plughw:0,0 Source device for your stream. Very hard to find information on this setting. Try this man page. The default setting here worked on a pi zero w. On a pi3 I had to change it to plughw:1,0 Good Luck!
DARKICE_SAMPLE_RATE 44100 Sample rate of the source audio. You shouldn't need to change this.
DARKICE_BITS_PER_SAMPLE 16 Bits per sample. You shouldn't need to change this one either.
DARKICE_CHANNEL 2 How many channels. 2 for stereo... 1 for mono
DARKICE_BITRATE_MODE cbr Accepts cbr, abr, vbr. Read the man page for more info
DARKICE_FORMAT mp3 Format of the stream sent to the IceCast2 server. Supported formats are 'vorbis', 'opus', 'mp3', 'mp2', 'aac' and 'aacp'
DARKICE_BITRATE 320 Bit rate to encode to in kBits / sec (e.g. 320). Only used when cbr or abr bitrate modes are specified.
DARKICE_SERVER localhost Icecast server address or url
DARKICE_PORT 80 Icecast port. Needs to be the same as ICECAST_PORT
DARKICE_PASSWORD b@13n4! Needs to be the same as ICECAST_SOURCE_PASSWORD
DARKICE_MOUNT_POINT phono.mp3 Needs to be the same as ICECAST_MOUNT_POINT
DARKICE_NAME balenaPhono Name of the stream.

Getting Help

  • Google is your friend!
  • Submit an issue on this repo and I'll help if I can.

Reference:


Credits:

About

balenaPhono is a project for Raspberry Pi that takes the audio output from a turntable or any other audio device and creates a shoutcast/icecast network stream. This project is great for anyone looking for a cheap and simple way to play vinyl on Sonos speakers.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published