Question about chunk size
I'm currently trying to make my dj engine (https://codeberg.org/obsoleszenz/librecdj/) sample accurate. Until now I used SincFixedOut and whenever the chunk size from the audio host changed, i offloaded the creation of a new SincFixedOut<T> on a worker thread. Buf to make it sample accurate, i want to partition the buffer into smaller buffers, according to the midi events and their timestamp. The slices would be all of different sizes, meaning i would need multiple Resamplers. As this is a realtime context i can't heap allocate a new Resampler and I wonder if it would be possible to change the chunk size on an existing resampler? Or am I overseeing something?
It would be possible to change the chunk size of the SincFixedIn/Out and FastFixedIn/Out. I think the easiest way to do this while avoiding allocations would be to only allow values equal to or smaller than what the resampler was created with. So you create a resampler with the largest chunksize you expect to need, and then reduce it to what is needed at the moment.
There could then be s trait method called set_chunksize or something like that, that changes the input or output chunksize depending on the resampler type (or an error if this isn't supported or if the new value is too large).
It would be possible to change the chunk size of the SincFixedIn/Out and FastFixedIn/Out. I think the easiest way to do this while avoiding allocations would be to only allow values equal to or smaller than what the resampler was created with. So you create a resampler with the largest chunksize you expect to need, and then reduce it to what is needed at the moment.
There could then be s trait method called set_chunksize or something like that, that changes the input or output chunksize depending on the resampler type (or an error if this isn't supported or if the new value is too large).
Nice! This sounds really good (:
Only allowing chunk sizes <= the initial max_chunk_size would be perfect and all that i need. I actually started playing around with this idea, but i hit an issue in the internals. The needed_input_size became 0 after the first process call. I opened a PR here, but maybe makes sense to start over again: https://github.com/HEnquist/rubato/pull/81
That PR has a lot more changes than what is required! See https://github.com/HEnquist/rubato/pull/82
It's a draft and only implemented for SincFixedIn/Out so far but I think it works as it should. Can you try it?
That PR has a lot more changes than what is required! See #82
It's a draft and only implemented for SincFixedIn/Out so far but I think it works as it should. Can you try it?
Ouh nice! Thank you :) I will give it a spin but might need a couple of days.
That PR has a lot more changes than what is required! See #82
It's a draft and only implemented for SincFixedIn/Out so far but I think it works as it should. Can you try it?
Sorry, I didn't find time yet to play around with this further, have to fix my software to play a gig this week and I was a bit overoptimisitic to pull off the major change of a sample accurate audio engine ^^ So I hacked in a intermediate solution and come back to the proper way after the gig :) So sorry for no update...
@HEnquist I finally found the time and brain to implement sample accurate playback on my side and it works quite good so far :) https://codeberg.org/obsoleszenz/librecdj/pulls/47/files#diff-d075ab60878d56dab23e87a12135b50c80e0fa83
Thanks a lot for implementing this <3
Great, thanks! Then I'll include this in the next release.
This is included in the v0.16.0 release.