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 timecode(self, tc: i64) -> Self
pub fn timecode(self, tc: i64) -> Self
Set the timecode in 100 ns units (or the SDK synthesis sentinel).
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 timestamp(self, ts: i64) -> Self
pub fn timestamp(self, ts: i64) -> Self
Set the timestamp field in 100 ns units. This field is filled by the SDK on receive.
Sourcepub fn build(self) -> Result<AudioFrame>
pub fn build(self) -> Result<AudioFrame>
Build the audio frame.
Defaults to 48 kHz stereo FLTP, 1024 samples per channel, planar input, synthesized timecode, and silent samples.
When AudioLayout::Interleaved is set, the input data is converted to planar
format in Rust. 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
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more