libsoxr 0.2.0

Wrapper for libsoxr (resampling library for sounds)
docs.rs failed to build libsoxr-0.2.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: libsoxr-0.2.9

libsoxr-rs

This library is a thin wrapper for libsoxr which is a "High quality, one-dimensional sample-rate conversion library".

This wrapper library is licensed the same as libsoxr itself: LGPLv2.

The documentation can be found here.

Install

add the following to your Cargo.toml:

[dependencies.libsoxr]
git = "https://github.com/lrbalt/libsoxr-rs"

and add the crate:

extern crate libsoxr;
use libsoxr::Soxr;

Example

// upscale factor 2, one channel with all the defaults
let s = Soxr::create(1.0, 2.0, 1, None, None, None).unwrap();

// source data, taken from 1-single-block.c of libsoxr examples.
let source: [f32; 48] = [0.0, 1.0, 0.0, -1.0, 0.0, 1.0, 0.0, -1.0, 0.0, 1.0, 0.0, -1.0, 0.0,
                         1.0, 0.0, -1.0, 0.0, 1.0, 0.0, -1.0, 0.0, 1.0, 0.0, -1.0, 0.0, 1.0,
                         0.0, -1.0, 0.0, 1.0, 0.0, -1.0, 0.0, 1.0, 0.0, -1.0, 0.0, 1.0, 0.0,
                         -1.0, 0.0, 1.0, 0.0, -1.0, 0.0, 1.0, 0.0, -1.0];

// create room for 2*48 = 96 samples
let mut target: [f32; 96] = [0.0; 96];

// two runs. last run with None to inform resampler of end-of-input
let result = s.process(Some(&source), &mut target).and_then(|_| {
    s.process::<f32, f32>(None, &mut target[0..]).and_then(|_| {
        for s in target.iter() {
            print!("{:?}\t", s)
        }
        Ok(())
    })
});