Skip to main content

AUDIO_BLOCK

Constant AUDIO_BLOCK 

Source
pub const AUDIO_BLOCK: &str = "type AudioBlock { samples: Tensor[f32]; sample_rate: u32; }";
Expand description

Decoded audio samples with a checked sample rate.

Samples have shape [sample_frames, channels] and finite f32 values. The SDK validates channel count and sample rate. This is a decoded block; playback, capture and scheduling belong to the host.

§Declaration

type AudioBlock { samples: Tensor[f32]; sample_rate: u32; }

§Fields and methods

  • samples: Sample-major f32 data with channels on the trailing axis.

  • sample_rate: Samples per second, from 1 through 384000.

§Construct AudioBlock

Inspect the typed payload and metadata.

let audio = AudioBlock { samples: tensor[f32]([0, 0.5, 0, -0.5], [4, 1])?, sample_rate: 48000 };
print(audio.samples.shape());
print(audio.sample_rate);