Git Product home page Git Product logo

wav_io's Introduction

wav_io

This is a crate for reading and writing wav file.

Suported format:

  • PCM 8, 16, 24, 32 bits Int
  • PCM 32, 64 bits Float

Functions

Install

Add wav_io to your project:

cargo add wav_io

Samples

use std::f32::consts::PI;
fn main() {
    // make sine wave
    let head = wav_io::new_mono_header();
    let mut samples: Vec<f32> = vec![];
    for t in 0..head.sample_rate {
        let v = ((t as f32 / head.sample_rate as f32) * 440.0 * 2.0 * PI).sin() * 0.6;
        samples.push(v);
    }
    // write to file
    let mut file_out = std::fs::File::create("./sine.wav").unwrap();
    wav_io::write_to_file(&mut file_out, &head, &samples).unwrap();
}

Example

Link

wav_io's People

Contributors

jaschutte avatar kujirahand avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

jaschutte

wav_io's Issues

Support streaming / infinite length wav files

Good wav handling libraries should handle reading files from std::io::Read (without std::io::Seek) and writing them to std::io::Write (also without std::io::Seek), not just from seekable files.

Instead of real chunk lengths, 0xFFFF_FFFF are used on such files.

Obviously, samples cannot be stored in a single continuous Vec, callback- or iterator-like interface needs to be used.

Unable to handle LIST chunk

Introduction

WAV uses the RIFF format as part of it's header structure. Part of the RIFF format allows for the inclusion of a LIST chunk.

Problem

As if now, if one were to read a WAV file which contains an LIST chunk (which is quite common for encoders to do), it would not work with this crate.

Suggestion

I would like to see support for LIST chunks, as in, still be able to read files which contain LIST chunks. I do not expect us to be able to read the LIST chunk itself. Merely being able to read the file like normal would be sufficient, since as of now, it fails to read sample data is a LIST chunk is included.

I am willing to add support for this myself at a later date.

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.