Coder Social home page Coder Social logo

rmp3's Introduction

Build Status (Travis-CI) Crates.io Documentation

rmp3

Idiomatic no_std bindings to minimp3 which don't allocate.

Usage

# Cargo.toml
[dependencies]
rmp3 = "0.2"

A simple forward streaming iterator is provided for decoding samples.

use rmp3::{Decoder, Frame};

// It returns a reference to the internal fixed buffer along with the frame info:
let mut decoder = Decoder::new(&your_data_here);
while let Some(Frame { channels, sample_rate, samples, .. }) = decoder.next_frame() {
    // * process frame data here *
}

// Sometimes you just want to iterate the frames without decoding them, as it's much faster.
// Example to calculate song length - 800µs vs. 350ms when decoding a 4:52 track (on a low-end CPU)
let mut decoder = Decoder::new(&your_data_here);
let mut length = 0.0f32; // length in seconds
while let Some(Frame { sample_rate, sample_count, .. }) = decoder.peek_frame() {
    // Not all frames necessarily contain samples (next_frame would skip over these).
    if sample_count != 0 {
        length += sample_count as f32 / sample_rate as f32;
    }
    decoder.skip_frame();
}

Features

  • float - Output 32-bit float PCM instead of signed 16-bit integers
  • no-simd - Disable all manual SIMD optimizations
  • only-mp3 (default) - Strip MP1/MP2 decoding logic

rmp3's People

Contributors

dyedgreen avatar viriw avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.