wav

package
v0.0.0-...-8c779d3 Latest Latest
Warning

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

Go to latest
Published: May 20, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AudioFormatPCM       = 1
	AudioFormatIEEEFloat = 3
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Chunk

type Chunk struct {
	ChunkID   []byte
	ChunkSize uint32
	RIFFReader
}

type RIFFChunk

type RIFFChunk struct {
	FileSize uint32
	FileType []byte
	Chunks   []*Chunk
}

type RIFFReader

type RIFFReader interface {
	io.Reader
	io.ReaderAt
}

type Reader

type Reader struct {
	*WavData
	// contains filtered or unexported fields
}

func NewReader

func NewReader(r RIFFReader) *Reader

func (*Reader) FloatValue

func (r *Reader) FloatValue(f *WavFormat, sample Sample, channel uint) float32

func (*Reader) Format

func (r *Reader) Format() (*WavFormat, *WavMeta)

func (*Reader) IntValue

func (r *Reader) IntValue(sample Sample, channel uint) int

func (*Reader) Read

func (r *Reader) Read(p []byte) (n int, err error)

func (*Reader) ReadSamples

func (r *Reader) ReadSamples(f *WavFormat, meta *WavMeta) (samples []Sample, err error)

type RiffWriter

type RiffWriter struct {
	io.Writer
}

func NewTheRiffWriter

func NewTheRiffWriter(w io.Writer, fileType []byte, fileSize uint32) *RiffWriter

func (*RiffWriter) WriteChunk

func (w *RiffWriter) WriteChunk(chunkID []byte, chunkSize uint32, cb writeCallback) (err error)

type Sample

type Sample struct {
	Values [2]int
}

type TheRiffReader

type TheRiffReader struct {
	RIFFReader
}

func NewTheRiffReader

func NewTheRiffReader(r RIFFReader) *TheRiffReader

func (*TheRiffReader) Read

func (r *TheRiffReader) Read() (chunk *RIFFChunk, err error)

type WavData

type WavData struct {
	io.Reader
	Size uint32
	// contains filtered or unexported fields
}

type WavFormat

type WavFormat struct {
	AudioFormat   uint16
	NumChannels   uint16
	SampleRate    uint32
	ByteRate      uint32
	BlockAlign    uint16
	BitsPerSample uint16
}

type WavMeta

type WavMeta struct {
	Duration float64
	Data     []byte
}

type Writer

type Writer struct {
	io.Writer
	Format *WavFormat
}

func NewWriter

func NewWriter(w io.Writer, numSamples uint32, numChannels uint16, sampleRate uint32, bitsPerSample uint16) (writer *Writer)

func (*Writer) WriteSamples

func (w *Writer) WriteSamples(samples []Sample) (err error)

Jump to

Keyboard shortcuts

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