Fun with sound streaming - 11/09/2016, 01:47

A couple of days ago I decided I wanted to have a stereo sound in my apartment, but without running cables all over the place. I looked at the prices for stereos with wireless speakers and decided they were too expensive.
Since I already had a small Bluetooth/35mm audio speaker which has suprisingly great sound, I decided to buy another one and a Raspberry Pi (I already have an rPi at home). I suspected Bluetooth was most likely not up to the task of streaming audio to 2 devices, so I wasn't surprised when it didn't work.

My plan with the additional rPi was to connect it to the speaker via the audio cable (something which, you know, 'courageous' devices will no longer be able to do as easily) and stream sound to it via wifi.

I have been playing a bit with building my own quick and dirty streaming system; you can see its source here:

As of now, with commands issued by UDP, it can correctly assign itself left or right channels, load and play local files in sync (the "easy" mode of "streaming" :D ) and play whatever it receives in 44100 Hz, signed 16-Bit PCM, little endian format 2-channel (actual streaming).

I wrote a small test programme which needs a header-less file with the sound in the aforementioned format (essentially a headerless WAV):

Right now it buffers 4096 bytes without problems so I hope it will have a low enough latency to stream also live sound and sound from movies.

I will experiment how small the buffer can be and keep the repos updated

I also considered using Xiph Opus but since I want to avoid buffering as much as possible and wireless LANs have become much, much better than what they used to be, I think I can get away with UDP and WAVE transmission >:3

The queue system is also super naïve and totally not thread-safe, but so far it's working :P

A picture of the rPi and the speaker:

< Back to blog

This site doesn't use cookies, does not log IPs and does not track you in any way.