spectogram

package module
v0.0.0-...-622acf2 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: BSD-3-Clause Imports: 11 Imported by: 0

README

Spectrogram

Go

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

View Source
const (
	FlagDrawAvg = 1 // Draws the average
	FlagDrawMax = 2 // Draws the maximum
)

Variables

This section is empty.

Functions

func DrawFFT

func DrawFFT(img draw.Image, gr Gradient, samples []float64, bins int)

DrawFFT calculates and draws the fast Fourier transform (FFT)

func DrawWaveform

func DrawWaveform(params WaveformParams, img draw.Image, samples []float64)

DrawWaveform calculates and draws the waveform

func ParseColor

func ParseColor(text string) color.RGBA

ParseColor interpretates a string representation of a color as RGBA

func ReadOgg

func ReadOgg(r *oggvorbis.Reader) ([]float64, error)

ReadOgg reads a ogg/vorbis stream

func ReadOggFile

func ReadOggFile(path string) ([]float64, error)

ReadOggFile reads a ogg/vorbis file

Types

type Gradient

type Gradient []color.RGBA

func NewGradient

func NewGradient() Gradient

func (*Gradient) Append

func (grad *Gradient) Append(c ...color.RGBA)

func (Gradient) ColorAt

func (grad Gradient) ColorAt(i float64) color.RGBA

func (Gradient) Index

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

type Line

type Line struct {
	Min float64
	Max float64
	Avg float64
}

type WaveformParams

type WaveformParams struct {
	AvgColor color.Color
	MaxColor color.Color
	Draw     int
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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