[−][src]Crate sndfile
A safe rust wrapper of libsndfile.
With this crate, you can read or save audio files.
Getting started
With minimal features:
[dependencies]
sndfile = "0.0"
With ndarray supports:
[dependencies.sndfile]
version = "0.0"
features = ["ndarray_features"]
Example
ⓘThis example is not tested
extern crate sndfile; extern crate ndarray; fn main() { use sndfile::*; let mut snd = sndfile::OpenOptions::ReadOnly(ReadOptions::Auto).from_path( "./sample_song.flac" ).unwrap(); let data: ndarray::Array2<f32> = snd.read_all_to_ndarray().unwrap(); let samplerate = snd.get_samplerate(); let n_frame = snd.len().unwrap(); let n_channels = snd.get_channels(); let title = snd.get_tag(TagType::Title); println!("Loaded song `{}`:", title); println!(" Length: {:.2} seconds", n_frame as f64 / samplerate as f64); println!(" Sample rate: {} Hz", samplerate); println!(" Channel count: {}", n_channels); println!(" DC offset = {}", data.mean().unwrap()); } /* == Expected output == Loaded song `Loow`: Length: 277.06 seconds Sample rate: 44100 Hz Channel count: 2 DC offset = 0.00018921464 */
Structs
MajorInfo | |
SndFile | Main struct of this crate. |
SubtypeInfo | |
UnsafeSndFile | This struct is unstable. |
VIOFile | |
WriteOptions | Options for writing audio files. |
Enums
Endian | |
MajorFormat | |
OpenOptions | Struct to specify options when opening a audio file. |
ReadOptions | Options for reading audio files. |
SndFileError | |
SubtypeFormat | |
TagType | Type of tags |
Traits
SndFileIO | Do I/O operation on slice or iterator. |
Functions
check_format | This function allows the caller to check if a set of parameters before opening a file in write mode. |
default_subtype | Returns default audio encoding format for given audio container format |
get_sf_global_lock | Lock it before interacting with a few raw |
get_supported_major_format_dict | Get all supported audio container format |
get_supported_subtype_format_dict | Get all supported audio encoding format |