Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Juan-Carlos-Cruz/robotaxi-zoox/llms.txt
Use this file to discover all available pages before exploring further.
AudioManager manages all audio in Robotaxi Zoox — background ambient music, a looping drive sound during taxi animation, and discrete event effects triggered by pickups, traffic, UI interactions, and route completion. The class wraps pygame.mixer behind a clean interface: when the mixer cannot initialise (headless environments, missing audio device), AudioManager sets enabled = False and every method becomes a silent no-op, so the rest of the application continues unaffected.
Import
Constructor
pygame.mixer with frequency=22050, size=-16, channels=2, buffer=512 (if not already running). Allocates 8 mixer channels — channel 1 is reserved for the drive loop, channels 2–3 for round-robin effect playback. Loads all WAV assets from the audio/ directory at the project root. Sets enabled = True on success or enabled = False on any pygame.error, printing a diagnostic message without raising.
Attributes
True when pygame.mixer initialised successfully and audio is available. False when initialisation failed. All methods check this flag before acting.User-controlled preference for ambient music playback. Defaults to
True. Change via set_ambient_enabled().Loaded sound effects keyed by internal name:
'road_loop', 'pickup_horn', 'traffic_horn', 'ui_click', 'finish_jingle'. Only populated when enabled is True and the corresponding WAV file exists.Methods
play_ambient()
lofi_ambient.wav on the music channel with an infinite loop and a 900 ms fade-in. If ambient music is already playing, it simply updates the volume to match the current drive-loop ducking state. Does nothing when enabled is False or ambient_enabled is False.
start_drive_loop()
road_loop.wav on the dedicated drive channel with an infinite loop and a 250 ms fade-in. Simultaneously ducks the ambient music to DUCKED_AMBIENT_VOLUME (0.16) to keep the soundscape balanced while the taxi is moving. Does nothing when enabled is False or the sound file is missing.
stop_drive_loop()
AMBIENT_VOLUME (0.24). Safe to call even if the drive loop is not currently active. Does nothing when enabled is False.
play_pickup_horn()
pickup_horn.wav as a one-shot effect on the next available effect channel. Triggered when the taxi collects a passenger.
play_traffic_horn()
traffic_horn.wav as a one-shot effect. Triggered when the taxi enters a high-traffic cell.
play_ui_click()
ui_click.wav as a one-shot effect. Triggered on button presses and algorithm selection changes in the interface.
play_finish_jingle()
finish_jingle.wav as a one-shot effect. Triggered when the taxi reaches its destination after collecting all passengers.
set_ambient_enabled(enabled)
False, fades out any currently playing music over 250 ms and resets ambient_started. When set to True, immediately calls play_ambient() to begin playback.
True to enable ambient music, False to disable and fade it out.shutdown()
stop_drive_loop() to fade out the drive channel, then fades out the music channel over 400 ms. Call this before pygame.quit() to avoid audio artefacts at exit. Does nothing when enabled is False.
Volume constants
All volume values are in the range0.0 (silent) to 1.0 (full). The constants are defined at module level in application/audio.py.
| Constant | Value | Used for |
|---|---|---|
AMBIENT_VOLUME | 0.24 | Normal ambient music level |
DRIVE_VOLUME | 0.28 | road_loop.wav playback volume |
PICKUP_HORN_VOLUME | 0.28 | pickup_horn.wav effect volume |
TRAFFIC_HORN_VOLUME | 0.24 | traffic_horn.wav effect volume |
UI_CLICK_VOLUME | 0.22 | ui_click.wav effect volume |
FINISH_JINGLE_VOLUME | 0.30 | finish_jingle.wav effect volume |
DUCKED_AMBIENT_VOLUME | 0.16 | Ambient level while drive loop is active |
Example
All methods are safe to call even when
enabled is False — they silently do nothing. There is no need to guard every call site with if audio.enabled; the guard shown in the example above is only necessary when you want to branch on audio availability for other logic.