Adapters
EngineAdapter
- class EngineAdapter(bus: EventBus, ev: EVSoundEngine)[source]
Bases:
objectAdapter responsible for synchronizing vehicle dynamics with the EV sound engine.
This class subscribes to simulation data from the EventBus (speed and throttle) and translates these values into auditory parameters for the EVSoundEngine. It ensures that engine sounds react dynamically to the driver’s input and vehicle state.
- ev
The engine responsible for generating electric vehicle sounds.
- Type:
- __init__(bus: EventBus, ev: EVSoundEngine)[source]
Initializes the EngineAdapter and subscribes to relevant data keys.
- Parameters:
bus (EventBus) – The system bus used for data subscription.
ev (EVSoundEngine) – The sound engine instance to be controlled.
- on_speed(speed)[source]
Callback triggered when a new speed value is published to the EventBus.
- Parameters:
speed (float) – The updated speed value from the simulation.
- on_throttle(throttle)[source]
Callback triggered when a new throttle value is published to the EventBus.
- Parameters:
throttle (float) – The updated throttle input from the simulation.
EnvironmentAdapter
- class EnvironmentAdapter(event_bus: EventBus, bank: EnvironmentBank)[source]
Bases:
objectAdapter responsible for mapping environmental simulation data to FMOD sound events.
This class monitors environmental factors like rain and wind intensity from the EventBus. It translates these raw simulation values into discrete levels (defined by
RainIntensityandWindIntensity) and updates the corresponding FMOD Studio parameters to modulate the ambient audio.- bank
The sound bank containing environmental audio events.
- Type:
- rain_event
The FMOD event instance controlling rain audio.
- Type:
EventInstance
- wind_event
The FMOD event instance controlling wind audio.
- Type:
EventInstance
- __init__(event_bus: EventBus, bank: EnvironmentBank)[source]
Initializes the EnvironmentAdapter and subscribes to relevant data keys.
- Parameters:
event_bus (EventBus) – The system bus for subscribing to intensity data.
bank (EnvironmentBank) – The bank instance providing access to FMOD events.
RainIntensity
- class RainIntensity(*values)[source]
Bases:
RangeLevelEnum-style class defining rain intensity ranges for FMOD parameter mapping.
This class categorizes raw rain intensity percentages (0-100) into four discrete levels. Each level is defined by a tuple representing the inclusive lower bound, the exclusive upper bound, and the corresponding FMOD parameter value used by the
EnvironmentAdapter.
TriggerAdapter
- class TriggerAdapter(event_bus: EventBus, rev_beep: ReverseBeep, bank: TriggerBank)[source]
Bases:
objectAdapter for managing discrete sound triggers based on simulation events.
This class handles one-shot audio events such as gear shifts, crashes, speed warnings, and the vehicle horn. It implements internal debouncing logic and state tracking (e.g., counters and flags) to ensure sounds are triggered correctly and only once per event, preventing double-triggering from the EventBus.
- reverse_beep
Engine for the rhythmic reverse warning sound.
- Type:
- bank
FMOD bank containing one-shot sound events.
- Type:
- honk_counter
Counter used to debounce horn events, ensuring the sound only plays once per key press.
- Type:
- GEAR_REVERSE = -1
Value CARLA Simulator returnes when reverse gear is selected
- Type:
GEAR_REVERSE (int) = -1
- SPEED_LIMIT = 100
Sets Value for speed warning if vehicle exceeds this limit
- Type:
SPEED_LIMIT (int) = 100
- HANDBRAKE_SPEED = 40
Minimum speed for the handbrake sound to play
- Type:
HANDBRAKE_SPEED (int) = 40
- __init__(event_bus: EventBus, rev_beep: ReverseBeep, bank: TriggerBank)[source]
Initializes the TriggerAdapter and subscribes to relevant data keys.
- Parameters:
event_bus (EventBus) – The system bus used for data subscription.
rev_beep (ReverseBeep) – The sound engine instance for reverse beeps.
bank (TriggerBank) – The bank containing one-shot audio instances.
- on_reverse(current_gear)[source]
Evaluates gear changes to trigger the reverse beep engine.
- Parameters:
current_gear (int) – The current gear value from the simulation.
- on_speed(speed=0)[source]
Triggers an overspeed warning sound if the speed limit is exceeded.
The trigger is reset only once the warning sound has finished playing.
- Parameters:
speed (float) – Current vehicle speed.
- on_crash(crash)[source]
Triggers the crash sound effect upon impact.
- Parameters:
crash – unused. Necesarry due to the event bus design
WindIntensity
- class WindIntensity(*values)[source]
Bases:
RangeLevelEnum-style class defining wind intensity ranges for FMOD parameter mapping.
This class categorizes raw wind intensity percentages (0-100) into three discrete levels. Each level is defined by a tuple containing the inclusive lower bound, the exclusive upper bound, and the corresponding FMOD parameter value used by the
EnvironmentAdapterto control ‘Windstaerke’.