Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd some documentation to the repository #22
Comments
|
Hi Lakritzator, I'm aware of it. I was trying at least to document the header files |
|
Hi Badaix, no hurry, but it would be a shame to have your product ignored due to a lack of documentation. Microsoft has added a new "platform" to Windows 10 called the Universal Windows Platform (UWP), which runs on the Windows 10 kernel available on the Desktop (and tablets), Phone, IoT (raspberry pi) and should even work on the HoloLens. According to this: https://msdn.microsoft.com/en-us/library/windows/apps/dn996906.aspx it should support C++ which has an advantage that we don't need to port/change a lot of the underlying code. Still the audio might be another thing... I was thinking of building a C# application, using NAudio, at least a prototype. But this would be hard to maintance, if you make changes to the protocol etc. What Audio engine can be used in UWP? I don't know yet, need to check... Having a remote control API for the multi room part would certainly be nice. P.S. |
|
I would be really interested in a more detailed documentation on the JSON Interface. I started to create some scripts for my home automation system based on the information in [1] & [2] . But so far it only covers volume control for each snapclient instance. If i knew the complete story, I could combine it all in one nifty OpenHab addon. [1] https://github.com/badaix/snapcast/blob/master/android/Snapcast/src/main/java/de/badaix/snapcast/control/RemoteControl.java |
|
I would also like to have documentation for the protocol which is used, I'm looking into creating hardware based clients for a multi-room playback system and for those I'd have to deduce the protocl from source as I need to implement a client myself. |
|
I would love to build an ESP8266 client. The ESP8266 costs 2$ and has i2s. A very simple PCM stream to i2s example is available here: https://gist.github.com/me-no-dev/e8b5131f840822cdd14b Sadly snapcast doesn't seem to have any documentation on the protocol. |
|
I'm also very interested in protocol documentation. I've also dabbled with the ESP and I2S DAC's to see what could be done, but the lack of reference is a bigger hindrance than the hardware limitations! @badaix, I understand this is really boring and tedious work for you, but been three years now and it would be mighty helpful to make snapcast easier to integrate, which in turn would increase the success of the project! |
|
Would there be any interest in collaboratively documenting the protocol? I'm interested in porting the client side to ESP32, it would be great to get some pointers to get me started. |
|
Will an ESP32 be strong enough to do flac/ogg/opus decoding? |
|
I haven't tested for myself, but there is an official esp-adf API that supports all of these (plus more)Link. The ESP32 has 2 cores running at 280 MHz, which should be fine for a single stereo stream, I think. |
|
I would like a documentation of the protocol, as this opens up the widespread of snapcast and hopefully, more and more nice things. The esp32 would be a good extension as client, if this works :) |
|
Question: the Hello message has a MAC address attribute, what does the server use that for? Same question for OS and Arch attributes. |
|
These are just informational fields. The MAC has been used as unique ID in earlier versions. |
|
I'm trying to reverse the protocol by reading the code, and I got a little stuck here:
What is the second socketRead() call for? |
|
The first read is to get just the base massage portion, it's kind of a common header, with the size |
|
Thanks, that makes sense. |
|
I'm definitely interested in collaborating on porting this to esp32 as well. I've tested the esp-adf mp3 examples and they worked fine for me. I'll see about FLAC next probably. I briefly looked over the snapcast client code but had trouble nailing down where the protocol decoding was happening. I may try poking around the function ClientConnection::getNextMessage() next. |
|
The python-snapcast project is not only a python control client, but also has some basic player client code that might be easier to read.
A client must first send a |
|
Fantastic! That's a great starting point, thanks for the pointer! |
|
I haven't had a lot of time to spend on this recently, however I did confirm today that the ESP-ADF's FLAC decoder works without issues (at least on the 2 second sample that I tested with). |
|
The client implementation in |
|
I've been able to make a lot of headway during the holidays! I've been able to re-implement most of the message parsing in C here: https://github.com/bridadan/libsnapcast Still not quite finished, but I'm already getting messages exchanged over a TCP socket connected to |
|
@badaix Can you explain the usage of Stream::getPlayerChunk()? Especially the second parameter (timeout) is a bit confusing. |
|
I wouldn't mind a high-level explanation of that one as well. That function is basically my next thing to tackle for synchronized playback and I've been procrastinating |
|
@jerryr this function is where the magic happens
To synchronize the audio, a lower level audio interface - as alsa is one - can tell the current internal buffer size and estimate when data is played out, as with
Knowing the current delay, e.g. 100ms, we must feed PCM data that should be audible in 100ms to the DAC. This is exactly the
The stream class is aware of
So when the player calls Problem is that there is some noise in this loop. The estimated DAC output time will be noisy and you will not pass the loop exactly every 50ms when feeding 50ms in the DAC, also the DAC might play the audio @48003 Hz instead of 48kHz, the stream might return PCM data that should be audible in 902 ms instead of 900ms, just because there is no recent data left. The stream gathers statistics about the estimated deviation and when the statistics tell us that the deviation is to high, e.g. we're 2ms early or late for a while, the stream is stretched or shortened my 2ms to stay in sync. You can rely on the Pcm chunk timestamps. The really first chunk is tagged with the current server time and the following timestamps are calculated based on the samplerate and the number of samples, i.e. +1s every 48000 samples, so the PcmChunk timestamps can be assumed to be reliable.
|
|
btw: there is a C implementation of Snapcast: SnapCastC. |
|
Nice description - Badaix good starting point for my work tonight. Ran over your snapcast code last night and got it running on my laptop and android phone. Tonight i will play with Brians code on my esp32 and Amps. |
This is certainly a cool project, with a lot of potential.
But I would also love to see clients on Windows 10 (phone, desktop etc.) and am willing to have a go at some of the basics of a .NET application.
The problem I am facing is a lack of documentation, I know that an answer would be "the code is the documentation", but some basic information might help... like "how" (format) are the packages transferred over the wire, how is the synchronization with the audio-clock made etc.
I found a nice document (master's thesis) on "Synchronization of streamed audio between multiple
playback devices over an unmanaged IP network" here: http://www.eit.lth.se/sprapport.php?uid=894
(don't know what license it covers, there is no real copyright on it). This should cover the basics for most people, but maybe it can help to make some parts more understandable or even have snapcast implement some standards...
Anyway, like I said, documentation would be nice. But even without, keep up the good work!