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 ¶
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.