pub struct SetupContext {
pub channels: usize,
pub sample_rate: f64,
pub block_size: usize,
}Expand description
Context passed to the PluginDriver::setup closure. Carries the
driver state that’s been resolved by the time setup runs - in
particular the auto-detected channel count, which would otherwise
be invisible to the closure (the user’s &mut P doesn’t know).
Test code that needs to size scratch buffers, validate bus layouts, or branch on stereo-vs-mono before the first process block reads these fields directly:
ⓘ
PluginDriver::<MyPlugin>::new()
.setup(|plugin, ctx| {
assert_eq!(ctx.channels, 2, "stereo run expected");
plugin.scratch = vec![0.0; ctx.block_size * ctx.channels];
})
.run();Fields§
§channels: usizeChannels per audio bus that the driver will run with. Either
the value passed to PluginDriver::channels or the
auto-resolved default from P::bus_layouts()[0].
sample_rate: f64Sample rate the upcoming process loop will use.
block_size: usizeBlock size the upcoming process loop will use.
Trait Implementations§
Source§impl Clone for SetupContext
impl Clone for SetupContext
Source§fn clone(&self) -> SetupContext
fn clone(&self) -> SetupContext
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SetupContext
impl Debug for SetupContext
impl Copy for SetupContext
Auto Trait Implementations§
impl Freeze for SetupContext
impl RefUnwindSafe for SetupContext
impl Send for SetupContext
impl Sync for SetupContext
impl Unpin for SetupContext
impl UnsafeUnpin for SetupContext
impl UnwindSafe for SetupContext
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