pub struct AudioFrameBuilder { /* private fields */ }Expand description
Builder for configuring an AudioFrame with ergonomic method chaining
Implementations§
Source§impl AudioFrameBuilder
impl AudioFrameBuilder
Sourcepub fn sample_rate(self, rate: i32) -> Self
pub fn sample_rate(self, rate: i32) -> Self
Set the sample rate
Sourcepub fn format(self, format: AudioFormat) -> Self
pub fn format(self, format: AudioFormat) -> Self
Set the audio format
Sourcepub fn layout(self, layout: AudioLayout) -> Self
pub fn layout(self, layout: AudioLayout) -> Self
Set the audio data layout (planar or interleaved)
- Planar: All samples for channel 0, then all for channel 1, etc.
- Interleaved: Samples from all channels are interleaved.
Defaults to AudioLayout::Planar which is the native format for FLTP.
§Example
use grafton_ndi::{AudioFrame, AudioLayout};
// Planar layout (default)
let frame = AudioFrame::builder()
.channels(2)
.samples(100)
.layout(AudioLayout::Planar)
.build()
.unwrap();Sourcepub fn data(self, data: Vec<f32>) -> Self
pub fn data(self, data: Vec<f32>) -> Self
Set the audio data as 32-bit floats
The data length must equal num_channels * num_samples. The layout must match
the configured AudioLayout:
- Planar:
[C0S0, C0S1, ..., C1S0, C1S1, ...] - Interleaved:
[C0S0, C1S0, C0S1, C1S1, ...](converted to planar at build time)
Sourcepub fn build(self) -> Result<AudioFrame>
pub fn build(self) -> Result<AudioFrame>
Build the AudioFrame
When AudioLayout::Interleaved is set, the input data is converted to planar
format using the NDI SDK utility function. The resulting frame always stores
planar data with channel_stride_in_bytes = num_samples * 4.
Trait Implementations§
Source§impl Clone for AudioFrameBuilder
impl Clone for AudioFrameBuilder
Source§fn clone(&self) -> AudioFrameBuilder
fn clone(&self) -> AudioFrameBuilder
Returns a duplicate of the value. Read more
1.0.0 · 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 AudioFrameBuilder
impl Debug for AudioFrameBuilder
Auto Trait Implementations§
impl Freeze for AudioFrameBuilder
impl RefUnwindSafe for AudioFrameBuilder
impl Send for AudioFrameBuilder
impl Sync for AudioFrameBuilder
impl Unpin for AudioFrameBuilder
impl UnsafeUnpin for AudioFrameBuilder
impl UnwindSafe for AudioFrameBuilder
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