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

input/output buffer types #4

Open
wrl opened this issue Aug 19, 2020 · 1 comment
Open

input/output buffer types #4

wrl opened this issue Aug 19, 2020 · 1 comment

Comments

@wrl
Copy link
Owner

wrl commented Aug 19, 2020

right now, the input buffer type is &[f32] and the output buffer type is &mut [f32]. these represent pretty much exactly what we get from the host.

i have seen other rust libs wrap these buffers in higher-level types (for example, vst-rs's AudioBuffer). perhaps this is a better route?

seems like this could come along with #3 for better defining the "shape" of the buffers that are passed to the plugin.

@SolarLiner
Copy link

I initially had interleaved float arrays as the buffer type in my internal audio engine for Wavr, but changed it to a custom audio buffer similar to vst-rs's because I needed to process channels separatedly, and separating and recombining the interleaved buffer several times was wasteful; instead the audio engine gets a block of interleaved audio from the system, deinterleaves it, and passes it through the audio graph. I don't think there's a use-case for needing interleaved audio from within a plugin anyway, and if there is, it's so niche that the benefits outweigh the hypothetical cost of a plugin having to manually reinterleave the buffer anyway.

Furthermore, having your own audio buffer type means you can attach methods to it providing basic transformation and processing (i.e. VST3 having an audio buffer class that provides per-channel RMS calculation, or my audio buffer implementation here). While those buffers have runtime checking of the shape, with Rust it's entirely possible to have type-level constant generics and trait associated constants to define (and later check) the shape of the I/O buffers.

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

2 participants