GithubHelp home page GithubHelp logo

silentbyte / wavedown Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 18 KB

Transforms a stream of raw PCM 16bit LE data into a fixed-width waveform representation.

License: MIT License

Rust 100.00%
waveform waveform-data ffmpeg rust

wavedown's Introduction

Wavedown

Build Status MIT License

A utility that transforms a stream of raw PCM 16bit LE data into a fixed-length waveform representation, written in Rust.

alt text

The tool wavedown determines the high-and-low peaks of the input audio stream (PCM 16bit LE) and produces a specified number of samples. The resulting data can then be stored or consumed by other applications.

Building with Cargo

The easiest way to build wavedown from source is using Cargo:

$ cargo build --release

Usage

The command line structure to run wavedown is as follows (run wavedown --help):

USAGE:
    wavedown [OPTIONS] --samples <SAMPLES> [ARGS]

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
    -p, --precision <PRECISION>    Sets the floating point precision [default: 7]
    -s, --samples <SAMPLES>        Sets the number of samples to output
    -t, --type <TYPE>              Sets the type of the output values [default: short]  [values: byte, short, float]

ARGS:
    <INPUT>     Sets the input file [default: -]
    <OUTPUT>    Sets the output file [default: -]

The only required flag is --samples, specifying the number of samples to be extracted from the audio stream. The flag --type sets the output type and supports byte (signed 8bit), short (signed 16bit, default), and float. In case of float, the resulting values are normalized to the range (-1; +1). The precision can be controlled using the --precision flag.

By default, wavedown reads from standard input and writes to standard output. Alternatively, the first and second argument represent the input and output files, respectively. A dash ("-") tells wavedown to use the standard IO streams.

The output lists two numbers per sample (min, max) in the specified format, one line per sample:

-0.0108 0.0139
-0.0956 0.1149
-0.1810 0.1735
[...]

Examples

The following command reads PCM data from the file in.dat and produces 1000 samples which are stored in the file out.txt in floating point format with a precision of 4 digits after the decimal point:

$ waveform in.dat out.txt --samples 1000 --type float --precision 4

wavedown can be paired with ffmpeg easily, making it straightforward to obtain waveform data from audio files. Running the following command will transform the file song.mp3 into a series of 1000 samples, following the format from the previous example:

$ ffmpeg -hide_banner -loglevel panic -i song.mp3 -ac 1 -map 0:a -c:a pcm_s16le -f data - | waveform - out.txt --samples 1000

License

See LICENSE.txt.

wavedown's People

Contributors

silentbyte avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.