Skip to content
Edit this page

Audio & Buses

Pite supports WAV (8/16/24/32-bit int and float), OGG (Vorbis), MP3, and FLAC playback with dynamic named audio buses.

voice = pite.play("res://sfx/hit.wav", volume=0.8, bus="sfx")
pite.set_volume(voice, 0.5)
pite.set_bus_volume("music", 0.4)
pite.set_bus_muted("sfx", True)
pite.stop_bus("music")
if not pite.is_playing(voice):
    pass
pite.stop(voice)

Voice Playback

  • pite.play(path: str, volume: float = 1.0, bus: str = "master") -> int: Decodes the audio file, assigns it to bus, and returns a voice ID. Output goes to the OS default audio device; on machines without an audio device, playback is simulated (a warning is logged; same API, no sound). Missing or undecodable files raise loudly without crashing the game.
  • pite.set_volume(voice_id: int, volume: float): Updates a playing voice's volume (clamped to 0.0–1.0). Unknown IDs are silent no-ops.
  • pite.is_playing(voice_id: int) -> bool: Returns True if the voice is currently playing, False for finished or unknown IDs.
  • pite.stop(voice_id: int): Stops a playing voice. Unknown IDs are silent no-ops.

pite check validates every pite.play("…") literal in project scripts to ensure the file exists and decodes.


Audio Buses

All named buses route through "master":

\[\text{effective\_gain} = \text{voice\_volume} \times \text{bus\_volume} \times \text{master\_volume}\]

If either the target bus or "master" is muted, the effective gain is 0.0.

  • pite.set_bus_volume(bus: str, volume: float): Sets the volume multiplier for bus.
  • pite.bus_volume(bus: str) -> float: Returns the current volume multiplier for bus.
  • pite.set_bus_muted(bus: str, muted: bool): Mutes or unmutes bus.
  • pite.is_bus_muted(bus: str) -> bool: Returns whether bus is muted.
  • pite.stop_bus(bus: str): Stops all currently playing voices on bus.