Help us shape the future of Go! Take the 2026 Go Developer Survey

qoa

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package qoa provides bounded one-shot and incremental adapters around Karty's pinned QOA codec.

Index

Constants

View Source
const (
	MaxEncodedBytes = 8 * 1024 * 1024
)
View Source
const MaxStreamDurationSeconds = asset.MaxAudioStreamDurationSeconds

MaxStreamDurationSeconds bounds long-form QOA metadata without requiring the complete decoded PCM to fit in memory.

View Source
const MaxStreamEncodedBytes = asset.MaxEncodedAudioStreamBytes

MaxStreamEncodedBytes bounds complete long-form QOA files processed by the packaging APIs. Runtime playback should use StreamDecoder instead.

Variables

View Source
var ErrInvalid = errors.New("QOA data is invalid")

Functions

This section is empty.

Types

type Metadata

type Metadata struct {
	Channels     uint8
	SampleRate   uint32
	Frames       uint32
	DecodedBytes uint64
}

Metadata describes bounded, static QOA content. Frames is the number of samples per channel; DecodedBytes is interleaved signed PCM16 storage.

func Decode

func Decode(encoded []byte) (metadata Metadata, samples []int16, err error)

Decode returns interleaved signed PCM16 only after Inspect has established safe allocation and frame bounds.

func Encode

func Encode(samples []int16, channels uint8, sampleRate uint32) (encoded []byte, metadata Metadata, err error)

Encode converts complete interleaved signed PCM16 into deterministic static QOA after validating lengths and Karty's runtime budgets.

func EncodeStream added in v0.0.4

func EncodeStream(samples []int16, channels uint8, sampleRate uint32) (encoded []byte, metadata Metadata, err error)

EncodeStream converts complete interleaved signed PCM16 into deterministic static QOA using the long-form streaming-audio bounds. The resulting file is suitable for separate staging and incremental playback with StreamDecoder.

func Inspect

func Inspect(encoded []byte) (Metadata, error)

Inspect validates a complete static QOA file using uint64 arithmetic. It rejects streaming files, noncanonical frames, trailing data, and content outside Karty's one-shot sound budgets.

func InspectStream added in v0.0.4

func InspectStream(encoded []byte) (Metadata, error)

InspectStream validates a complete, static long-form QOA file. It applies streaming-audio duration and encoded-size bounds without requiring decoded PCM to fit in the one-shot sound budget.

type StreamDecoder added in v0.0.4

type StreamDecoder struct {
	// contains filtered or unexported fields
}

StreamDecoder incrementally validates QOA frames and exposes interleaved little-endian PCM16. It retains at most one encoded and one decoded frame.

func NewStreamDecoder added in v0.0.4

func NewStreamDecoder(source io.Reader) (*StreamDecoder, error)

NewStreamDecoder reads the file header and first frame. Static QOA with a known sample count is required so allocation and duration bounds are known.

func (*StreamDecoder) Metadata added in v0.0.4

func (decoder *StreamDecoder) Metadata() Metadata

func (*StreamDecoder) Read added in v0.0.4

func (decoder *StreamDecoder) Read(destination []byte) (int, error)

Jump to

Keyboard shortcuts

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