-
Notifications
You must be signed in to change notification settings - Fork 222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
shmem input is broken #375
Comments
To add to this, it works, but is pegging a core to 100% or thereabouts. |
ih @atisharma the main loop did not wait for the shmem input module to set the rate. should be fixed now. for the cpu usage there is some logic missing in the shmem input module. there should probably some checking of whether or not this variable changes: Line 25 in ff29ab5
and then sleep for some ms if there are no update. |
Excellent! I can confirm your fix works. Would you like me to add the timing check you mention to |
I made an attempt, but I have no way of testing it. If it doesn't work, please feel free to have a go at it. |
Thanks for the very fast response! |
does it work better after latest commit: I tried to ref this issue but i hit the '%' instead of the '#' and did not notice. |
It does, thanks. I've been having a look at the squeezelite source that writes to shmem.
which seems also to work. (I don't know how to write zeros on silence though...) I have a question: how did you calculate req.tv_nsec in the previous try? Why does BUFSIZE appear? edit: |
Since shmem input is working now, and since the questions about BUFSIZE and writing zeros are not directly relevant to the issue, I'll close the issue. |
no problem, I did brake this a while back, so it's ok to get it fixed.
this is essentially the time of one whole buffer (around 40ms with 44100 rate). I set it to sleep that long since there is no need to write data any faster than that. But we should probably include your changes regarding the you could create some kind of dummy "silence" buffer before the while loop like this:
and use it like this:
But is it necessary? What happens if there is no audio? Is it uninitialized data in the buffers (the bowl shape you mentioned earlier)? one more thing I don't really understand is the
the original commit by @dnalor we only use the data in the mmap buffer from index Is there any documentation on this? I can't seem to find it. You could try to play around with those number, see what difference it makes. |
Thanks for the explanation. That seems reasonable.
Basically it just leave the spectrum as it was (whatever shape it was when it's paused or stopped, for instance) since I think squeezelite doesn't clear the buffer, it just sets That link may also explain the offset. Actually, I think my understanding of I tried doubling I tried writing silence as you suggest above, and the array of zeros appears as the bowl shape (default config). It's fair to say I don't know why. Playing silent tracks looks all flat. As for documentation on squeezelite's shmem feature, I don't think there is any. The original source code I linked to above is about it. |
I think I have solved both the use the whole buffer:
silence_buffer was the wrong type, needs to be s16_t and different length:
Wait for the buffer index to pass the amount we are to read, then pass to fft:
I am still not sure why BUFSIZE has to be 1/2 of VIS_BUF_SIZE (stereo channels perhaps?), but increasing it beyond 8192 fails. |
do you have stereo enabled in your cava config? can you confirm that it is actually left and right channel that you see? |
I have stereo enabled ( |
Hi @atisharma , could you test shmem with the latest commits? I think we might need to reduce the number of bytes read on each iteration. It should be no more than 512 (fft treble input buffer size) frames (preferably equal) written to the fft buffers. BTW is there an easy way to test shmem? I am thinking about implementing some kind of automated testing to the github actions. |
Hi guys I like to aks first here before open a new issue
Have you any idear? |
@docgalaxyblock running as root looks a bit strange. Are you sure it's necessary? |
Same error here |
hi @Jocker666z, sorry about this, but the smem input is indeed broken. this is actually the same as #418. I haven't been maintaining this input module properly for a while, but I think I have a fix ready, will push it now. |
Thanks the malloc bug fixed, but now noise bug appear. It seems to me that it has something to do with this exchange #375 (comment) As for the background noise when there is silence, a step backwards solves the problem:
I don't know how to solve the problem of background noise while playing music (My knowledge in C is very limited). But I can test all the modifications you want ;) |
Yes looks like something is wrong. I will look at it soon. Please move the discussion over to #418 as this issue was originally for a completely different thing. |
I complied cava from source (0.7.2) on raspbian and tried from the void repo (v0.7.2) on x64.
Starting cava to use the shmem input with squeezelite fails with
I checked and /dev/shm/... is there.
This seems to be because line 510 of cava.c has this line commented out:
// audio.rate = 44100;
As a result, audio.rate defaults to 0 and cava exits with failure.
I uncommented this line and compiled, and it runs, and seems to be OK.
The text was updated successfully, but these errors were encountered: