-
Notifications
You must be signed in to change notification settings - Fork 5
Selecting a Decoder
Phil Schatzmann edited this page Feb 9, 2024
·
31 revisions
First you need to define the codec or audio format that snapcast is using in /etc/snapserver.conf. Supported values are flac, ogg, opus and pcm. My recommendation would be to use opus!
codec = pcm
is selecting pcm the data will be provided as pcm.
The default sample rate of 48000 is a bit high for pcm, so I suggest to adjust it as well e.g. with
sampleformat = 44100:16:2
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, opus);
The WAVDecoder is part of the AudioTools.
#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/CodecFLAC.h" // https://github.com/pschatzmann/arduino-libflac.git
// codecs
FLACDecoder 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.