Visuals - Alert Volume Controller

Control the volume level for each individual sound in openpilot.
This commit is contained in:
FrogAi 2024-05-11 12:31:55 -07:00
parent 573b834474
commit 5428fa4f72
1 changed files with 20 additions and 2 deletions

View File

@ -153,8 +153,14 @@ class Soundd:
sm.update(0)
if sm.updated['microphone'] and self.current_alert == AudibleAlert.none: # only update volume filter when not playing alert
self.spl_filter_weighted.update(sm["microphone"].soundPressureWeightedDb)
self.current_volume = self.calculate_volume(float(self.spl_filter_weighted.x))
if self.frogpilot_toggles.alert_volume_control:
self.current_volume = 0.0
else:
self.spl_filter_weighted.update(sm["microphone"].soundPressureWeightedDb)
self.current_volume = self.calculate_volume(float(self.spl_filter_weighted.x))
elif self.frogpilot_toggles.alert_volume_control and self.current_alert in self.volume_map:
self.current_volume = self.volume_map[self.current_alert] / 100.0
self.get_audible_alert(sm)
@ -168,6 +174,18 @@ class Soundd:
self.update_frogpilot_sounds()
def update_frogpilot_sounds(self):
self.volume_map = {
AudibleAlert.engage: self.frogpilot_toggles.engage_volume,
AudibleAlert.disengage: self.frogpilot_toggles.disengage_volume,
AudibleAlert.refuse: self.frogpilot_toggles.refuse_volume,
AudibleAlert.prompt: self.frogpilot_toggles.prompt_volume,
AudibleAlert.promptRepeat: self.frogpilot_toggles.prompt_volume,
AudibleAlert.promptDistracted: self.frogpilot_toggles.promptDistracted_volume,
AudibleAlert.warningSoft: self.frogpilot_toggles.warningSoft_volume,
AudibleAlert.warningImmediate: self.frogpilot_toggles.warningImmediate_volume,
}
def main():
s = Soundd()