waveform

package module
v0.0.0-...-f044b83 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 7, 2023 License: MIT Imports: 4 Imported by: 0

README

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbsMax

func AbsMax(w WaveReader, o *Options) *image.NRGBA

AbsMax function ...

func MinMax

func MinMax(w WaveReader, o *Options) *image.NRGBA

MinMax function ...

func Rms

func Rms(w WaveReader, o *Options) *image.NRGBA

Rms function ...

Types

type Options

type Options struct {
	Width   int
	Height  int
	Half    bool
	Zoom    float32
	MarginL int
	MarginR int
	MarginT int
	MarginB int
	Back    *color.NRGBA
	Front   *color.NRGBA
}

Options represents ...

type WaveReader

type WaveReader interface {
	Len() uint64
	Rate() uint32
	Chans() uint16
	At(ch uint, offset uint64) (float32, error)
}

WaveReader interface ...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL