Skip to content
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

[request if possible] add r8brain resampling #922

Open
TheBestKmanEver opened this issue Oct 1, 2023 · 8 comments
Open

[request if possible] add r8brain resampling #922

TheBestKmanEver opened this issue Oct 1, 2023 · 8 comments

Comments

@TheBestKmanEver
Copy link

TheBestKmanEver commented Oct 1, 2023

title says it. see following links
https://www.voxengo.com/product/r8brain/
https://github.com/avaneev/r8brain-free-src

@kcat
Copy link
Owner

kcat commented Oct 2, 2023

I'm not sure if that's usable for OpenAL, at least in that form. OpenAL needs to be able to adjust the resampling rate on the fly, as a result of AL_PITCH or AL_VELOCITY changes, and OpenAL Soft needs it to be real-time safe (no (re)allocations, etc when running or updating). It also needs to track sub-sample positions.

It may be possible to take out the guts of the resampler and fit it into what OpenAL Soft needs, though it would be a fair bit of work.

@TheBestKmanEver
Copy link
Author

@TheBestKmanEver
Copy link
Author

just a poke :P
curious if you have decided to possibly add this sometime in the near distant future??

@kcat
Copy link
Owner

kcat commented Oct 30, 2023

I wouldn't expect it any time soon. It would need significant changes to make work with the library as well as adding the ability to dynamically adjust the resampling rate in a real-time-safe manner. I also wouldn't be surprised if performance ends up a problem, since OpenAL needs to be able to resample potentially hundreds of sounds at once, with higher quality resamplers having higher CPU impact.

@TheBestKmanEver
Copy link
Author

TheBestKmanEver commented Oct 31, 2023

it's realtime friendly though (based on the source page)
i do understand that it might be a lot of work to implement though. it being c++ is likely a bit of bonus (maybe)
i would really love to see this though so instead of resampling via Reaper with r8brain to my output (48k) ii can just set it in openal and forget :P this way i will have top quality even if i upsample. yes i know this adds nothing but instead of some loss in quality from the system resampler, this is also really good for files from a nicely useless 96k+ samplerate to 48k

either way, ill leave this open for now and if it does end up being added in the future i will close this... unless it ends up not being possible

@kcat
Copy link
Owner

kcat commented Nov 1, 2023

it's realtime friendly though (based on the source page)

The actual processing is, but changing the resampling rate needs to allocate new structures and buffers, which isn't real-time safe. OpenAL has different requirements for resampling sources than fixed playback or conversion, like being able to accurately report the playback position in a passively fed buffer queue, or being able to dynamically ramp the playback speed up and down. Low-latency mixing and playback will also always run into limits with resampling quality due to better quality resampling needing larger filters, which increases latency.

@GranMinigun
Copy link

As a possible alternative, have you looked into the resampler from SpeexDSP? No idea how well it reacts to frequent input rate changes, but quality and latency are pretty decent.

@kcat
Copy link
Owner

kcat commented Nov 2, 2023

I haven't looked into that. From a quick look, it seems potentially more doable, though from what I'm reading, it seems to be very similar to what OpenAL Soft already has for the bsinc resamplers; the primary difference seems to be that OpenAL Soft uses linear interpolation between phase indices while speex uses cubic (though it's unclear how much that influences the quality; it seems speex primarily does that to make the tables smaller, and doesn't mention any impact on quality).

Aside from that, OpenAL Soft has only a couple settings (12 points up to 24 for downsampling, and 24 points up to 48 for downsampling, all with a -60dB stop band) while speex has many more. Simply adding more options (larger filters that further attenuate the the stop band and shrink the transition band) would provide better quality resamplers like speex, although it's important to note that it will have an impact on performance even with a moderate (compared to speex) size of 64, given OpenAL may need to resample hundreds of sources at once as opposed to Speex, which only needs to do a handful of channels from an audio file. Its primary use-case would be for making the WASAPI resampler sound better where it only does a handful of channels, or replace some uses of the polyphase resampler to perform faster where quality isn't as important.

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

No branches or pull requests

3 participants