vorbis

package
v0.3.13 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: MIT Imports: 8 Imported by: 2 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package vorbis is a pure-Go Ogg Vorbis decoder (Vorbis I) for the sound files freedesktop sound themes ship (.oga): it decodes a whole stream once into interleaved signed 16-bit PCM, the layout a sample cache upload or a playback stream takes.

It covers the whole Vorbis I specification: floor types 0 and 1, residue types 0, 1 and 2, codebook lookup types 1 and 2, channel coupling, both block sizes and any channel count, and it checks every Ogg page's CRC. Output matches libvorbis's to within one least significant bit.

data, err := os.ReadFile("message-new-instant.oga")
sound, err := vorbis.Decode(data)
// sound.Samples holds sound.Frames()*sound.Channels samples

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotVorbis is data that is not an Ogg stream carrying Vorbis.
	ErrNotVorbis = errors.New("not an Ogg Vorbis stream")
	// ErrCorrupt is a stream whose framing, checksums or headers are
	// invalid.
	ErrCorrupt = errors.New("corrupt stream")
	// ErrTruncated is a stream that ends inside a page or a packet.
	ErrTruncated = errors.New("truncated stream")
)

Decode fails with one of these, wrapped with what was being read.

Functions

This section is empty.

Types

type Sound

type Sound struct {
	// SampleRate is in frames per second.
	SampleRate int
	// Channels is the number of interleaved channels, in Vorbis
	// channel order.
	Channels int
	// Samples is the PCM, interleaved by channel.
	Samples []int16
}

Sound is a decoded stream.

func Decode

func Decode(data []byte) (Sound, error)

Decode decodes the first logical Vorbis stream of an Ogg file. Other logical streams multiplexed with it are skipped; a chained stream after it is not read.

func (Sound) Frames

func (s Sound) Frames() int

Frames is the length of the sound in frames (samples per channel).

Jump to

Keyboard shortcuts

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