Skip to content

Conversation

@theeternalsw0rd
Copy link
Contributor

Always feed a buffer of at most 2 channels to cava regardless of audio output to device. There may still be edge cases that need covered where it has the comment // Unsupported format, handle error (line 405). This handles 16-bit pcm multichannel, 32-bit pcm multichannel, and 32-bit floating point multichannel.

@theeternalsw0rd
Copy link
Contributor Author

After checking on my second computer, I saw that 24-bit seems to be common as well, so I added downmixing for that format.

In further testing there was inconsistency if cava was not fed 16-bit, so I added conversion for mono and stereo 24 and 32-bit as well.

Another thing I did learn is that Dolby Atmos, DTS:X, basically anything with Spatial processing enabled is not available via loopback. So getting that to work would either require developing an audio driver to ship with cava or utilizing third-party software to handle audio mixing and virtual cables.

As it stands right now, cava freezes if fed Dolby Atmos. It seems to handle a failure properly and print that the device is not supported but then locks up. I'll see if I can determine more at a later time.

@karlstav
Copy link
Owner

hi @theeternalsw0rd.

A lot of stuff going on here I can see! I'm afraid I don't have time to go through it in detail, but browsing through it looks like you have added a lot of converting that I don't understand. cava is supposed to handle s8, s16, s24 and float both mono and stereo. But you have added stuff like "convert_mono_f32_to_s16". Maybe the mono processing in cava is not working?

If cava is not working when not fed 16 bit stereo, than that needs to be fixed in cava.

down/up mixing:

https://github.com/karlstav/cava/blob/master/input/common.c#L21

stereo/mono handling is happening around here:

https://github.com/karlstav/cava/blob/master/cavacore.c#L362

@theeternalsw0rd
Copy link
Contributor Author

I've pulled the conversion of stereo and mono out. Turns out the issue my previous refactor resolved that had to do with the graph freezing before reaching zero level when going from audible audio to silence, also resolved the issue with non-16-bit audio. Quite bizarre.

input/winscap.c Outdated

write_to_cava_input_buffers(silent_channels, (unsigned char *)silence, audio);
pCapture->lpVtbl->ReleaseBuffer(pCapture, numFramesAvailable);
pCapture->lpVtbl->GetNextPacketSize(pCapture, &packetLength);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it maybe just packetLength here, without the &?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or maybe better remove the * from the write_silent_frame packetLength function argument and remove the & when calling the function.

@theeternalsw0rd
Copy link
Contributor Author

theeternalsw0rd commented Jul 31, 2025 via email

@theeternalsw0rd
Copy link
Contributor Author

20-bit audio is also used it seems. I've set up a separate branch for that since I cannot test it currently. I'll try to locate some hardware to test on. I think the virtual cable I have at work supports it, so I can check that tomorrow. The changes for the use of packetLength have been pushed.

@theeternalsw0rd
Copy link
Contributor Author

I did find a device that supports 20-bit audio, but that format is not selectable in Windows 11 sound settings. Windows itself may have removed support completely or 20-bit is only available via direct hardware or the audio driver isn't properly sending supported formats to Windows. I will not worry about it at this point. It's available on my repo under the 20-bit branch if anyone should have need. I am assuming anything with 20-bit support also supports other formats too.

@karlstav
Copy link
Owner

karlstav commented Aug 1, 2025

just use the .clang-format file to make the linter happy. don't worry about the commits, I will squash them when i merge

@theeternalsw0rd
Copy link
Contributor Author

Hopefully the linter is happy now. I made the handling of overflowing lines as consistent as possible across the board too.

@theeternalsw0rd
Copy link
Contributor Author

Sorry, didn't realize the linter failure actually generates a patch that it would be happy with. I'll get that applied. I guess the reason for the inconsistent long line formatting is the linter itself being at fault.

@theeternalsw0rd
Copy link
Contributor Author

The linter supplied patch has been applied. Hopefully now it should have no reason to complain.

@karlstav karlstav merged commit 1f8c348 into karlstav:master Aug 3, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants