Crates.io | aifc |
lib.rs | aifc |
version | 0.5.3 |
source | src |
created_at | 2024-07-30 11:28:22.415087 |
updated_at | 2024-07-30 11:28:22.415087 |
description | Reader and writer for the AIFF and AIFF-C audio format |
homepage | |
repository | https://github.com/karip/aifc |
max_upload_size | |
id | 1319691 |
size | 271,478 |
Rust library to read and write AIFF and AIFF-C (AIFC) audio format.
Features:
Out of scope:
Reading AIFF/AIFF-C file:
let mut stream = std::io::BufReader::new(std::fs::File::open("test.aiff").expect("Open failed"));
let mut reader = aifc::AifcReader::new(&mut stream).expect("Can't create reader");
let info = reader.read_info().expect("Can't read header");
for sample in reader.samples().expect("Can't iterate samples") {
println!("Got sample {:?}", sample.expect("Sample read error"));
}
Writing AIFF-C file with the default 2 channels, 16 bits/sample and sample rate 44100:
let mut stream = std::io::BufWriter::new(std::fs::File::create("test.aiff").expect("Open failed"));
let info = aifc::AifcWriteInfo::default();
let mut writer = aifc::AifcWriter::new(&mut stream, &info).expect("Can't create writer");
writer.write_samples_i16(&[ 1, 2, 3, 4 ]).expect("Can't write samples");
writer.finalize().expect("Can't finalize");
See the AIFC API documentation for details.
A simple AIFF player using aifc::AifcReader
and tinyaudio:
cd examples/aifc-tinyaudio
cargo run filename.aiff
Toisto AIFF Test Suite is a submodule and needs to be fetched before running the tests.
cd aifc
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.