audio

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package audio is the malgo (miniaudio) playback engine: it streams, decrypts and decodes Deezer audio (MP3 + FLAC) into a PCM ring that a single output device drains. Supports seek, per-track ReplayGain, output-device selection, gapless transitions and (experimental) crossfade. In-memory only — nothing is written to disk.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Device added in v0.4.0

type Device struct {
	ID        string // backend device id, hex-encoded; "" = system default
	Name      string
	IsDefault bool
}

Device is an output device the user can pick.

type Player

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

Player owns the malgo context + one output device and plays a current source, optionally with a preloaded next source for gapless/crossfade.

func NewPlayer

func NewPlayer() (*Player, error)

NewPlayer initializes the audio context + default output device.

func (*Player) AddVolume

func (p *Player) AddVolume(delta float64) float64

func (*Player) Close added in v0.4.0

func (p *Player) Close()

Close tears down the device + context.

func (*Player) CrossfadeMS added in v0.4.0

func (p *Player) CrossfadeMS() int

func (*Player) CurrentDevice added in v0.4.0

func (p *Player) CurrentDevice() string

CurrentDevice returns the selected device id ("" = default).

func (*Player) Devices added in v0.4.0

func (p *Player) Devices() ([]Device, error)

Devices lists available playback devices.

func (*Player) DurationMS

func (p *Player) DurationMS() int64

func (*Player) Format

func (p *Player) Format() string

func (*Player) Gapless added in v0.4.0

func (p *Player) Gapless() bool

Gapless reports whether gapless transitions are enabled.

func (*Player) LastError

func (p *Player) LastError() string

func (*Player) Pause

func (p *Player) Pause()

func (*Player) Play

func (p *Player) Play(plan *deezer.StreamPlan, durationMS int64) error

Play starts a track immediately, replacing anything current.

func (*Player) PositionMS

func (p *Player) PositionMS() int64

func (*Player) Preload added in v0.4.0

func (p *Player) Preload(plan *deezer.StreamPlan, durationMS int64)

Preload prepares the next track so the transition is gapless/crossfaded. It is a no-op if gapless is disabled.

func (*Player) ReplayGain added in v0.3.0

func (p *Player) ReplayGain() bool

func (*Player) Resume

func (p *Player) Resume()

func (*Player) SeekMS

func (p *Player) SeekMS(ms int64)

SeekMS jumps to an absolute position in the current track.

func (*Player) SetCrossfadeMS added in v0.4.0

func (p *Player) SetCrossfadeMS(ms int)

func (*Player) SetDevice added in v0.4.0

func (p *Player) SetDevice(id string) error

SetDevice switches output to the device with the given id ("" = system default), reinitializing the playback device. Playback continues from the current source.

func (*Player) SetGapless added in v0.4.0

func (p *Player) SetGapless(on bool)

SetGapless enables/disables gapless transitions between tracks.

func (*Player) SetOnFinish

func (p *Player) SetOnFinish(fn func())

func (*Player) SetReplayGain added in v0.3.0

func (p *Player) SetReplayGain(on bool)

func (*Player) State

func (p *Player) State() State

func (*Player) Stop

func (p *Player) Stop()

Stop halts playback and releases sources.

func (*Player) TogglePause

func (p *Player) TogglePause()

func (*Player) Volume

func (p *Player) Volume() float64

type State

type State int

State is the player's lifecycle state.

const (
	Stopped State = iota
	Loading
	Playing
	Paused
	Errored
)

func (State) String

func (s State) String() string

Jump to

Keyboard shortcuts

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