audio

package
v1.0.260758 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package audio wraps github.com/ebitengine/oto/v3 for local PCM playback — the "audio decode hooks" slice of the roadmap's Host/App API line, consumed via uiapp.Host.PlayAudio. Decoding (ffmpeg subprocess, for Amp and Vid) stays entirely outside this package; it only plays already- decoded interleaved int16 samples.

Index

Constants

View Source
const (
	SampleRate = 48000
	Channels   = 2
)

SampleRate/Channels are the fixed output format every caller must decode to. oto's Context — and the real audio device behind it — is created once per process at a single sample rate/channel count; there is no per-call resampling (oto's own docs: "Creating multiple contexts is NOT supported"). ffmpeg-based decoders should always target these via -ar/-ac flags rather than passing a rate through here.

Variables

This section is empty.

Functions

This section is empty.

Types

type Playback

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

Playback controls audio started via Play. Pause/Resume map straight onto oto's own Player.Pause/Play — pausing doesn't restart or re-seek anything, and it doubles as backpressure on the whole pipeline for free: once the player stops pulling from the reader, the feeding goroutine's channel send blocks, which blocks whatever's decoding upstream (e.g. an ffmpeg subprocess whose stdout pipe just fills up) — no separate pause signal needs to reach the decoder.

func Play

func Play(pcm <-chan []int16) (*Playback, error)

Play streams pcm (interleaved int16 samples at SampleRate/Channels) to the shared audio output until pcm is closed or Stop is called. Stop is safe to call more than once (and safe to never call, if pcm closes on its own — e.g. end of track).

func (*Playback) Pause

func (p *Playback) Pause()

func (*Playback) Playing

func (p *Playback) Playing() bool

func (*Playback) Resume

func (p *Playback) Resume()

func (*Playback) Stop

func (p *Playback) Stop()

Jump to

Keyboard shortcuts

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