waveform

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2021 License: MIT Imports: 11 Imported by: 0

README

go-waveform

go-waveform

Golang project for the purpose of practicing, understanding golang and audio file format.

Usage

Requirements

Go 1.11 (Go Modules)

Cli

Generate waveform image via CLI

GO111MODULE=on make
./bin/go-waveform -t dark -r 1000 -f png example/violin.wav

open example/violin-L.png
open example/violin-R.png
Import as package

Import as package,

import "github.com/cettoana/go-waveform"

and decode wav audio file

w := waveform.DecodeWav(wavFileBytes)
fmt.Println(w.BitsPerSample)

data, _ := w.GetData()

if stereoData, ok := data.(*waveform.StereoData); ok {
  fmt.Println(stereoData.RSample)
  fmt.Println(stereoData.LSample)
} else if monoData, ok := data.(*waveform.MonoData); ok {
  fmt.Println(monoData.Sample)
}
Todo
  • More wav file details
  • Converter
  • Raw Waveform
  • Waveform image customization
  • Test

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OutputWaveformImageMp3

func OutputWaveformImageMp3(data *mp3.Decoder, option *Option) (r io.Reader, err error)

OutputWaveformImageMp3 outputs waveform image from *mp3.Decoder.

func OutputWaveformImageWav

func OutputWaveformImageWav(data *wav.Decoder, option *Option) (r io.Reader, err error)

OutputWaveformImageWav outputs waveform image from *wav.Decoder.

Types

type Option

type Option struct {
	// Resolution specifies the resolution of the
	// Required.
	Resolution int
	// Width specifies the width of the resulting image.
	// Default: Resolution * 5
	Width int
	// Height specifies the height of the resulting image.
	// Default: 540
	Height int
	// Background specifies the color of the background.
	// Default: none (transparent)
	Background color.Color
	// Color specifies the color of the waveform.
	// Default: color.Black
	Color color.Color
}

Option image option

Jump to

Keyboard shortcuts

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