Struct nih_plug::buffer::Block

source ·
pub struct Block<'slice, 'sample: 'slice> { /* private fields */ }
Expand description

A block yielded by BlocksIter. Can be iterated over once or multiple times, and also supports direct access to the block’s samples if needed.

Implementations§

source§

impl<'slice, 'sample> Block<'slice, 'sample>

source

pub fn samples(&self) -> usize

Get the number of samples per channel in the block.

source

pub fn channels(&self) -> usize

Returns the number of channels in this buffer.

source

pub fn iter_mut(&mut self) -> BlockChannelsIter<'slice, 'sample>

A resetting iterator. This lets you iterate over the same block multiple times. Otherwise you don’t need to use this function as Block already implements Iterator. You can also use the direct accessor functions on this block instead.

source

pub fn iter_samples(&mut self) -> SamplesIter<'slice, 'sample>

Iterate over this block on a per-sample per-channel basis. This is identical to Buffer::iter_samples() but for a smaller block instead of the entire buffer

source

pub fn get(&self, channel_index: usize) -> Option<&[f32]>

Access a channel by index. Useful when you would otherwise iterate over this Block multiple times.

source

pub unsafe fn get_unchecked(&self, channel_index: usize) -> &[f32]

The same as get(), but without any bounds checking.

Safety

channel_index must be in the range 0..Self::len().

source

pub fn get_mut(&mut self, channel_index: usize) -> Option<&mut [f32]>

Access a mutable channel by index. Useful when you would otherwise iterate over this Block multiple times.

source

pub unsafe fn get_unchecked_mut(&mut self, channel_index: usize) -> &mut [f32]

The same as get_mut(), but without any bounds checking.

Safety

channel_index must be in the range 0..Self::len().

source

pub fn to_channel_simd<const LANES: usize>( &self, sample_index: usize ) -> Option<Simd<f32, LANES>>where LaneCount<LANES>: SupportedLaneCount,

Available on crate feature simd only.

Get a SIMD vector containing the channel data for a specific sample in this block. If `LANES

channels.len()then this will be padded with zeroes. IfLANES < channels.len()` then this won’t contain all values.

Returns a None value if sample_index is out of bounds.

source

pub unsafe fn to_channel_simd_unchecked<const LANES: usize>( &self, sample_index: usize ) -> Simd<f32, LANES>where LaneCount<LANES>: SupportedLaneCount,

Available on crate feature simd only.

Get a SIMD vector containing the channel data for a specific sample in this block. Will always read exactly LANES channels, and does not perform bounds checks on sample_index.

Safety

Undefined behavior if LANES > block.len() or if sample_index > block.len().

source

pub fn from_channel_simd<const LANES: usize>( &mut self, sample_index: usize, vector: Simd<f32, LANES> ) -> boolwhere LaneCount<LANES>: SupportedLaneCount,

Available on crate feature simd only.

Write data from a SIMD vector to this sample’s channel data for a specific sample in this block. This takes the padding added by to_channel_simd() into account.

Returns false if sample_index is out of bounds.

source

pub unsafe fn from_channel_simd_unchecked<const LANES: usize>( &mut self, sample_index: usize, vector: Simd<f32, LANES> )where LaneCount<LANES>: SupportedLaneCount,

Available on crate feature simd only.

Write data from a SIMD vector to this sample’s channel data for a specific sample in this block.. This assumes LANES matches exactly with the number of channels in the buffer, and does not perform bounds checks on sample_index.

Safety

Undefined behavior if LANES > block.len() or if sample_index > block.len().

Trait Implementations§

source§

impl<'slice, 'sample> IntoIterator for Block<'slice, 'sample>

§

type Item = &'sample mut [f32]

The type of the elements being iterated over.
§

type IntoIter = BlockChannelsIter<'slice, 'sample>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<'slice, 'sample> RefUnwindSafe for Block<'slice, 'sample>

§

impl<'slice, 'sample> !Send for Block<'slice, 'sample>

§

impl<'slice, 'sample> !Sync for Block<'slice, 'sample>

§

impl<'slice, 'sample> Unpin for Block<'slice, 'sample>where 'sample: 'slice,

§

impl<'slice, 'sample> !UnwindSafe for Block<'slice, 'sample>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T, U> ToSample<U> for Twhere U: FromSample<T>,

§

fn to_sample_(self) -> U

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Any for Twhere T: Any,

§

impl<S, T> Duplex<S> for Twhere T: FromSample<S> + ToSample<S>,