pub struct ScratchPool<const N: usize, const FRAMES: usize> { /* private fields */ }Expand description
Pre-allocated buffer pool for intermediate results during audio processing.
Const-constructed, zero-initialized in the data segment. Uses UnsafeCell for
interior mutability — safe because WASM is single-threaded.
Each call to buf(frames) returns the next available &mut [f32] of the
requested length. The cursor wraps around when all slots are used.
§Example
use sesh_sdk::Scratch;
static SCRATCH: Scratch = Scratch::new();
fn process(channels: &mut [&mut [f32]]) {
let frames = channels[0].len();
let cutoff = SCRATCH.buf(frames);
let q = SCRATCH.buf(frames);
let temp = SCRATCH.buf(frames);
// ...
}Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<const N: usize, const FRAMES: usize> !Freeze for ScratchPool<N, FRAMES>
impl<const N: usize, const FRAMES: usize> !RefUnwindSafe for ScratchPool<N, FRAMES>
impl<const N: usize, const FRAMES: usize> Send for ScratchPool<N, FRAMES>
impl<const N: usize, const FRAMES: usize> Unpin for ScratchPool<N, FRAMES>
impl<const N: usize, const FRAMES: usize> UnsafeUnpin for ScratchPool<N, FRAMES>
impl<const N: usize, const FRAMES: usize> UnwindSafe for ScratchPool<N, FRAMES>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more