vorbis

package
v0.0.0-...-682a2af Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2024 License: BSD-2-Clause, MIT Imports: 5 Imported by: 0

README

vorbis

a native go vorbis decoder

Note that this package can only decode raw vorbis packets, for reading .ogg files, use oggvorbis

godoc

The vorbis specification

Documentation

Overview

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

Constants

This section is empty.

Variables

This section is empty.

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.

Jump to

Keyboard shortcuts

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