Git Product home page Git Product logo

ausnd's Introduction

Ausnd

Cross-platform tests

Rust library to read and write Sun/Next AU audio format. Features:

  • read AU files
  • write AU files
  • reading infinite AU streams
  • no heap memory allocations
  • no unsafe code
  • no panicking
  • supports uncompressed integer and floating point samples
  • supports compression types: μ-law and A-law
  • supports audio streams larger than 4 gigabytes

Out of scope:

  • conversion between different sample formats (e.g., i16 to f32). There's so many ways to do the conversion that it's better that this crate doesn't do it.

Usage

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.

Examples

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

Testing

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.

References

License

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.

ausnd's People

Contributors

karip avatar

Watchers

 avatar

ausnd's Issues

Change AuReader to read from Read without Seek

Currently, creating AuReader with AuReader::new() requires the inner reader to implement std::io::Read and std::io::Seek.AuReader needs to be changed to support inner readers implementing std::io::Read only. However, it should also keep the current functionality for inner readers implementing std::io::Seek.

Therefore, this change seems to require some kind of specialization. The AuReader::new() function should behave slightly differently depending on the inner reader:

  • if the inner reader implements std::io::Read only, then initial_stream_len should be set to None.
  • if the inner reader implements std::io::Read and std::io::Seek, then initial_stream_len should be set to Some(stream_length).

Rust doesn't seem to support specialization at the moment, so it isn't possible to have two different behaviors for new().

There's private AuReader::new_read() as an example how the new() function would look like for inner readers implementing only std::io::Read, but it can't be used, because calling it for inner readers implementing std::io::Seek would give wrong results (initial_stream_len would be set to None instead of Some(..)).

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.