It's still great to make the code open, but it's not usable anymore for a self-hosted setup.
623 karma · joined March 31, 2013
It's still great to make the code open, but it's not usable anymore for a self-hosted setup.
[1] https://github.com/badaix/snapcast [2] https://github.com/geekuillaume/soundsync
In the end, I used WebRTC from an external HTTPS webpage I'm hosting and a "mailbox" service where two peers can post and retrieve messages from a UUID. To communicate this UUID on the local network to the peer, I first used an <img> tag with the UUID in the URL query string but this method was recently broken because of increased security measures by browsers. I now use two methods:
- Bonjour: Every peer listen for every bonjour request on the network, on the webpage I make a request to https://soundsync-UUID.local/. The peer then extract the UUID from the request and connect
- TLS Server Name Indication: I use sslip.io to connect to https://UUID_IP.sslip.io/. This is redirected to the local network IP of the peer which use the full domain name in the TLS handshake to extract the conversation UUID. This method doesn't always work because of some router filtering out DNS records resolving to 192.168.X.X.
All this process is very hacky and doesn't always work but I haven't found anything else better. We still don't have a good way to make self-hosting easy for anyone while making it secure and not dependant on an external service.
Soundsync is a software to synchronize every audio speaker in your home and listen to your music however you want. It’s compatible with a lot of existing audio systems (Chromecast, Airplay, Spotify, WebAudio, OS audio) and focus on using what you already own instead of selling you a new proprietary system. I’ve been working on this since early 2020 and it’s in a good enough shape now that I use it everyday at home.
You can install it on any number of Windows, MacOS and Linux computers (and also RaspberryPis) on your local network and control each speaker from the web interface from any web browser on the same network. When multiple speakers are linked to the same audio source, Soundsync synchronizes them to make the playback seamless (less than 10ms drift in most cases). It supports any type of configuration, as many audio sources and audio outputs on any number of devices. You can even connect multiple audio cards on a single computer and control them separately.
The full source-code is available on Github and it’s released under the BSL License. It respects your privacy (more info in the FAQ on the landing page), doesn’t share any information with third-parties and only collects anonymous basic usage data that can be disabled easily.
On the technical side, this is Javascript, uses WebRTC to communicate in a peer-to-peer model (no server-client) and some WebAssembly to encode and resample the audio streams. The Web interface uses the same code as the installable binary for the audio and communication. The binary is an Electron package built on Github Actions. I’m using Cubeb, the multi-OS audio library used by Firefox. This is the most technically complex project I’ve ever done. Some hard problems I’ve encountered include precise audio synchronization, peer-to-peer communication system, connection to local peers from an external https webpage (the controller at https://soundsync.app/controller) and C bindings between the audio lib and NodeJS (which are available separately here https://github.com/geekuillaume/node-audioworklet/).
I’m happy to talk more about this if you have any questions! :)
I think I'm going to try to integrate net-boot in Soundsync this weekend. It would be awesome to be able to install Soundsync on any computer on the network, turn on an option and then just start the rPi to get it to play music.
Perfect game to pass time without the modern games addictive bullshit :)
[0] https://github.com/badaix/snapcast [1] https://github.com/librespot-org/librespot
Just one precision, you don't need to contact S3 to get a presigned URL, it's a cryptographic operation most libs do on your server. This means that if your key is invalid for any reason, the URL will be signed but the error will only be raised when the client starts the upload. You need to check for this in your code.