Go package capable of generating waveform images from audio streams. MIT Licensed.
This library supports any audio streams which the azul3d/engine/audio package is able to decode. At the time of writing, this includes:
- WAV
- FLAC
An example binary called waveform
is provided which show's the library's usage.
Please see cmd/waveform/README.md
for details.
Here are several example images generated using waveform
. Enjoy!
Generate a waveform image, and scale it both vertically and horizontally.
$ cat ~/Music/02\ -\ Peace\ Of\ Mind.flac | waveform -x 5 -y 2 > ~/waveform.png
Apply a foreground and background color, to make things more interesting.
cat ~/Music/02\ -\ Peace\ Of\ Mind.flac | waveform -fg=#FF3300 -bg=#0099CC -x 5 -y 2 > ~/waveform_color.png
Apply an alternate foreground color, draw using a stripe pattern.
cat ~/Music/02\ -\ Peace\ Of\ Mind.flac | waveform -fg=#FF3300 -bg=#0099CC -alt=#FF9933 -fn stripe -x 5 -y 2 > ~/waveform_stripe.png
Apply an alternate foreground color, draw using a random fuzz pattern.
cat ~/Music/02\ -\ Peace\ Of\ Mind.flac | waveform -fg=#FF3300 -bg=#0099CC -alt=#FF9933 -fn fuzz -x 5 -y 2 > ~/waveform_fuzz.png
Apply a new set of colors, draw using a gradient pattern.
cat ~/Music/02\ -\ Peace\ Of\ Mind.flac | waveform -fg=#FF0000 -bg=#00FF00 -alt=#0000FF -fn gradient -x 5 -y 2 > ~/waveform_gradient.png
Apply a checkerboard color set, draw using a checkerboard pattern.
cat ~/Music/02\ -\ Peace\ Of\ Mind.flac | waveform -fg=#000000 -bg=#222222 -alt=#FFFFFF -fn checker -x 5 -y 2 > ~/waveform_checker.png
Pre-install:
$ go mod download
$ go get -u
To run tests, just run:
$ go test -v ./...
To build waveform
, just run:
- Build
$ go build
The waveform
binary is now available in the current directory. You may also wish to run it by following:
$ ./waveform
- Install
To install and use waveform
, simply run:
$ go install github.com/fwx5618177/waveform/...
The waveform
binary is now installed in your $GOPATH
. It has several options available
for generating waveform images:
$ waveform -h
Usage of waveform:
-alt="": hex alternate color of output waveform image
-bg="#FFFFFF": hex background color of output waveform image
-fg="#000000": hex foreground color of output waveform image
-fn="solid": function used to color output waveform image [options: fuzz, gradient, solid, stripe]
-resolution=1: number of times audio is read and drawn per second of audio
-sharpness=1: sharpening factor used to add curvature to a scaled image
-x=1: scaling factor for image X-axis
-y=1: scaling factor for image Y-axis
waveform
currently supports both WAV and FLAC audio files. An audio stream must
be passed on stdin
, and the resulting, PNG-encoded image will be written to stdout
.
Any errors which occur will be written to stderr
.