MCPcopy Index your code
hub / github.com/RustAudio/lewton

github.com/RustAudio/lewton @0.10.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release 0.10.2 ↗ · + Follow
205 symbols 383 edges 17 files 60 documented · 29%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

lewton

docs crates.io dependency status

Vorbis decoder written in pure Rust.

To give the decoder a try, you can do:

cargo run --example player /path/to/your/audio_file.ogg

It will then play back the audio.

If you want to know how to use this crate, look at the examples folder.

This crate has a low level API for per-packet decoding in the audio and header modules, and a high level API for ogg/vorbis streams in the inside_ogg module.

Some parts were created with help from the public domain stb_vorbis decoder implementation.

The minimum required Rust version is 1.36.

Use of unsafe

The entire library uses not a single line of unsafe code. In fact, lib.rs contains the #![forbid(unsafe_code)] directive.

About the history of this crate

I've started started to work on this crate in December 2015. The goal was to learn more about Rust and audio processing, while also delivering something useful to the Rust ecosystem.

I've tried not to look into the libvorbis implementation, as then I'd have to first abide the BSD license, and second as I didn't want this crate to become "just" a translation from C to Rust. Instead I wanted this crate to base on the spec only, so that I'd learn more about how vorbis worked.

The only time I did look into the libvorbis implementation was to look up the implementation of a function needed by the ogg crate (the CRC function), which is why that crate is BSD licensed, and attributes the authors. This crate however contains no code, translated or otherwise, from the libvorbis implementation.

After some time I realized that without any help of a working implementation progress would become too slow.

Therefore, I've continued to work with the public domain stb_vorbis implementation and used some of its code (most prominently for the imdct algorithm) to translate it to rust. I've also used it for debugging by comparing its outputs with mine.

Most of this crate however was created by reading the spec only.

Use from C

lewton provides a C-compatible set of library, header and pkg-config file.

To build and install it you can use cargo-c:

cargo install cargo-c
cargo cinstall --release --destdir /tmp/lewton
sudo cp -a /tmp/lewton/* /

License

Licensed under Apache 2 or MIT (at your option). For details, see the LICENSE file.

All examples inside the examples/ folder are licensed under the CC-0 license.

License of your contributions

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed / CC-0 licensed as above, without any additional terms or conditions.

Extension points exported contracts — how you extend this code

Samples (Interface)
Trait for a packet of multiple samples [2 implementers]
src/samples.rs
Sample (Interface)
Trait representing a single sample [2 implementers]
src/samples.rs

Core symbols most depended-on inside this repo

iter
called by 28
src/huffman_tree.rs
iter_test
called by 20
src/huffman_tree.rs
read_bit_flag
called by 17
src/bitpacking.rs
stream_serial
called by 8
src/inside_ogg.rs
ilog
called by 7
src/lib.rs
truncate
called by 6
src/samples.rs
read_header_ident
called by 5
src/header.rs
imdct_step3_inner_r_loop
called by 5
src/imdct.rs

Shape

Function 125
Method 45
Class 23
Enum 10
Interface 2

Languages

Rust100%

Modules by API surface

src/audio.rs37 symbols
src/header.rs35 symbols
src/huffman_tree.rs20 symbols
src/bitpacking.rs20 symbols
src/inside_ogg.rs16 symbols
dev/cmp/src/lib.rs12 symbols
src/capi.rs11 symbols
src/header_cached.rs10 symbols
src/lib.rs9 symbols
src/imdct.rs9 symbols
src/samples.rs7 symbols
dev/cmp/tests/vals.rs7 symbols

For agents

$ claude mcp add lewton \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact