Skip to content

Latest commit

 

History

History
72 lines (58 loc) · 964 Bytes

README.md

File metadata and controls

72 lines (58 loc) · 964 Bytes

go-waveform

Go module to generate and render waveform images from audio files

Example :

combined

We can zoom :

combined2

TODO

  • doc
  • add range
  • add segment
  • add labels

Usage :

import (
    // ...
	"github.com/xigh/go-waveform"
	"github.com/xigh/go-wavreader"
)

func main() {
	r, err := os.Open("test-hello.wav")
	if err != nil {
		return err
	}
	defer r.Close()
	
	w0, err := wavreader.New(r)
	if err != nil {
        return err
    }
    
	img := waveform.MinMax(w1, &waveform.Options{
		Width:   1800,
		Height:  400,
		Zoom:    1.7,
		Half:    false,
		MarginL: *margin,
		MarginR: *margin,
		MarginT: *margin,
		MarginB: *margin,
		Front: &color.NRGBA{
			R: 255,
			G: 128,
			B: 0,
			A: 150,
		},
		Back: &color.NRGBA{
			A: 0,
		},
	})

	w, err := os.Create("test-minmax.png")
	if err != nil {
		return err
	}
	defer w.Close()

	err = png.Encode(w, img)
	if err != nil {
		return err
    }
}