ArborealAudio / arbor

Easy-to-use audio plugin framework
https://arborealaudio.com
MIT License
27 stars 0 forks source link

Use slices in AudioBuffer #3

Open ArborealAudio opened 2 months ago

ArborealAudio commented 2 months ago

Currently we're having to keep [*][*]f32s for audio data, for ease of copying, and just setting an offset which the user will be expected to use when working with audio buffer data. This isn't really ideal--ideally the user would get a slice of slices for audio in/out, and they would just be correctly sized.

I broke my brain trying to figure out how to convert CLAP's audio buffers into slices. Gotta figure it out someday.

Hint for future me: the solution might involve using a FixedBuffer allocator to create new pointers ~-- for stereo audio data we really only need 2 pointers and so~ we can allocate them off a stack-allocated byte buffer, then just copy the [*]s? idk

ArborealAudio commented 2 months ago

b7c7eea1a6399a44204b6347f03f04734cf30ef0

It's easy to implement if you just assume 2 channels. But that is problematic and in general Not Good. Maybe instead of getting cute with a fixed buffer, we just create an intermediate "buffer" sized by the number of channels at init time, then used that as a destination for copying the APIs pointers.