-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Abstracting over sample format? #34
Comments
So the This crate is careful to put as few bounds as possible on audio buffers (note that they're usually either |
Rubato will never support anything other than floats internally. I don't think it's unique in that sense, I rather think this is a pretty common limitation for things doing non-trivial math. What I need is a way to seamlessly convert whatever format the samples are stored in to floats (and then from floats to whatever the user needs afterwards). Of course it's always possible to copy and convert samples to a new buffer before using them, but this is exactly what I'm hoping to avoid. |
One way that could work would be to add a converting layer on top of
this gives an error saying I also need to specify the associated types Channel and Iter. That would really limit things, can something smarted be done? |
I got the converting wrapper working, just needed to use an intermediate trait without associated types. I tried using |
Definitely |
Here is an example of using the converting wrapper of
|
We can definitely build out an equivalent |
The |
Thanks for merging #35! // Create a view of the data with as a slice of i32
let data_view = unsafe {
let ptr = byte_data.as_mut_ptr() as *mut i32;
let len = byte_data.len();
std::slice::from_raw_parts_mut(ptr, len / 4)
}; |
I frequently get questions about how to use my resampling library to resample audio data that is in integer format, often
i16
but it varies. My resampler (as most other non-trivial signal processing) must work on float samples. So I need an abstraction layer that lets me read and write float samples to and from input and output buffers, no matter what layout and sample format the actual data buffer is using. Usingaudio
buffers for input and output solves this for the layout, but it doesn't help with the sample format. Are there plans to support this inaudio
? Is it even possible with the current design?I have experimented with implementing a solution for this, which ended up as this: https://github.com/HEnquist/audioadapter-rs
This solves the problem, but with the obvious downside that it's a completely different solution than the
audio
buffers. It does however implement simple wrappers foraudio
buffers, so a project usingaudioadapter-rs
would be able to also useaudio
buffers.Initially I was planning on using
audio
buffers, but since it only solves half my problem I'm not sure about that any more. So what are the plans? I also see that there hasn't been much activity here lately which is a little worrying.The text was updated successfully, but these errors were encountered: