Go package capable of generating waveform images from audio streams. MIT Licensed.

waveform Build Status GoDoc

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.

Examples

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

waveform

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

waveform_color

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

waveform_stripe

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

waveform_fuzz

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

waveform_gradient

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

waveform_checker

Owner
Matt Layher
Software Engineer. Go, Linux, and open source software enthusiast. On and ever upward.
Matt Layher
Comments
  • waveform.go: Refactored if block which calculates scaling factor in New.

    waveform.go: Refactored if block which calculates scaling factor in New.

    Just thought I'd make a slight change. it's idiomatic to have a switch statement in this situation where there are multiple if statements, especially since only one variable is involved. I also made sure tests passed before submitting this pull request.

    Since the resuting code that could be executed on each condition is only one line, I didn't think to place parentheses over the single statements, but let me know if that's what you prefer and I'll make the changes accordingly.

  • Use

    Use "functional options" pattern instead of config structs

    This will provide a much more simple interface, reduce the need to merge in default options, etc etc.

    http://dave.cheney.net/2014/10/17/functional-options-for-friendly-apis

  • Add waveform generation from []float64

    Add waveform generation from []float64

    Since []float64 is computed from reading samples anyway, allow direct generation by inputting []float64. Also add the option to retrieve the values used to compute a new waveform from a io.Reader, so that the same waveform can be quickly regenerated.

  • If possible, implement `io` interfaces

    If possible, implement `io` interfaces

    If possible, allow images to be generated, encoded, and directly streamed using io interfaces. This would enable images to be sent via HTTP as they are generated, etc.

  • Figure out a way to generate fixed-width images

    Figure out a way to generate fixed-width images

    Right now, image width is completely dependent on stream duration. In the future, it would be nice to be able to specify that the output image should be a certain width.

  • Compute method returns unknown format

    Compute method returns unknown format

    Hi, I'm trying to get []float64 from Compute() method of Waveform, but it returns an error of "audio: unknown format", is there anything that I did wrong?

    myAgi := agi.New()
    myAgi.Init(nil)
    
    fd, err := syscall.Open("/dev/fd/3", syscall.O_RDWR, 0755)  // open file descriptor
    if err != nil {
    	myAgi.Verbose(err)
    	return
    }
    
    buf := make([]byte, 1024)
    
    for {
    	n, err := syscall.Read(fd, buf)  // read streaming audio
    	if n > 0 {
    		br := bytes.NewReader(buf[:n])
    
    		wav, err := waveform.New(br)
    		if err != nil {
    			myAgi.Verbose(err)
    		}
    
    		value, err := wav.Compute()
    		if err != nil {
    			myAgi.Verbose(err)  // got an error here
    		}
    
    		// futher proccesing with value
    	}
    
    	if err != nil {
    		myAgi.Verbose(err)
    		return
    	}
    } 
    
  • Reformat Markdown files

    Reformat Markdown files

    General changes:

    • Consistent line breaks after 80 characters
    • Heading levels (# for title and ## for sections)

    LICENSE.md:

    • Replace (C) with copyright symbol

    README.md:

    • Badges aren't part of the title anymore
    • Small fixes (MIT Licensed to MIT licensed and show's to shows)
    • Specify language for code snippets
  • panic: EOF

    panic: EOF

    Hi,

    I'm using the latest commit of waveform: 6b28917edfbacd50bff4d58f951cf80499c952c4 and Go 1.11 on 64-bit Arch Linux.

    After building waveform and copying test.wav to the cmd/waveform directory:

    $ ls -al
    .rw-r----- 1,0k afr 14 sep.  11:36 README.md
    .rw-r-----  47M afr 14 sep.  11:40 test.wav
    .rwxr-x--- 3,0M afr 14 sep.  11:36 waveform*
    .rw-r----- 4,8k afr 14 sep.  11:36 waveform.go
    .rw-r-----    0 afr 14 sep.  11:40 waveform.png
    $ file test.wav
    test.wav: RIFF (little-endian) data, WAVE audio
    

    When attempting to create a .png image, I get an error message:

    $ cat test.wav | ./waveform -x 5 -y 2 > waveform.png
    panic: EOF
    
    goroutine 1 [running]:
    main.main()
            /home/afr/clones/waveform/cmd/waveform/waveform.go:127 +0xc9b
    

    I tried with several different .wav files.

    Line 127 in waveform.go is here.

  • something wrong with vertical scaling

    something wrong with vertical scaling

    this;

    ./waveform.a -resolution 1000 < wavTones.com.unregistred.sin_10Hz_-12dBFS_1s.wav > temp.png

    (wav file from here; http://www.wavtones.com/functiongenerator.php github wont let me add wav files, but these both produce correct waveforms in audacity.)

    produces this;

    temp

    which is too big, -12db is 1/4 full scale.

    and this, which is just full scale;

    ./waveform.a -resolution 1000 < wavTones.com.unregistred.sin_10Hz_0dBFS_1s.wav > temp.png

    produces this? (completely white png)

    temp

  • unlimited memory usage

    unlimited memory usage

    when i generate with this;

    img, err := waveform.Generate(out,waveform.Resolution(8000),bColor,fColor)

    with a wave file with 8k samples per second, its fine, using 6MB memory in 0.01sec, but

    img, err := waveform.Generate(out,waveform.Resolution(10000),bColor,fColor)

    (ie when resolution slightly higher than the sample rate, )

    i had to kill the process at 6GB mem usage.

Local-audio - Web walking audio tour platform proof-of-concept

Goal: Proof of concept for a Web Audio walk platform Data retention dynamdo db "time to live" expires in 1 day from creation of record set in add.go s

Jan 9, 2022
GAAD (Go Advanced Audio Decoder)

GAAD (Go Advanced Audio Decoder) Package currently provides AAC parsing capabilities. This package performs a full parse of AAC-LC and HE-AACv1 bitstr

Oct 24, 2022
Go tools for audio processing & creation ?

GoAudio ? GoAudio is an audio processing library, currently supporting WAVE files, although some tools such as the synth and breakpoints are encoding

Dec 23, 2022
Mini audio library

malgo Go bindings for miniaudio library. Requires cgo but does not require linking to anything on the Windows/macOS and it links only -ldl on Linux/BS

Dec 31, 2022
Sequence-based Go-native audio mixer for music apps

Mix https://github.com/go-mix/mix Sequence-based Go-native audio mixer for music apps See demo/demo.go: package main import ( "fmt" "os" "time"

Dec 1, 2022
Go bindings for the PortAudio audio I/O library

portaudio This package provides an interface to the PortAudio audio I/O library. See the package documentation for details. To build this package you

Jan 1, 2023
CLI audio player written in go.
CLI audio player written in go.

A very minimal CLI audio player.

Dec 13, 2022
alto is a program built for audio management.
alto is a program built for audio management.

alto, a music organizer alto is a program built for audio management. It's purpose is to provide the user the means to create a path construct to move

Oct 10, 2022
Terrible Audio Downloader

Terrible Audio Downloader This is just a small go project I did for myself, to manage my audio library to get away from spotify. All it does is downlo

Oct 30, 2021
Audio visualizer in Go
Audio visualizer in Go

demo_audio_visualizer Simple audio visualizer in Go Used libraries: raylib-go go-mp3 oto go-dsp To disable the additional console window on Windows OS

Dec 4, 2022
Package arp implements the ARP protocol, as described in RFC 826. MIT Licensed.

arp Package arp implements the ARP protocol, as described in RFC 826. MIT Licensed. Portions of this code are taken from the Go standard library. The

Dec 20, 2022
Package dhcp6 implements a DHCPv6 server, as described in RFC 3315. MIT Licensed.

dhcp6 Package dhcp6 implements a DHCPv6 server, as described in IETF RFC 3315. MIT Licensed. At this time, the API is not stable, and may change over

Sep 27, 2022
Package ethernet implements marshaling and unmarshaling of IEEE 802.3 Ethernet II frames and IEEE 802.1Q VLAN tags. MIT Licensed.

ethernet Package ethernet implements marshaling and unmarshaling of IEEE 802.3 Ethernet II frames and IEEE 802.1Q VLAN tags. MIT Licensed. For more in

Dec 29, 2022
Package raw enables reading and writing data at the device driver level for a network interface. MIT Licensed.

raw Package raw enables reading and writing data at the device driver level for a network interface. MIT Licensed. For more information about using ra

Dec 28, 2022
Package socket provides a low-level network connection type which integrates with Go's runtime network poller to provide asynchronous I/O and deadline support. MIT Licensed.

socket Package socket provides a low-level network connection type which integrates with Go's runtime network poller to provide asynchronous I/O and d

Dec 14, 2022
pure go, cross-platform, MIT-licensed ui toolkit for developers
pure go, cross-platform, MIT-licensed ui toolkit for developers

duit - developer ui toolkit WARNING: this library is work in progress. backwards incompatible changes will be made. details duit is a pure go (*), cro

Dec 24, 2022
Package flac provides access to FLAC (Free Lossless Audio Codec) streams.

flac This package provides access to FLAC (Free Lossless Audio Codec) streams. Documentation Documentation provided by GoDoc. flac: provides access to

Jan 5, 2023
ready-to-use RTSP / RTMP server and proxy that allows to read, publish and proxy video and audio streams
ready-to-use RTSP / RTMP server and proxy that allows to read, publish and proxy video and audio streams

rtsp-simple-server is a simple, ready-to-use and zero-dependency RTSP / RTMP server and proxy, a software that allows users to publish, read and proxy live video and audio streams. RTSP is a specification that describes how to perform these operations with the help of a server, that is contacted by both publishers and readers and relays the publisher's streams to the readers.

Dec 31, 2022
Local-audio - Web walking audio tour platform proof-of-concept

Goal: Proof of concept for a Web Audio walk platform Data retention dynamdo db "time to live" expires in 1 day from creation of record set in add.go s

Jan 9, 2022
CLI tool and library for generating a Software Bill of Materials from container images and filesystems
CLI tool and library for generating a Software Bill of Materials from container images and filesystems

A CLI tool and Go library for generating a Software Bill of Materials (SBOM) from container images and filesystems. Exceptional for vulnerability dete

Jan 6, 2023