MeadowlarkDAW / creek

Realtime disk streaming IO for audio
Other
112 stars 12 forks source link

Resampling on Read and Write #21

Closed apps4uco closed 1 year ago

apps4uco commented 1 year ago

Hi I just came upon creek today, the idea of the buffers and the ability to seek in realtime is excellent.

This may be a massive scope creep, however, for a project I need to do resampling (and looping).

I have used https://crates.io/crates/rubato to do sample interpolation in another project. Would it be possible to create a Decoder/Encoder using rubato as a wrapper to the underlying Codec?

To enable seeking it would be great for there to be 2 different caches.

I imagine that there could be a pipeline something like

Data in File Format -> Cached Buffers of float -> Cached Resampled data (at different rate) - in chronological order -> Playback sampling (possibly in reverse issue #14, or sample accurate looping)

Is any of this currently possible?

Thanks

apps4uco commented 1 year ago

Sorry, I just saw that you had already addressed resampling in #9, although being able to cache both the decode from disk and also the resampling would be excellent.

Be-ing commented 1 year ago

I don't think this should be done in creek because creek doesn't know what sample rate to target. Depending on the application, the target sample rate can change, potentially continuously in real time as Moiré does. Caching resampled audio doesn't make sense in that case because the cache would have to be invalidated whenever the target sample rate changes, which would require creek to still keep the cache of the un-resampled audio and resample it. Resampling all of creek's cache doesn't make sense when the sample rate can change the next time the application reads data from creek.

Be-ing commented 1 year ago

I do however think it should be easier to pass data from creek to rubato. I have been contributing to the audio crate to create a API to pass audio data between crates and have a work-in-progress branch of rubato using it. I asked the Symphonia maintainer about using the audio crate as well and they expressed some interest.

Be-ing commented 1 year ago

Closing as out of scope