wav2png

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package wav2png implements the functions required to render an audio waveform as a PNG image. The current implementation supports 16 bit PCM WAV files only.

Index

Constants

View Source
const (
	BITS      int32 = 16
	RANGE_MIN int32 = -32768
	RANGE_MAX int32 = +32767
	RANGE     int32 = RANGE_MAX - RANGE_MIN + 1
)

Variables

View Source
var Horizontal = Kernel{
	{0, 0, 0},
	{1, 2, 1},
	{0, 0, 0},
}
View Source
var None = Kernel{
	{0, 0, 0},
	{0, 1, 0},
	{0, 0, 0},
}
View Source
var Soft = Kernel{
	{1, 2, 1},
	{2, 12, 2},
	{1, 2, 1},
}
View Source
var Vertical = Kernel{
	{0, 1, 0},
	{0, 2, 0},
	{0, 1, 0},
}

Functions

func Antialias

func Antialias(img *image.NRGBA, kernel Kernel) *image.NRGBA

func Fill

func Fill(img *image.NRGBA, spec FillSpec)

func Grid

func Grid(spec GridSpec, width, height, padding int) *image.NRGBA

func Render

func Render(pcm []float32, fs float64, width, height int, palette Palette, volume float64) *image.NRGBA

Types

type FillSpec

type FillSpec interface {
	Colour() color.NRGBA
	Fill(img *image.NRGBA)
}

type Fit

type Fit int
const (
	Approximate Fit = iota
	Exact
	AtLeast
	AtMost
	LargerThan
	SmallerThan
)

func (Fit) String

func (f Fit) String() string

type GridSpec

type GridSpec interface {
	Colour() color.NRGBA
	Overlay() bool
	Border(bounds image.Rectangle, padding int) *image.Rectangle
	VLines(bounds image.Rectangle, padding int) []int
	HLines(bounds image.Rectangle, padding int) []int
}

func NewNoGrid

func NewNoGrid() GridSpec

type Kernel

type Kernel [3][3]uint32

type NoGrid

type NoGrid struct {
}

func (NoGrid) Border

func (g NoGrid) Border(bounds image.Rectangle, padding int) *image.Rectangle

func (NoGrid) Colour

func (g NoGrid) Colour() color.NRGBA

func (NoGrid) HLines

func (g NoGrid) HLines(bounds image.Rectangle, padding int) []int

func (NoGrid) Overlay

func (g NoGrid) Overlay() bool

func (NoGrid) VLines

func (g NoGrid) VLines(bounds image.Rectangle, padding int) []int

type Palette

type Palette struct {
	// contains filtered or unexported fields
}
var Ice Palette = Palette{
	// contains filtered or unexported fields
}
var Mono Palette = Palette{
	// contains filtered or unexported fields
}

func PaletteFromPng

func PaletteFromPng(png image.Image) (*Palette, error)

type RectangularGrid

type RectangularGrid struct {
	// contains filtered or unexported fields
}

func NewRectangularGrid

func NewRectangularGrid(colour color.NRGBA, width, height uint, fit Fit, overlay bool) RectangularGrid

func (RectangularGrid) Border

func (g RectangularGrid) Border(bounds image.Rectangle, padding int) *image.Rectangle

func (RectangularGrid) Colour

func (g RectangularGrid) Colour() color.NRGBA

func (RectangularGrid) HLines

func (g RectangularGrid) HLines(bounds image.Rectangle, padding int) []int

func (RectangularGrid) Overlay

func (g RectangularGrid) Overlay() bool

func (RectangularGrid) VLines

func (g RectangularGrid) VLines(bounds image.Rectangle, padding int) []int

type SolidFill

type SolidFill struct {
	// contains filtered or unexported fields
}

func NewSolidFill

func NewSolidFill(colour color.NRGBA) SolidFill

func (SolidFill) Colour

func (f SolidFill) Colour() color.NRGBA

func (SolidFill) Fill

func (f SolidFill) Fill(img *image.NRGBA)

type SquareGrid

type SquareGrid struct {
	// contains filtered or unexported fields
}

func NewSquareGrid

func NewSquareGrid(colour color.NRGBA, size uint, fit Fit, overlay bool) SquareGrid

func (SquareGrid) Border

func (g SquareGrid) Border(bounds image.Rectangle, padding int) *image.Rectangle

func (SquareGrid) Colour

func (g SquareGrid) Colour() color.NRGBA

func (SquareGrid) HLines

func (g SquareGrid) HLines(bounds image.Rectangle, padding int) []int

func (SquareGrid) Overlay

func (g SquareGrid) Overlay() bool

func (SquareGrid) VLines

func (g SquareGrid) VLines(bounds image.Rectangle, padding int) []int

Jump to

Keyboard shortcuts

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