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.
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<H: Sample>(
&mut self,
inputs: *const *const H,
outputs: *mut *mut H,
num_in: u32,
num_out: u32,
num_frames: u32,
supports_in_place: bool,
) -> AudioBuffer<'_, S>
pub unsafe fn build<H: Sample>( &mut self, inputs: *const *const H, outputs: *mut *mut H, num_in: u32, num_out: u32, num_frames: u32, supports_in_place: bool, ) -> AudioBuffer<'_, S>
Build an AudioBuffer<S> from raw host pointers of wire
precision H - f32 in the common case (CLAP, LV2, AAX
always; VST3/VST2/AU 32-bit mode), f64 when the host
negotiated a double-precision wire (VST3 kSample64, VST2
processDoubleReplacing).
When S = H, slices point directly into host memory (modulo
in-place input copying). Otherwise every channel is converted
into per-channel scratch and the wrapper must call
Self::finish_widening at the end of the block to copy the
rendered samples back to the host’s output pointers.
§Safety
inputsmust point tonum_invalid*const Hpointers (each non-null pointer must address at leastnum_framesreadable samples; null is allowed and yields an empty slice).outputsmust point tonum_outvalid*mut Hpointers (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<H: Sample>(
&self,
outputs: *mut *mut H,
num_out: u32,
num_frames: u32,
)
pub unsafe fn finish_widening<H: Sample>( &self, outputs: *mut *mut H, num_out: u32, num_frames: u32, )
Copy + convert the rendered S output back to the host’s H
output pointers. No-op when S = H (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.