Trait babycat::Waveform[][src]

pub trait Waveform<T> {
    fn new(
        frame_rate_hz: u32,
        num_channels: u32,
        interleaved_samples: Vec<T>
    ) -> Self;
fn frame_rate_hz(&self) -> u32;
fn num_channels(&self) -> u32;
fn num_frames(&self) -> u64;
fn interleaved_samples(&self) -> &[T]; }
Expand description

Methods common to all types of waveforms.

Required methods

fn new(
    frame_rate_hz: u32,
    num_channels: u32,
    interleaved_samples: Vec<T>
) -> Self
[src]

fn frame_rate_hz(&self) -> u32[src]

Expand description

The frame rate (or sample rate) of the audio in memory.

This returns how many audio frames represent one second of audio.

fn num_channels(&self) -> u32[src]

Expand description

The number of audio channels.

fn num_frames(&self) -> u64[src]

Expand description

The number of frames in the audio.

Babycat defines a frame as a collection of time-coincidant samples–one sample for every channel. Therefore, the total number of samples is num_frames * num_channels.

fn interleaved_samples(&self) -> &[T][src]

Expand description

Return the waveform as a slice of interleaved samples.

Loading content...

Implementors

impl Waveform<f32> for FloatWaveform[src]

fn new(
    frame_rate_hz: u32,
    num_channels: u32,
    interleaved_samples: Vec<f32>
) -> Self
[src]

Constructs a FloatWaveform from an already-decoded vector of 32-bit float samples.

Examples

This creates a FloatWaveform containing one second of silent stereo audio. Note that the input vector contains 88,200 audio samples–which we divide into 44,100 frames containing two samples each.

use babycat::{FloatWaveform, Waveform};

let frame_rate_hz = 44100;
let num_channels = 2;
let raw_uncompressed_audio: Vec<f32> = vec![0.0_f32; 88200];
let waveform = FloatWaveform::new(frame_rate_hz, num_channels, raw_uncompressed_audio);
assert_eq!(
    format!("{:?}", waveform),
    "FloatWaveform { frame_rate_hz: 44100, num_channels: 2, num_frames: 44100}"
);

fn interleaved_samples(&self) -> &[f32][src]

Returns of channel-interleaved samples.

fn frame_rate_hz(&self) -> u32[src]

fn num_channels(&self) -> u32[src]

fn num_frames(&self) -> u64[src]

impl Waveform<i16> for IntWaveform[src]

fn new(
    frame_rate_hz: u32,
    num_channels: u32,
    interleaved_samples: Vec<i16>
) -> Self
[src]

fn frame_rate_hz(&self) -> u32[src]

fn num_channels(&self) -> u32[src]

fn num_frames(&self) -> u64[src]

fn interleaved_samples(&self) -> &[i16][src]

Loading content...