Giter Site home page Giter Site logo

waveform's Introduction

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

waveform's People

Contributors

mdlayher avatar mewmew avatar vulpivia avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

waveform's Issues

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.

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.

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.

panic: EOF

Hi,

I'm using the latest commit of waveform: 6b28917
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.

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
	}
} 

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

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.