[−][src]Crate claxon
Claxon, a FLAC decoding library.
Examples
The following example computes the root mean square (RMS) of a FLAC file.
let mut reader = claxon::FlacReader::open("testsamples/pop.flac").unwrap(); let mut sqr_sum = 0.0; let mut count = 0; for sample in reader.samples() { let s = sample.unwrap() as f64; sqr_sum += s * s; count += 1; } println!("RMS is {}", (sqr_sum / count as f64).sqrt());
A simple way to decode a file to wav with Claxon and Hound:
let mut reader = claxon::FlacReader::open(fname).expect("failed to open FLAC stream"); let spec = hound::WavSpec { channels: reader.streaminfo().channels as u16, sample_rate: reader.streaminfo().sample_rate, bits_per_sample: reader.streaminfo().bits_per_sample as u16, sample_format: hound::SampleFormat::Int, }; let fname_wav = fname.with_extension("wav"); let opt_wav_writer = hound::WavWriter::create(fname_wav, spec); let mut wav_writer = opt_wav_writer.expect("failed to create wav file"); for opt_sample in reader.samples() { let sample = opt_sample.expect("failed to decode FLAC stream"); wav_writer.write_sample(sample).expect("failed to write wav file"); }
Retrieving the artist metadata:
let reader = claxon::FlacReader::open("testsamples/pop.flac").unwrap(); for artist in reader.get_tag("ARTIST") { println!("{}", artist); }
For more examples, see the examples directory in the crate.
Re-exports
pub use frame::Block; |
Modules
frame | The |
input | Exposes traits that help reading data at the bit level with low overhead. |
metadata | The |
subframe | The |
Structs
FlacReader | A FLAC decoder that can decode the stream from the underlying reader. |
FlacReaderOptions | Controls what metadata |
FlacSamples | An iterator that yields samples read from a |
Enums
Error | An error that prevents successful decoding of the FLAC stream. |
Type Definitions
Result | A type for results generated by Claxon where the error type is hard-wired. |