Rally Audio Manager
Manages a queue of pacenote audio playback and pauses for the rally co-driver system. Handles sequential playback with breath timing between notes and damage interruption.
Manages a queue of pacenote audio playback and pauses for the rally co-driver system. Handles sequential playback with breath timing between notes and damage interruption.
Constructor
local AudioManager = require('/lua/ge/extensions/gameplay/rally/audioManager')
local am = AudioManager(rallyManager)Public API
| Method | Signature | Returns | Description |
|---|---|---|---|
init | (rallyManager) | nil | Initializes with a rally manager reference |
resetQueue | () | nil | Clears the audio queue and stops current playback |
enqueuePacenoteAudio | (pacenote, addToFront) | nil | Queues audio objects from a pacenote |
enqueueSystemPacenote | (pacenote, addToFront, audioLen) | nil | Queues a system pacenote (countdown, finish, etc.) |
enqueuePauseSecs | (secs, addToFront) | nil | Queues a timed pause between notes |
handleDamage | () | nil | Interrupts current playback on vehicle damage |
isPlaying | () | bool | Returns true if audio is currently playing |
getQueueInfo | () | table | Returns {queueSize, paused} |
onUpdate | (dtReal, dtSim, dtRaw) | nil | Per-frame: plays next queued audio when ready |
Internals
| Field | Type | Description |
|---|---|---|
rallyManager | RallyManager | Parent rally manager |
queue | dequeue | Double-ended queue of audio objects |
currAudioObj | table/nil | Currently playing audio object |
Audio Object Structure
| Field | Type | Description |
|---|---|---|
audioType | string | 'pacenote' or 'pause' |
pacenoteFname | string | Path to audio file (for pacenote type) |
audioLen | number | Duration in seconds |
breathSuffixTime | number | Pause after playback before next note |
time | number | Timestamp when playback started |
timeout | number | Timestamp when playback ends |
How It Works
- Pacenote audio is queued via
enqueuePacenoteAudio()which extracts audio objects from the pacenote onUpdate()callsplayNextInQueue()each frame- When not playing, the next item is popped from the left of the dequeue
- For
'pacenote'type: plays viaEngine.Audio.intercomPlayPacenote, sets timeout = time + audioLen + breathSuffixTime - For
'pause'type: simply waits for the duration handleDamage()immediately stops current audio if it's not a damage note, clears the queueisPlaying()checks if the current time is before the timeout
Usage Examples
-- Queue a pacenote
am:enqueuePacenoteAudio(myPacenote)
-- Queue a system note with a pause
am:enqueueSystemPacenote(countdownNote)
am:enqueuePauseSecs(1.0)
-- Check playback state
if not am:isPlaying() then
-- ready for next note
end
-- Reset on stage restart
am:resetQueue()Notes
- Uses
dequeuemodule for efficient push/pop from both ends addToFrontparameter allows priority insertion (e.g., for damage interrupts)- Audio playback uses
Engine.Audio.intercomPlayPacenote(engine-level intercom system) - Breath suffix time adds a natural pause between consecutive notes
| Function | Signature | Returns | Description |
|---|---|---|---|
M.enqueueDamage | () | nil | enqueueDamage |
See Also
- Rally Camera Path Player - Related reference
- Rally Client - Related reference
- Rally Cut Capture - Related reference
- Gameplay Systems Guide - Guide
Race Start Position
Object class representing a spawn/recovery position in a race path. Stores position and rotation, and provides methods to calculate vehicle placement transforms and teleport vehicles.
Rally Camera Path Player
Plays a cinematic camera path along a snaproad for rally stage preview. Generates a Catmull-Rom camera path from driveline points with configurable height offset, FOV, and playback speed.