Git Product home page Git Product logo

wave_stream's Introduction

wave_stream

A streaming wav reader and writer for Rust. Wave_stream supports the following:

  • Reading, both in random access and streaming modes
  • Writing in random access mode.

Wave_stream supports any sample rate. It supports 8-bit, 16-bit, 24-bit, and floating-point wave files.

Wave_stream does not load the entire wav file into RAM. This allows working with extremely large files with low RAM overhead.

For a full example, and instructions, see: https://github.com/GWBasic/wave_stream_example/blob/main/src/main.rs

License

Licensed under either of

at your option.

Contribution

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.

Note: Pull requests require that "cargo fmt" is run. If you are using Visual Studio Code, enable "Format on Save": https://stackoverflow.com/a/67861602/1711103

wave_stream's People

Contributors

gwbasic avatar

Stargazers

 avatar Ponj avatar Max Justus Spransy avatar

Watchers

 avatar

wave_stream's Issues

Expose the maximum length of a file in the header

In #30, protections were added to prevent writing a wave file longer than the RIFF 4GB limit.

One confusing area when consuming this is that the maximum length of a wave file, in samples, should be known before opening the file. This allows the consuming program to reason about the file.

Use usize everywhere

In Rust, indexing of arrays and general sizes are typically represented by a usize.

wave_stream currently uses a u32, because the wave header uses u32.

Initially, I believed it was best to keep with the type limitations imposed by the wave format. Instead, I believe it's simpler to keep with Rust semantics for indicating size and location; and have a runtime exception if the wave file is longer than u32::MAX;

Support upconverting on read and write

It should be possible to read an 8-bit wav as if it's a float; upconverting to float through the process.

(Likewise, 16-bit should automatically upconvert to 24-bit and float.)

Downconverting, (float -> 8-bit) on read or write will not be supported.

Documentation

Idiomatic Rust documentation is needed prior to publishing the library

Support files greater than 4GB

Currently, files that are long are truncated. (See GWBasic/soft_matrix#77 )

I've determined this is because RIFF + WAV has limitations imposed by 32-bit lengths specified in the file.

Specifically, https://docs.fileformat.com/audio/wav/ states that bytes 5-8 are the length of the file, in bytes. A 32-bit 6-channel wav that's 2 hours will be 8GB. This overflows RIFF's file length field.

In this bug: Figure out how to construct wav files that are longer than 32-bit RIFF file limits. https://www.loc.gov/preservation/digital/formats/fdd/fdd000001.shtml#notes might explain how to do this.

Note: Wave files > 4GB in length will not be supported. The reason is that there are two competing proposals to alter the wave file format, and support for these file formats in other applications is very limited. A much better approach for files > 4GB is to use an alternate file format, like AIFF.

I currently do not intend on supporting other audio file formats in wave_stream. At some point it may make sense to write a sister library called "aiff_stream," and possibly a library that allows reading and writing both.

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.