wave: github.com/bake/wave Index | Files | Directories

package wave

import "github.com/bake/wave"

Package wave offers a simplified API to read and write WAVE files by only allowing to work with samples directly.

Index

Package Files

format.go reader.go wave.go writer.go

type Format Uses

type Format struct {
    AudioFormat   uint16 // 1 if PCM is used.
    NumChans      uint16 // Number of channels (1 = mono, 2 = stereo, ...)
    SampleRate    uint32 // Samples per second (44100, ...).
    ByteRate      uint32 // Average bytes per second.
    BlockAlign    uint16 // Bytes per sample.
    BitsPerSample uint16 // Bits per sample.
}

Format holds configuration about the WAVE.

type Reader Uses

type Reader struct {
    Format Format
    // contains filtered or unexported fields
}

Reader reads samples from a WAVE file.

func NewReader Uses

func NewReader(r io.Reader) (*Reader, error)

NewReader reads the initial chunks from a WAVE file and returns a new reader.

func (*Reader) Sample Uses

func (wavr *Reader) Sample() (int, error)

Sample returns the next sample from the wave file. Chunks that don't contain samples are skipped.

func (*Reader) Samples Uses

func (wavr *Reader) Samples() ([]int, error)

Samples reads the whole file and returns all samples.

type Writer Uses

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

Writer writes samples to an io.WriteSeeker.

func NewWriter Uses

func NewWriter(ws io.WriteSeeker, format Format) (*Writer, error)

NewWriter creates a new WAVE Writer.

func (*Writer) Close Uses

func (wavw *Writer) Close() error

Close the underlying RIFF writers. The file writer needs to be closed separately.

func (*Writer) Sample Uses

func (wavw *Writer) Sample(s int) error

Sample writes a sample.

func (*Writer) Samples Uses

func (wavw *Writer) Samples(samples []int) error

Samples writes a slice of samples.

Directories

PathSynopsis
riffPackage riff contains implementations for a reader and a writer for RIFF files.

Package wave imports 5 packages (graph). Updated 2019-08-18. Refresh now. Tools for package owners.