simplemad is a simple interface for libmad, the MPEG audio decoding library.
Use and examples
simplemad::decode takes a byte-oriented source and returns a channel that
yields Result<Frame, MadError>. If you only need to decode part of a file,
you can also use simplemad::decode_interval.
Frame and MadError correspond to libmad's struct types mad_pcm and
mad_error, respectively. Samples are signed 32 bit integers and are organized
into channels. For stereo, the left channel is channel 0.
MP3 files often begin with metadata, which will cause libmad to produce errors. It is safe to ignore these errors until libmad reaches audio data and starts producing frames.
use decode;
use File;
use Path;
let path = new;
let file = open.unwrap;
let mut decoder = decode;
for item in decoder.iter
To decode from 30 seconds to 60 seconds, use decode_interval and provide the start and end time in milliseconds.
let mut partial_decoder = decode_interval;
Installation
First, install libmad. Links to the source can be found below. It might be necessary to apply the patch found in this guide. Then add simplemad = "0.3.0" to the list of dependencies in your Cargo.toml.
Documentation
http://bendykst.github.io/doc/simplemad/index.html
Dependencies
-
libmad (FTP: ftp://ftp.mars.org/pub/mpeg/ or SourceForge)
-
libc
License
MIT