vorbis – github.com/jfreymuth/vorbis Index | Files

package vorbis

import "github.com/jfreymuth/vorbis"

Package vorbis implements a vorbis decoder.

Note that this package only decodes raw vorbis packets, these packets are usually stored in a container format like ogg.

The vorbis specification is available at: https://xiph.org/vorbis/doc/Vorbis_I_spec.html

Index

Functions

func IsHeader

func IsHeader(packet []byte) bool

IsHeader returns wether the packet is a vorbis header.

Types

type Bitrate

type Bitrate struct {
	Nominal int
	Minimum int
	Maximum int
}

The Bitrate of a vorbis stream. Some or all of the fields can be zero.

type CommentHeader

type CommentHeader struct {
	Vendor   string
	Comments []string
}

The CommentHeader of a vorbis stream.

type Decoder

type Decoder struct {
	Bitrate Bitrate

	CommentHeader
	// contains filtered or unexported fields
}

A Decoder stores the information necessary to decode a vorbis steam.

func (*Decoder) BufferSize

func (d *Decoder) BufferSize() int

BufferSize returns the highest amount of data that can be decoded from a single packet. The result is already multiplied with the number of channels. This will be zero if the headers have not been read yet.

func (*Decoder) Channels

func (d *Decoder) Channels() int

Channels returns the number of channels of the vorbis stream. This will be zero if the headers have not been read yet.

func (*Decoder) Clear

func (d *Decoder) Clear()

Clear must be called between decoding two non-consecutive packets.

func (*Decoder) Decode

func (d *Decoder) Decode(in []byte) ([]float32, error)

Decode decodes a packet and returns the result as an interleaved float slice. The number of samples decoded varies and can be zero, but will be at most BufferSize()

func (*Decoder) DecodeInto

func (d *Decoder) DecodeInto(in []byte, buffer []float32) ([]float32, error)

DecodeInto decodes a packet and stores the result in the given buffer. The size of the buffer must be at least BufferSize(). The method will always return a slice of the buffer or nil.

func (*Decoder) HeadersRead

func (d *Decoder) HeadersRead() bool

HeadersRead returns wether the headers necessary for decoding have been read.

func (*Decoder) ReadHeader

func (d *Decoder) ReadHeader(header []byte) error

ReadHeader reads a vorbis header. Three headers (identification, comment, and setup) must be read before any samples can be decoded.

func (*Decoder) SampleRate

func (d *Decoder) SampleRate() int

SampleRate returns the sample rate of the vorbis stream. This will be zero if the headers have not been read yet.

Source Files

bitreader.go codebook.go decode.go doc.go floor0.go floor1.go header.go huffman.go imdct.go inversedbtable.go residue.go setup.go vorbis.go window.go

Version
v1.0.2 (latest)
Published
Jan 30, 2021
Platform
linux/amd64
Imports
5 packages
Last checked
1 month ago

Tools for package owners.