Crates.io | ausnd |
lib.rs | ausnd |
version | 0.5.1 |
source | src |
created_at | 2024-04-16 10:10:59.525012 |
updated_at | 2024-04-26 06:15:09.642082 |
description | Reader and writer for the AU audio format |
homepage | |
repository | https://github.com/karip/ausnd |
max_upload_size | |
id | 1210105 |
size | 175,177 |
Rust library to read and write Sun/Next AU audio format. Features:
Out of scope:
Reading an AU audio file:
let mut bufrd = std::io::BufReader::new(std::fs::File::open("test.au").expect("File error"));
let mut reader = ausnd::AuReader::new(&mut bufrd).expect("Read error");
let info = reader.read_info().expect("Invalid header");
for sample in reader.samples().expect("Can't read samples") {
println!("Got sample {:?}", sample.expect("Sample error"));
}
Writing an AU audio file (with the default 2 channels, 16-bit signed integer samples, sample rate 44100):
let mut bufwr = std::io::BufWriter::new(std::fs::File::create("test.au").expect("File error"));
let winfo = ausnd::AuWriteInfo::default();
let mut writer = ausnd::AuWriter::new(&mut bufwr, &winfo).expect("Write header error");
writer.write_samples_i16(&[ 1, 2, 3, 4 ]).expect("Write sample error");
writer.finalize().expect("Finalize error");
See the ausnd API documentation for details.
A simple AU player using ausnd::AuReader
and tinyaudio:
cd examples/ausnd-tinyaudio
cargo run filename.au
A simple audio processor for volume and noise effects using AuStreamParser
and AuWriter
:
cargo run --example ausnd-piper v0.8 n0.1 < input.au > out.au
The same audio processor piped from/to ffmpeg. ffmpeg converts mp3 to AU for ausnd-piper, which writes AU for ffmpeg to convert it to mp3.
ffmpeg -i music.mp3 -f au - | cargo run --example ausnd-piper v1.5 n0.2 | ffmpeg -i - -y out.mp3
Toisto AU Test Suite is a submodule and needs to be fetched before running the integration tests.
cd ausnd
git submodule update --init
./tools/test.sh
The test should end with --- All tests OK.
.
Performance testing:
cargo bench
There is a GitHub Action called "Cross-platform tests" (cross-test.yml), which automatically
runs ./tools/test.sh
for little-endian 64-bit x64_86 and big-endian 32-bit PowerPC.
Licensed under either of Apache License, Version 2.0 or MIT license at your option.
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 as above, without any additional terms or conditions.