wav

package
v0.0.0-...-7f18e8e Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2021 License: Unlicense, Unlicense Imports: 7 Imported by: 0

Documentation

Overview

Package wav privides interface to PCM wave data. 8bits unsigned, 16bits signed and 32bits float are supported. samples must tight interlacing.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFormat       = errors.New("wav: bad or unsupported format")
	ErrRandomAccess = errors.New("wav: not random accessible")
	ErrCorrupted    = errors.New("wav: corrupted data")
)

Functions

func Write

func Write(w io.Writer, wave Reader) (err error)

Write PCM wave to writer w

func WriteFile

func WriteFile(filename string, wave Reader) error

WriteFile write PCM wave to file

Types

type Block

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

Block is PCM wave in memory

func NewBlock

func NewBlock(b []byte, tracks uint8, t Type, freq int) *Block

NewBlock create PCM memory block from bytes

func ReadAll

func ReadAll(x Reader) (*Block, error)

ReadAll read all data into memory Block from reader x

func (*Block) Duration

func (s *Block) Duration() time.Duration

Duration of the data

func (*Block) Frequency

func (s *Block) Frequency() int

Frequency reports the sample frequency. i.e. 441000

func (*Block) NumTracks

func (s *Block) NumTracks() int

NumTracks reports track count

func (*Block) Read

func (s *Block) Read(b []byte) (n int, err error)

func (*Block) ReadAt

func (s *Block) ReadAt(b []byte, off int64) (n int, err error)

ReadAt implement io.ReadAt

func (*Block) Rewind

func (s *Block) Rewind() error

Rewind to begin of data

func (*Block) SampleType

func (s *Block) SampleType() Type

SampleType reporst sample's data type

func (*Block) String

func (s *Block) String() string

type ReadCloser

type ReadCloser interface {
	Reader
	Close() error
}

ReadCloser for PCM data

func Open

func Open(filename string) (ReadCloser, error)

Open PCM wave file

type Reader

type Reader interface {
	Read(p []byte) (n int, err error)

	// SampleType reporst sample's data type
	SampleType() Type
	// Frequency reports the sample frequency. i.e. 441000
	Frequency() int
	// NumTracks reports track count
	NumTracks() int
	// Duration of the audio
	Duration() time.Duration
}

Reader for PCM data

func NewReader

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

type Type

type Type int8

Type is sample type

const (
	U8 Type = iota
	I16
	F32
)

Sample types

func (Type) Bits

func (x Type) Bits() int

Bits per sample

func (Type) String

func (x Type) String() string

Jump to

Keyboard shortcuts

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