pub struct AudioClip {
pub sample_rate: u32,
pub channels: u16,
pub samples: Vec<f32>,
}Expand description
Owned interleaved f32 clip for whole-buffer editing.
Fields§
§sample_rate: u32Sample rate in hertz.
channels: u16Number of interleaved channels.
samples: Vec<f32>Interleaved f32 samples.
Implementations§
Source§impl AudioClip
impl AudioClip
Sourcepub fn new(sample_rate: u32, channels: u16, samples: Vec<f32>) -> Result<Self>
pub fn new(sample_rate: u32, channels: u16, samples: Vec<f32>) -> Result<Self>
Creates a validated clip.
Sourcepub fn from_frames(frames: &[OwnedAudioFrame]) -> Result<Self>
pub fn from_frames(frames: &[OwnedAudioFrame]) -> Result<Self>
Builds a single clip from ordered frames.
Sourcepub fn to_frame(&self, timestamp: Timestamp) -> Result<OwnedAudioFrame>
pub fn to_frame(&self, timestamp: Timestamp) -> Result<OwnedAudioFrame>
Converts the clip to one owned frame at the supplied timestamp.
Sourcepub fn samples_per_channel(&self) -> usize
pub fn samples_per_channel(&self) -> usize
Returns the number of samples per channel.
Sourcepub fn duration_seconds(&self) -> f64
pub fn duration_seconds(&self) -> f64
Returns clip duration in seconds.
Sourcepub fn slice_samples(&self, start_sample: u64, end_sample: u64) -> Result<Self>
pub fn slice_samples(&self, start_sample: u64, end_sample: u64) -> Result<Self>
Slices by per-channel sample indices.
Sourcepub fn slice_seconds(
&self,
start_seconds: f64,
end_seconds: f64,
) -> Result<Self>
pub fn slice_seconds( &self, start_seconds: f64, end_seconds: f64, ) -> Result<Self>
Slices by seconds.
Sourcepub fn split_at_seconds(&self, boundaries: &[f64]) -> Result<Vec<Self>>
pub fn split_at_seconds(&self, boundaries: &[f64]) -> Result<Vec<Self>>
Splits a clip at ordered boundary times.
Sourcepub fn concat(clips: &[Self], policy: ConcatPolicy) -> Result<Self>
pub fn concat(clips: &[Self], policy: ConcatPolicy) -> Result<Self>
Concatenates clips.
Trait Implementations§
impl StructuralPartialEq for AudioClip
Auto Trait Implementations§
impl Freeze for AudioClip
impl RefUnwindSafe for AudioClip
impl Send for AudioClip
impl Sync for AudioClip
impl Unpin for AudioClip
impl UnsafeUnpin for AudioClip
impl UnwindSafe for AudioClip
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