#mp3 #decoding #no-alloc #fixed-point #bindings #interface #target

no-std threepm

Rust bindings and high-level interface abstraction for ThreePM - a fixed-point MP3 decoding library written in C

5 releases

0.2.0 Sep 24, 2023
0.1.3 Sep 24, 2023
0.1.2 Sep 23, 2023
0.1.1 Sep 23, 2023
0.1.0 Sep 23, 2023

#593 in Embedded development

Download history 4/week @ 2024-02-26 9/week @ 2024-03-11 3/week @ 2024-04-01 145/week @ 2024-04-08

148 downloads per month

MIT AND RPSL-1.0

305KB
5.5K SLoC

C 3K SLoC // 0.4% comments Rust 2.5K SLoC // 0.0% comments Shell 3 SLoC

ThreePM-rs

Rust bindings for ThreePM - a fixed-point MP3 decoding library written in C.

It supports decoding all MP3 CBR files. VBR is not currently supported.

Usage

Add threepm to your Cargo.toml

cargo add threepm

If you are running on a target where access to flash is slow (eg RP2040), you can try enabling the code-in-ram feature for more performance.

cargo add threepm --features threepm/code-in-ram

This uses linker tricks to put some performance critical code in RAM - note this does not work on all targets, and GCC will issue a few warnings during linking about symbols it doesn't think should live in RAM.

Build

This crate will compile ThreePM as part of the build process - this means you need to tell Rust about your C compiler! With a cortex-m target, it is sufficient to have an arm-none-eabi- toolchain on your path as this is the target default. With a riscv target, you also need to have an environment variable exposing the C compiler name. For https://github.com/riscv-collab/riscv-gnu-toolchain/releases or https://www.embecosm.com/resources/tool-chain-downloads/

CC=riscv32-unknown-elf-gcc cargo run --release

or for the xPack riscv gcc toolchain https://xpack.github.io/dev-tools/riscv-none-elf-gcc/releases/

CC=riscv-none-elf-gcc cargo run --release

Develop

If you update or add to the interface of ThreePM you will need to update the Rust bindings. To do so, install bindgen-cli and run ./ffi/bindgen.sh from the root of this project.

Test

For testing this library, I recommend the test samples available at
https://espressif-docs.readthedocs-hosted.com/projects/esp-adf/en/latest/design-guide/audio-samples.html
The examples in the examples path of project are already configured to run against a short 2 channel example from the espressif audio samples page. You can grab this sample by running the following command from the root of this project if you have wget installed:

wget https://dl.espressif.com/dl/audio/gs-16b-2c-44100hz.mp3

License

ThreePM is RPSL-1.0 licensed
ThreePM-rs is MIT licensed

Dependencies

~215KB