codec

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2015 License: ISC Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrFormat = errors.New("codec: unknown format")

ErrFormat indicates that decoding encountered an unknown format.

Functions

func RegisterCodec

func RegisterCodec(name, magic string, extensions []string, decode func(Reader) ([]Song, error))

RegisterCodec registers an audio codec for use by Decode. Name is the name of the format, like "nsf" or "wav". Magic is the magic prefix that identifies the codec's encoding. The magic string can contain "?" wildcards that each match any one byte. Decode is the function that decodes the encoded codec.

Types

type Reader

type Reader func() (io.ReadCloser, int64, error)

Reader returns a file reader and the file size in bytes (or 0 if streamed or unknown).

type Song

type Song interface {
	// Info returns information about a song.
	Info() (SongInfo, error)
	// Init is called before the first call to Play(). It should prepare resources
	// needed for Play().
	Init() (sampleRate, channels int, err error)
	// Play returns the next n samples. Return < n to indicate end of song or 0
	// to indicate EOF, neither of which should return an error. If < n samples
	// are returned, Play will not be invoked again.
	Play(n int) ([]float32, error)
	// Close releases resources used by the current file.
	Close()
}

func ByExtension

func ByExtension(path string, rf Reader) ([]Song, string, error)

func Decode

func Decode(rf Reader) ([]Song, string, error)

Decode decodes audio that has been encoded in a registered codec. The string returned is the format name used during format registration. Format registration is typically done by the init method of the codec- specific package.

type SongInfo

type SongInfo struct {
	Time   time.Duration
	Artist string
	Title  string
	Album  string
	Track  float64
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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