Expand description
A processing buffer with the exact right maximum size. This is an unsafe abstraction, and should be used with a lot of care. You will have to manually free the buffer, and take care if you make copies of these.
This is an abstraction for the inner most DSP processing, where I don’t want to spend a nanosecond too much on accessing buffers.
The main user is crate::nodes::NodeProg, which takes extra care of allocating and managing the ProcBuf instances.
let mut buf = hexodsp::dsp::ProcBuf::new();
buf.write(0, 0.42);
buf.write(1, 0.13);
buf.write(2, 0.37);
assert_eq!(((buf.read(0) * 100.0).floor()), 42.0);
assert_eq!(((buf.read(1) * 100.0).floor()), 13.0);
assert_eq!(((buf.read(2) * 100.0).floor()), 37.0);
buf.free(); // YOU MUST DO THIS!
Tuple Fields
0: *mut [f32; 128]
Implementations
sourceimpl ProcBuf
impl ProcBuf
sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new ProcBuf with the size of MAX_BLOCK_SIZE.
sourceimpl ProcBuf
impl ProcBuf
sourcepub fn write_from(&mut self, slice: &[f32])
pub fn write_from(&mut self, slice: &[f32])
Writes the samples from slice
to this ProcBuf.
Be careful, the slice
must not exceed MAX_BLOCK_SIZE, or else
you will get UB.
sourcepub fn read(&self, idx: usize) -> f32
pub fn read(&self, idx: usize) -> f32
Reads a sample at idx
. Be careful to not let the idx
land outside of MAX_BLOCK_SIZE.
sourcepub fn slice(&self, len: usize) -> &[f32]
pub fn slice(&self, len: usize) -> &[f32]
Returns a mutable slice to the inner buffer.
len
must not exceed MAX_BLOCK_SIZE.
sourcepub fn slice_mut(&mut self, len: usize) -> &mut [f32]
pub fn slice_mut(&mut self, len: usize) -> &mut [f32]
Returns a mutable slice to the inner buffer.
len
must not exceed MAX_BLOCK_SIZE.
sourcepub fn is_null(&self) -> bool
pub fn is_null(&self) -> bool
Checks if this is a ProcBuf::null.