pub struct RawBufferScratch<S: Sample = f32> {
pub input_slices: Vec<&'static [S]>,
pub output_slices: Vec<&'static mut [S]>,
/* private fields */
}Expand description
Scratch space for RawBufferScratch::build.
Callers allocate this on the stack and pass it to build. The
buffer borrows the slices stored here, so this struct must outlive
the returned AudioBuffer.
Generic over the plugin’s sample type S. When the host buffer
matches S, slices point into host memory (zero-copy). When the
host buffer is a different precision, the input is widened/narrowed
into per-channel scratch; the output is rendered into scratch and
the wrapper copies + casts it back to the host buffer at the end
of the block via Self::finish_widening_f32.
Fields§
§input_slices: Vec<&'static [S]>§output_slices: Vec<&'static mut [S]>Implementations§
Source§impl<S: Sample> RawBufferScratch<S>
impl<S: Sample> RawBufferScratch<S>
Sourcepub unsafe fn build(
&mut self,
inputs: *const *const f32,
outputs: *mut *mut f32,
num_in: u32,
num_out: u32,
num_frames: u32,
supports_in_place: bool,
) -> AudioBuffer<'_, S>
pub unsafe fn build( &mut self, inputs: *const *const f32, outputs: *mut *mut f32, num_in: u32, num_out: u32, num_frames: u32, supports_in_place: bool, ) -> AudioBuffer<'_, S>
Build an AudioBuffer<S> from raw f32 host pointers - the
common case (CLAP, LV2, AAX always; VST3/VST2/AU 32-bit mode).
When S = f32, slices point directly into host memory (modulo
in-place input copying). When S = f64, every channel is
widened into per-channel scratch and the wrapper must call
Self::finish_widening_f32 at the end of the block to copy
the rendered samples back to the host’s f32 output pointers.
§Safety
inputsmust point tonum_invalid*const f32pointers (each non-null pointer must address at leastnum_framesreadable samples; null is allowed and yields an empty slice).outputsmust point tonum_outvalid*mut f32pointers (each non-null pointer must address at leastnum_frameswritable samples; null is allowed and yields an empty slice).- The pointed-to memory must remain valid for the lifetime of
the returned
AudioBuffer.
Sourcepub unsafe fn finish_widening_f32(
&self,
outputs: *mut *mut f32,
num_out: u32,
num_frames: u32,
)
pub unsafe fn finish_widening_f32( &self, outputs: *mut *mut f32, num_out: u32, num_frames: u32, )
Copy + narrow the rendered S output back to the host’s
f32 output pointers. No-op when S = f32 (the slices the
plugin wrote already point directly at host memory).
§Safety
outputs and num_out / num_frames must match the values
passed to the prior Self::build call on this scratch.
Sourcepub fn ensure_capacity(
&mut self,
num_in: usize,
num_out: usize,
max_frames: usize,
)
pub fn ensure_capacity( &mut self, num_in: usize, num_out: usize, max_frames: usize, )
Pre-allocate the per-channel scratch vectors so build runs
allocation-free for buses up to num_in × num_out channels
and blocks up to max_frames. Idempotent and growth-only.