MODULE v1.8.0

mixer

pykraken.mixer

Sound mixer and audio management system.

More about mixer

The mixer manages a pool of 64 mixer tracks/voices for playing :class:Sample (short polyphonic sounds) and :class:Stream (long music files). It handles automatic track acquisition and priority-based sound stealing when the track pool is exhausted.

Reference

PYTHON API
get_master_volume() -> float

Get the current global mixer gain.

Returns

  • float — Master volume (0.0 to 1.0).

load_sample

function
load_sample(path: str | PathLike, predecode: bool = True) -> mixer.Sample

Load an audio sample (SFX) from disk.

Args

  • path (str | PathLike[str]) — File path to load.
  • predecode (bool) — Whether to decode into memory now. Defaults to True.

Returns

  • Sample — The loaded audio object.

load_stream

function
load_stream(path: str | PathLike, predecode: bool = False) -> mixer.Stream

Load an audio stream (Music) from disk.

Args

  • path (str | PathLike[str]) — File path to load.
  • predecode (bool) — Whether to decode into memory now. Defaults to False.

Returns

  • Stream — The loaded audio object.
set_master_volume(volume: float) -> None

Set the global mixer gain.

This affects all playing samples and streams. Individual audio volume is multiplied by this value. Default is 1.0.

Args

  • volume (float) — Master volume scalar (0.0 to 1.0).

Find your next step

Start typing to search the manual.