From 6c2182c026dd0b0d161b1d36c1aa1215885ba163 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Thu, 2 Dec 2021 00:28:25 -0800 Subject: [PATCH] Newer sounds (#23091) * new prompt sound * padding * prompt distracted * debug * fix spelling * lower min volume * better volume at low speeds * revert debug * revert that * fix tests * update refs Co-authored-by: Comma Device old-commit-hash: 3b367e68728c29eea057d99f3948d64ed6cbfa92 --- cereal | 2 +- selfdrive/assets/sounds/prompt.wav | 4 ++-- selfdrive/assets/sounds/prompt_distracted.wav | 3 +++ selfdrive/assets/sounds/refuse.wav | 4 ++-- selfdrive/controls/lib/events.py | 4 ++-- selfdrive/hardware/tici/hardware.h | 2 +- selfdrive/test/process_replay/ref_commit | 2 +- selfdrive/ui/soundd/sound.cc | 2 +- selfdrive/ui/soundd/sound.h | 1 + selfdrive/ui/tests/test_soundd.py | 5 +++-- 10 files changed, 17 insertions(+), 12 deletions(-) create mode 100644 selfdrive/assets/sounds/prompt_distracted.wav diff --git a/cereal b/cereal index 9ce45916c6..596d34e77a 160000 --- a/cereal +++ b/cereal @@ -1 +1 @@ -Subproject commit 9ce45916c6c27e8cfbbe2aa6b796fac41eeeba00 +Subproject commit 596d34e77ac380f965f0f5f96f59d622c9e814b1 diff --git a/selfdrive/assets/sounds/prompt.wav b/selfdrive/assets/sounds/prompt.wav index 3f5509bdd0..2b9ab56deb 100644 --- a/selfdrive/assets/sounds/prompt.wav +++ b/selfdrive/assets/sounds/prompt.wav @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3007836472db496398397eb409778b2e0018cce66033afc791b108e5202ad371 -size 127172 +oid sha256:b9e126f394f2412a6edda83fa739d472e4bb921300e5eeecb2e3e122cd4e8f8d +size 152148 diff --git a/selfdrive/assets/sounds/prompt_distracted.wav b/selfdrive/assets/sounds/prompt_distracted.wav new file mode 100644 index 0000000000..69426bbc2a --- /dev/null +++ b/selfdrive/assets/sounds/prompt_distracted.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:91d9cec33aca78464627855696c248d042417da1d8ff6f6e947c35f003e7a334 +size 64702 diff --git a/selfdrive/assets/sounds/refuse.wav b/selfdrive/assets/sounds/refuse.wav index 5c00b291ca..37a9fccd11 100644 --- a/selfdrive/assets/sounds/refuse.wav +++ b/selfdrive/assets/sounds/refuse.wav @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:079121f2e0272117afc21074d79602c9939a1a4f0c19ca0ed82547d7d9537c22 -size 209238 +oid sha256:b6c55e0295392a52a9432e0a4e383fc548deca610b3c8b11e2ee8a1c5e1e72d0 +size 75610 diff --git a/selfdrive/controls/lib/events.py b/selfdrive/controls/lib/events.py index 9107f5fe2e..d858dbfcbc 100644 --- a/selfdrive/controls/lib/events.py +++ b/selfdrive/controls/lib/events.py @@ -375,7 +375,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo "KEEP EYES ON ROAD", "Driver Distracted", AlertStatus.userPrompt, AlertSize.mid, - Priority.MID, VisualAlert.steerRequired, AudibleAlert.prompt, .1), + Priority.MID, VisualAlert.steerRequired, AudibleAlert.promptDistracted, .1), }, EventName.driverDistracted: { @@ -399,7 +399,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo "TOUCH STEERING WHEEL", "Driver Unresponsive", AlertStatus.userPrompt, AlertSize.mid, - Priority.MID, VisualAlert.steerRequired, AudibleAlert.prompt, .1), + Priority.MID, VisualAlert.steerRequired, AudibleAlert.promptDistracted, .1), }, EventName.driverUnresponsive: { diff --git a/selfdrive/hardware/tici/hardware.h b/selfdrive/hardware/tici/hardware.h index 3d025775ae..549170412d 100644 --- a/selfdrive/hardware/tici/hardware.h +++ b/selfdrive/hardware/tici/hardware.h @@ -10,7 +10,7 @@ class HardwareTici : public HardwareNone { public: static constexpr float MAX_VOLUME = 0.9; - static constexpr float MIN_VOLUME = 0.3; + static constexpr float MIN_VOLUME = 0.15; static bool TICI() { return true; } static std::string get_os_version() { return "AGNOS " + util::read_file("/VERSION"); diff --git a/selfdrive/test/process_replay/ref_commit b/selfdrive/test/process_replay/ref_commit index 95bf325d7c..2996331fe4 100644 --- a/selfdrive/test/process_replay/ref_commit +++ b/selfdrive/test/process_replay/ref_commit @@ -1 +1 @@ -6da38baefb2741902f8b10fbf2b5e64fd15ced1f \ No newline at end of file +e15e446543ea74cce4864f07902a39bdb8b10688 \ No newline at end of file diff --git a/selfdrive/ui/soundd/sound.cc b/selfdrive/ui/soundd/sound.cc index 7ce758d0ad..f42edd308e 100644 --- a/selfdrive/ui/soundd/sound.cc +++ b/selfdrive/ui/soundd/sound.cc @@ -47,7 +47,7 @@ void Sound::update() { // scale volume with speed if (sm.updated("carState")) { - float volume = std::clamp(sm["carState"].getCarState().getVEgo() / 29.f, 0.1f, 1.0f); + float volume = util::map_val(sm["carState"].getCarState().getVEgo(), 11.f, 29.f, 0.f, 1.0f); volume = QAudio::convertVolume(volume, QAudio::LogarithmicVolumeScale, QAudio::LinearVolumeScale); volume = util::map_val(volume, 0.f, 1.f, Hardware::MIN_VOLUME, Hardware::MAX_VOLUME); for (auto &[s, loops] : sounds) { diff --git a/selfdrive/ui/soundd/sound.h b/selfdrive/ui/soundd/sound.h index 6215da6ac0..0990591093 100644 --- a/selfdrive/ui/soundd/sound.h +++ b/selfdrive/ui/soundd/sound.h @@ -13,6 +13,7 @@ const std::tuple sound_list[] = { {AudibleAlert::PROMPT, "prompt.wav", 0}, {AudibleAlert::PROMPT_REPEAT, "prompt.wav", QSoundEffect::Infinite}, + {AudibleAlert::PROMPT_DISTRACTED, "prompt_distracted.wav", 0}, {AudibleAlert::WARNING_SOFT, "warning_soft.wav", QSoundEffect::Infinite}, {AudibleAlert::WARNING_IMMEDIATE, "warning_immediate.wav", 10}, diff --git a/selfdrive/ui/tests/test_soundd.py b/selfdrive/ui/tests/test_soundd.py index 5be16348c7..df795c4c88 100755 --- a/selfdrive/ui/tests/test_soundd.py +++ b/selfdrive/ui/tests/test_soundd.py @@ -17,9 +17,10 @@ SOUNDS = { AudibleAlert.none: 0, AudibleAlert.engage: 197, AudibleAlert.disengage: 230, - AudibleAlert.refuse: 223, + AudibleAlert.refuse: 189, AudibleAlert.prompt: 217, AudibleAlert.promptRepeat: 475, + AudibleAlert.promptDistracted: 187, AudibleAlert.warningSoft: 477, AudibleAlert.warningImmediate: 468, } @@ -39,7 +40,7 @@ class TestSoundd(unittest.TestCase): pm = messaging.PubMaster(['deviceState', 'controlsState']) # make sure they're all defined - alert_sounds = {v: k for k, v in car.CarControl.HUDControl.AudibleAlert.schema.enumerants.items() if not k.endswith('DEPRECATED')} + alert_sounds = {v: k for k, v in car.CarControl.HUDControl.AudibleAlert.schema.enumerants.items()} diff = set(SOUNDS.keys()).symmetric_difference(alert_sounds.keys()) assert len(diff) == 0, f"not all sounds defined in test: {diff}"