audio

package
v2.11.0-beta3 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2026 License: GPL-3.0 Imports: 19 Imported by: 1 module, 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 audio provides cross-platform audio playback using malgo.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MalgoPlayer added in v2.9.1

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

MalgoPlayer implements Player using malgo for real audio hardware output.

func NewMalgoPlayer added in v2.9.1

func NewMalgoPlayer() *MalgoPlayer

NewMalgoPlayer creates a new MalgoPlayer instance.

func (*MalgoPlayer) ClearFileCache added in v2.9.1

func (p *MalgoPlayer) ClearFileCache()

ClearFileCache clears the in-memory file cache, forcing subsequent PlayFile calls to re-read from disk. Called after settings reload to pick up new files.

func (*MalgoPlayer) PlayBytes added in v2.11.0

func (p *MalgoPlayer) PlayBytes(data []byte) error

PlayBytes plays audio from a byte slice asynchronously, detecting format from magic bytes. Supports WAV, OGG (Vorbis), MP3, and FLAC.

func (*MalgoPlayer) PlayFile added in v2.9.1

func (p *MalgoPlayer) PlayFile(path string) error

PlayFile plays an audio file asynchronously, detecting format by extension. Supports WAV, MP3, OGG (Vorbis), and FLAC. Cancels any currently playing sound. File bytes are cached per-instance to avoid repeated disk reads for the same path.

func (*MalgoPlayer) SetVolume added in v2.11.0

func (p *MalgoPlayer) SetVolume(volume float64)

SetVolume sets the playback volume (0.0-2.0). Applies to subsequent playback calls.

type Player added in v2.9.1

type Player interface {
	PlayBytes(data []byte) error
	PlayFile(path string) error
	ClearFileCache()
	SetVolume(volume float64)
}

Player is the interface for audio playback, allowing tests to mock sound output.

Jump to

Keyboard shortcuts

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