12 releases

Uses old Rust 2015

0.4.3 Aug 9, 2020
0.4.2 May 19, 2019
0.4.1 Aug 25, 2018
0.4.0 Dec 2, 2017
0.0.1 Feb 13, 2015

#91 in Audio

Download history 12472/week @ 2024-08-12 13117/week @ 2024-08-19 10386/week @ 2024-08-26 9562/week @ 2024-09-02 8958/week @ 2024-09-09 9012/week @ 2024-09-16 12112/week @ 2024-09-23 11440/week @ 2024-09-30 9348/week @ 2024-10-07 11881/week @ 2024-10-14 10604/week @ 2024-10-21 12087/week @ 2024-10-28 9719/week @ 2024-11-04 9287/week @ 2024-11-11 10008/week @ 2024-11-18 9803/week @ 2024-11-25

39,718 downloads per month
Used in 71 crates (23 directly)

Apache-2.0

160KB
2.5K SLoC

Claxon

A FLAC decoding library in Rust.

Build Status Crates.io version Changelog Documentation

Claxon is a FLAC decoder written in pure Rust. It has been fuzzed and verified against the reference decoder for correctness. Its performance is similar to the reference decoder.

Example

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());

More examples can be found in the examples directory. For a simple example of decoding a FLAC file to wav with Claxon and Hound, see decode_simple.rs. A more efficient way of decoding requires dealing with a few details of the FLAC format. See decode.rs for an example.

Performance

These are the times to decode 5 real-world FLAC files to wav, average and standard deviation of 11 runs, normalized to version 1.3.2 of the reference implementation. Measurements were done on a Skylake i7. Claxon was compiled with Rust 1.26.0.

Decoder Time / reference
Claxon 1.10 ± 0.01
libflac 1.00 ± 0.01

Note that for decent performance, Claxon should be compiled with -C codegen-units=1 on Rust ≥ 1.24.0. Not passing this RUSTFLAG can cause as much as a 45% increase in running time.

Contributing

Contributions in the form of bug reports, feature requests, or pull requests are welcome. See contributing.md.

License

Claxon is licensed under the Apache 2.0 license. It may be used in free software as well as closed-source applications, both for commercial and non-commercial use under the conditions given in the license. If you want to use Claxon in your GPLv2-licensed software, you can add an exception to your copyright notice. Please do not open an issue if you disagree with the choice of license.

No runtime deps