pschatzmann / arduino-snapclient

Snapcast client for Arduino
40 stars 4 forks source link

How to set 32 bit per sample? #17

Closed constant-flow closed 6 months ago

constant-flow commented 6 months ago

Hi, the DAC I use (TAS5713) requires a high clock rate for the MCLK as i learned from the squeezelite project.

The tas5713 typically has the mclk connected to the sclk. In this configuration, mclk must be a multiple of the sclk. The lowest workable multiple is 64x. To achieve this, 32 bits per channel on must be sent over I2S. Reconfigure the I2S for that here, and expand the I2S stream when it is sent

Doing this based of from the sample code provided here

auto cfg = out.defaultConfig();
...
cfg.bits_per_sample = 32;

Is not sufficient to convince the lib to start 32 bit sample stream, it always falls back to 16. How to setup the stream properly with something like the expansion as mentioned above?

pschatzmann commented 6 months ago

If you want resample on the client side to change the format from 16 to 32 bits, Just wrap the output class (e.g. I2SStream) with a FromatConverterStream or better a NumberFormatConverterStream and provide the converterstream as output class to the snap client. Don't forget to configure the converter class by defining the input and output format and the output format of i2s

Further info can be fund in the Wiki of the AudioTools.

Another option would be to change the format in the snapserver.conf. Then you will not have to change anything on the client side.