pub struct AudioFile {
pub audio_format: AudioFormat,
pub bits_per_sample: u32,
pub duration: f64,
pub num_channels: usize,
pub num_frames: usize,
pub sample_rate: u32,
pub samples: Vec<Vec<f64>>,
}Expand description
Represents an audio file. Samples are always stored in f64 format, regardless of their original format on disk.
Fields§
§audio_format: AudioFormat§bits_per_sample: u32§duration: f64§num_channels: usize§num_frames: usize§sample_rate: u32§samples: Vec<Vec<f64>>Implementations§
source§impl AudioFile
impl AudioFile
sourcepub fn copy_header(&self) -> AudioFile
pub fn copy_header(&self) -> AudioFile
Copies the header of an AudioFile and initializes the struct with an empty sample vector. Warning - the empty sample vector has no channels and no frames.
§Example:
let audio = aus::read("myfile.wav").unwrap();
let blank_file = audio.copy_header();sourcepub fn new(
audio_format: AudioFormat,
sample_rate: u32,
samples: Vec<Vec<f64>>,
) -> AudioFile
pub fn new( audio_format: AudioFormat, sample_rate: u32, samples: Vec<Vec<f64>>, ) -> AudioFile
Creates a new AudioFile from provided audio format, sample rate, and 2D sample vector.
§Example
use aus::{AudioFile, AudioFormat};
use aus::synthesis::sine;
let waveform = sine(440.0, 0.0, 44100 * 2, 44100);
let mut channels: Vec<Vec<f64>> = Vec::with_capacity(2);
channels.push(waveform.clone());
channels.push(waveform.clone());
let file = AudioFile::new(AudioFormat::S24, 44100, channels);
aus::write("file_name.wav", &file);sourcepub fn new_mono(
audio_format: AudioFormat,
sample_rate: u32,
samples: Vec<f64>,
) -> AudioFile
pub fn new_mono( audio_format: AudioFormat, sample_rate: u32, samples: Vec<f64>, ) -> AudioFile
Creates a new mono AudioFile from provided audio format, sample rate, and 1D sample vector.
§Example
use aus::{AudioFile, AudioFormat};
use aus::synthesis::sine;
let waveform = sine(440.0, 0.0, 44100 * 2, 44100);
let file = AudioFile::new_mono(AudioFormat::S24, 44100, waveform);
aus::write("file_name.wav", &file);Auto Trait Implementations§
impl Freeze for AudioFile
impl RefUnwindSafe for AudioFile
impl Send for AudioFile
impl Sync for AudioFile
impl Unpin for AudioFile
impl UnwindSafe for AudioFile
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
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moresource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moresource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.