pub struct ProcBuf(*mut [f32; 128]);
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

Creates a new ProcBuf with the size of MAX_BLOCK_SIZE.

Create a new null ProcBuf, that can’t be used.

Writes the sample v at idx.

Writes the samples from slice to this ProcBuf. Be careful, the slice must not exceed MAX_BLOCK_SIZE, or else you will get UB.

Reads a sample at idx. Be careful to not let the idx land outside of MAX_BLOCK_SIZE.

Returns a mutable slice to the inner buffer. len must not exceed MAX_BLOCK_SIZE.

Returns a mutable slice to the inner buffer. len must not exceed MAX_BLOCK_SIZE.

Fills the ProcBuf with the sample v.

Checks if this is a ProcBuf::null.

Deallocates the ProcBuf. If you still keep around other copies of this ProcBuf, you will most likely land in UB land.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Formats the value using the given formatter. Read more

Copies the contents of this ProcBuf to the given slice.

  • len - the number of samples to copy from this ProcBuf.
  • slice - the slice to copy to.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.