spectrogram

package module
v1.0.1-0...-887a393 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2022 License: BSD-3-Clause Imports: 12 Imported by: 0

README

Spectrogram

Taking an audio signal (wav) and converting it into a spectrogram. Written in Go programming language.

example

Install

git clone https://github.com/xigh/spectrogram

Example

python3 sine_wav.py && ../../xigh/spectrogram/spectrogram -hamming -hideavg -bins=256 sine.wav

example

Usage

./spectrogram [options] input_file.wav

-preemp float64
    set pre-emphasis parameter (0 means no pre-emp)
-rectangle
    disable hamming window support
-BG0 string
    set background color 0 (default "000000")
-BG1 string
    set background color 1 (default "333")
-BG2 string
    set background color 2 (default "447744")
-FG0 string
    set forground color 0 (default "0972a2")
-FG1 string
    set forground color 1 (default "6b5f7e")
-RUL string
    set rulers color (default "a0b0c0")
-bins int
    set freq bins (default 512)
-dft
    use dft instead of fft
-height int
    set height (default 450)
-hideavg
    hide average
-hiderulers
    hide rulers
-length int
    set number of samples [0 means all]
-offset int
    sey begin of samples
-out string
    set output filename (default "out.png")
-ratio float
    set ratio (default 0.8)
-width int
    set width (default 2048)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	OFFSET = flag.Uint64("offset", 0, "sey begin of samples")
	LENGTH = flag.Uint64("length", 0, "set number of samples [0 means all]")

	RATIO = flag.Float64("ratio", 0.8, "set ratio")

	WIDTH  = flag.Uint("width", 2048, "set width")
	HEIGHT = flag.Uint("height", 450, "set height")

	HIDEAVG    = flag.Bool("hideavg", false, "hide average")
	HIDERULERS = flag.Bool("hiderulers", false, "hide rulers")

	OUT = flag.String("out", "out.png", "set output filename")

	BINS      = flag.Uint("bins", 512, "set freq bins")
	PREEMP    = flag.Float64("preemp", 0.95, "pre-emphasis")
	RECTANGLE = flag.Bool("rectangle", false, "use rectangle window")
	DFT       = flag.Bool("dft", false, "use dft instead of fft")
	LOG10     = flag.Bool("log10", false, "pretty")
	MAG       = flag.Bool("mag", false, "mag")

	BG0 = flag.String("BG0", "000", "set background color 0")
	BG1 = flag.String("BG1", "333", "set background color 1")

	FG0 = flag.String("FG0", "0972a2", "set forground color 0")
	FG1 = flag.String("FG1", "6b5f7e", "set forground color 1")
	RUL = flag.String("RUL", "a0b0c0", "set rulers color")
)

Functions

func Drawfft

func Drawfft(img draw.Image, samples []float64, rate, bins uint32)

func Drawwav

func Drawwav(img draw.Image, samples []float64)

func SavePng

func SavePng(img *Image128, fileName string) error

Types

type Color128

type Color128 struct {
	R, G, B, A uint32
}

func NewColor128

func NewColor128(r, g, b, a uint32) Color128

func ParseColor

func ParseColor(text string) Color128

func (Color128) RGBA

func (c Color128) RGBA() (r, g, b, a uint32)

type Gradient

type Gradient []Color128

func New

func New() Gradient

func (*Gradient) Append

func (grad *Gradient) Append(c Color128)

func (Gradient) ColorAt

func (grad Gradient) ColorAt(i float64) Color128

func (Gradient) Index

func (grad Gradient) Index(i float64) (int, float64)

type Image128

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

func NewImage128

func NewImage128(bounds image.Rectangle) *Image128

func (*Image128) At

func (img *Image128) At(x int, y int) color.Color

func (*Image128) Bounds

func (img *Image128) Bounds() image.Rectangle

func (*Image128) ColorModel

func (img *Image128) ColorModel() color.Model

func (*Image128) Set

func (img *Image128) Set(x int, y int, c color.Color)

func (*Image128) Stats

func (img *Image128) Stats() (int, int)

func (*Image128) Sub

func (img *Image128) Sub(bounds image.Rectangle) *SubImage128

type PngImage

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

func (*PngImage) At

func (p *PngImage) At(x int, y int) color.Color

func (*PngImage) Bounds

func (p *PngImage) Bounds() image.Rectangle

func (*PngImage) ColorModel

func (p *PngImage) ColorModel() color.Model

type SubImage128

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

func (*SubImage128) At

func (sub *SubImage128) At(x int, y int) color.Color

func (*SubImage128) Bounds

func (sub *SubImage128) Bounds() image.Rectangle

func (*SubImage128) ColorModel

func (sub *SubImage128) ColorModel() color.Model

func (*SubImage128) Set

func (sub *SubImage128) Set(x int, y int, c color.Color)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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