-
Notifications
You must be signed in to change notification settings - Fork 5
Selecting a Decoder
First you need to define the codec or audio format that snapcast is using in /etc/snapserver.conf. Currently supported values are opus and pcm. My recommendation would be to use opus!
codec = opus
The advantage of PCM is that it is a simple audio format and no additional codec library needs to be installed.
codec = pcm
is selecting pcm and the data will be provided as wav.
The default server settings are a too high for PCM: I recommend to lower the following values:
# Default source stream read chunk size [ms]
chunk_ms = 8
# Buffer [ms]
buffer = 500
You need to install the necessary decoder library first! (See the urls below). Then you can use them in your Arduino sketch as follows:
// codecs
WAVDecoder pcm;
// setup client
WiFiClient wifi;
I2SStream out;
SnapClient client(wifi, out, pcm);
The WAVDecoder is part of the AudioTools. If you use PCM with the default Processor, you need to increase the I2S buffer: e.g.
auto cfg = out.defaultConfig();
cfg.buffer_size = 512;
cfg.buffer_count = 40;
out.begin(cfg);
With the SnapProcessorRTOS, the buffering is done with the encoded data and the default i2s settings are ok.
#include "AudioCodecs/CodecOpus.h" // https://github.com/pschatzmann/arduino-libopus.git
// codecs
OpusAudioDecoder opus;
// setup client
WiFiClient wifi;
I2SStream out;
SnapClient client(wifi, out, opus);
You need to install libopus
#include "AudioCodecs/CodecFLACFoxen.h" // https://github.com/pschatzmann/arduino-libfoxenflac
// codecs
FLACDecoderFoxen flac;
// setup client
WiFiClient wifi;
I2SStream out;
SnapClient client(wifi, out, flac);
You need to install libflac
#include "AudioCodecs/CodecVorbis.h" //https://github.com/pschatzmann/arduino-libvorbis-tremor
// codecs
VorbisDecoder ogg;
// setup client
WiFiClient wifi;
I2SStream out;
SnapClient client(wifi, out, ogg);
You need to install libvorbis-tremor. Currently it is only working with the low memory branch.