Closed jhuber-de closed 1 year ago
@gh7531 maximum supported buffer length is around 500ms if psram is disabled. You could enable psram from menuconfig which should work but I didn't test for a long time because my aim was always to get it to work without psram
(previously posted under the wrong issue)
Should we include a reference snapserver.conf somewhere? I'm not sure how well it is tuned to ESP32 but seems to work well for me:
chunk_ms = 24
codec = flac
sampleformat = 48000:16:2
buffer = 408
Update: Just tested on my setup - setting sampleformat to 44100:16:2 breaks sound as per OP.
@velaar I didn't see that sample rate was set to 44.1kHz. Probably we should change snapserver.conf located in snapclient/snapserver.conf
. Maybe also the folder should be renamed and README.MD
edited to make it more clear there is the reference config file for the server. I really want to merger NETCONN into master too but didn't find the time to do it yet.
@gh7531 Please use 48000:16:2 and flac (as suggested by @velaar) on snapserver for now as all other settings are either not implemented or hardly tested. At some point I will also look into different sample rate settings too but as I always like to state, I dind't have much use for it till now. Still I'd like to see a fully compatible snapclient at some point to be available on esp32 platform. Hopefully, as there are getting more people involved, this will be achievable soon :)
Thank you both for your help.
The sample rate of 48000 does indeed work. My issue now is that I can't get my source for the snapcast server (in my case librespot) to output at this sample rate properly. But this is not related to your project.
Thank you for your time working on this project
checkout https://github.com/badaix/snapcast/blob/master/doc/configuration.md and jump to the Alsa section. I guess you'll find your solution there
checkout https://github.com/badaix/snapcast/blob/master/doc/configuration.md and jump to the Alsa section. I guess you'll find your solution there
Sadly no solution there. They suggest to use snd-aloop but it doesn't do any resampling. I tried to resample it with this;
pcm.!snapcast {
type plug
slave.pcm hw:1,1,0
slave {
pcm rate48000Hz # Direct default output to the below converter
}
}
pcm.rate48000Hz {
type rate
slave {
pcm writeFile # Direct to the plugin which will write to a file
format S16_LE
rate 48000
}
}
pcm.writeFile {
type file
slave.pcm null
file "/tmp/snapfifo48"
format "raw"
}
But shairport-sync refuses to play into snapcast output, It might help @gh7531 though.
Ideally would love to learn how to resample a pipe into a pipe on Linux but that is definitely not related to project. Fixing 44100 on ESP32 might be nice at some point as well. Sadly, I'm far from your level of programming so can only offer testing. Presently running the latest pull request on my hardware.
Maybe this can be of help? https://github.com/badaix/snapcast/blob/master/doc/player_setup.md Also see the alsa section
Maybe you can playback to the loopback device and use snapcast process to start arecord with 48khz from the loopback device. I did such a thing in the past successfully although I believe I started arecord manually und piped its output into snapfifo
Ideally would love to learn how to resample a pipe into a pipe on Linux but that is definitely not related to project.
Probably cpiped from the line in example in combination with the alsa example can achieve what you want? Let shairport do its playback at 44.1khz and capture with cpiped at 48khz from the loopback device.
I will definitly try to fix the samplerate problem at some point but at the moment i am designing a custom PCB which will run snapclient so i can spread it around the house. Time is scarce with a two year old at home so this can take a while :)
Great to have someone else to test and find my errors.
Ok, just tested with sample rate 44.1kHz and found there is a problem with chunk duration detection in http_get_task()
around line 1387.
size_t decodedSize = pcmData->totalSize; // pFlacData->bytes;
scSet.chkDur_ms = (1000UL * decodedSize) / (uint32_t)(scSet.ch * (scSet.bits / 8)) / scSet.sr;
decodedSize results in 4608 bytes which are 1152 frames using 44100:16:2
setting. When calculating scSet.chkDur_ms
this results in a fractional number (26.122ms) while scSet.chkDur_ms
is an uint32_t
from there on all other calculations using scSet.chkDur_ms
will be wrong and we will get memory allocation/access errors at some point.
I am currently not sure how to handle that though.
found that dsp_processor()
causes kernel panic with sample rate set to 44.1kHz and if disabled "only" syncing isn't working because of above reason.
found that
dsp_processor()
causes kernel panic with sample rate set to 44.1kHz and if disabled "only" syncing isn't working because of above reason.
I did not test, but stereo flow should work even with soft volume enabled. The other flows use the buffer that is created with dsp_setup_flow(500, scSet->sr, scSet->chkDur_ms)
, so probably the buffer is too small.
Could you simply change scSet.chkDur_ms to float and use ceil() for memory allocation?
I'll try when I got time. Maybe it's as easy as that :)
Hi,
I have an issue with the snapclient on my LyraT v4.3. I build the firmware using the NETCON-Branch and changed only my wifi and snapcast server IP using the menuconfig. Flashing and connecting to the snapcast server works, but the playback using librespot as input to snapcast is a horrible stuttery noise. Other clients like my phone work just fine with my librespot / snapcast setup.
The output of the LyraT throws a ton of
E (250821) PLAYER: Failed to allocate IRAM memory for pcm chunk payload
andE (250821) PLAYER: Failed to allocate IRAM memory for pcm chunk payload
warnings / errors.This is another output right after reseting the LyraT and starting the playback on spotify
Any idea what is going on here?