From e31f0045939eacc93a28d0a7bc6baeed620f2992 Mon Sep 17 00:00:00 2001 From: robbederks Date: Mon, 26 Jul 2021 16:28:41 -0700 Subject: [PATCH] Tici sound improvements (#21722) * tune amp config and add EQed sounds * fix release files * bump up max * cleanup * more volume Co-authored-by: Adeeb Shihadeh old-commit-hash: cebddc94c4903d04463ceb4c991ca813ea2a45a0 --- release/files_tici | 1 + selfdrive/assets/sounds_tici/disengaged.wav | 3 +++ selfdrive/assets/sounds_tici/engaged.wav | 3 +++ selfdrive/assets/sounds_tici/error.wav | 3 +++ selfdrive/assets/sounds_tici/warning_1.wav | 3 +++ selfdrive/assets/sounds_tici/warning_2.wav | 3 +++ .../assets/sounds_tici/warning_repeat.wav | 3 +++ selfdrive/hardware/tici/amplifier.py | 13 ++++++++----- selfdrive/hardware/tici/hardware.h | 2 +- selfdrive/ui/soundd.cc | 18 ++++++++++-------- 10 files changed, 38 insertions(+), 14 deletions(-) create mode 100644 selfdrive/assets/sounds_tici/disengaged.wav create mode 100644 selfdrive/assets/sounds_tici/engaged.wav create mode 100644 selfdrive/assets/sounds_tici/error.wav create mode 100644 selfdrive/assets/sounds_tici/warning_1.wav create mode 100644 selfdrive/assets/sounds_tici/warning_2.wav create mode 100644 selfdrive/assets/sounds_tici/warning_repeat.wav diff --git a/release/files_tici b/release/files_tici index bf4e3afb58..69d4b121cf 100644 --- a/release/files_tici +++ b/release/files_tici @@ -6,6 +6,7 @@ selfdrive/timezoned.py selfdrive/assets/navigation/* selfdrive/assets/training_wide/* +selfdrive/assets/sounds_tici/* selfdrive/camerad/cameras/camera_qcom2.cc selfdrive/camerad/cameras/camera_qcom2.h diff --git a/selfdrive/assets/sounds_tici/disengaged.wav b/selfdrive/assets/sounds_tici/disengaged.wav new file mode 100644 index 0000000000..383b504d29 --- /dev/null +++ b/selfdrive/assets/sounds_tici/disengaged.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c6ef7f760160e1c5d9ec7a9b2cd46a79866acfdd3dbba6a8fd49051490b37aa7 +size 50316 diff --git a/selfdrive/assets/sounds_tici/engaged.wav b/selfdrive/assets/sounds_tici/engaged.wav new file mode 100644 index 0000000000..9dabcb3bb7 --- /dev/null +++ b/selfdrive/assets/sounds_tici/engaged.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5429a1633695013bcd69a6d8e529e4ac95a9e0e4c50e8ae0027b06003ed662e2 +size 50288 diff --git a/selfdrive/assets/sounds_tici/error.wav b/selfdrive/assets/sounds_tici/error.wav new file mode 100644 index 0000000000..6149e9af76 --- /dev/null +++ b/selfdrive/assets/sounds_tici/error.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1c31dab68d1498b84912c6e424fd783d054942242ca40a5dfb311edd148b744a +size 50304 diff --git a/selfdrive/assets/sounds_tici/warning_1.wav b/selfdrive/assets/sounds_tici/warning_1.wav new file mode 100644 index 0000000000..d8bd9056d4 --- /dev/null +++ b/selfdrive/assets/sounds_tici/warning_1.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:209c3328f1eb924917f78438c2faf43d9c23ae7f39b7ba6105b7ca509e279e15 +size 31094 diff --git a/selfdrive/assets/sounds_tici/warning_2.wav b/selfdrive/assets/sounds_tici/warning_2.wav new file mode 100644 index 0000000000..df757a043c --- /dev/null +++ b/selfdrive/assets/sounds_tici/warning_2.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8687abcc94d4bb30dd18be37ed03e2a224cc6ddc227c1e8c0c3ba9bdfc85b302 +size 134392 diff --git a/selfdrive/assets/sounds_tici/warning_repeat.wav b/selfdrive/assets/sounds_tici/warning_repeat.wav new file mode 100644 index 0000000000..7726f7728f --- /dev/null +++ b/selfdrive/assets/sounds_tici/warning_repeat.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:92a69b8847a51b7d60af4447f930b50e343f7f04316a765d0a13ae4d0152160f +size 70114 diff --git a/selfdrive/hardware/tici/amplifier.py b/selfdrive/hardware/tici/amplifier.py index b0c201c078..99b6d0598a 100755 --- a/selfdrive/hardware/tici/amplifier.py +++ b/selfdrive/hardware/tici/amplifier.py @@ -31,7 +31,7 @@ BASE_CONFIG = [ AmpConfig("Enable PLL2", 0b1, 0x1A, 7, 0b10000000), AmpConfig("DAI1: I2S mode", 0b00100, 0x14, 2, 0b01111100), AmpConfig("DAI2: I2S mode", 0b00100, 0x1C, 2, 0b01111100), - AmpConfig("Right speaker output volume", 0x1F, 0x3E, 0, 0b00011111), + AmpConfig("Right speaker output volume", 0x1a, 0x3E, 0, 0b00011111), AmpConfig("DAI1 Passband filtering: music mode", 0b1, 0x18, 7, 0b10000000), AmpConfig("DAI1 voice mode gain (DV1G)", 0b00, 0x2F, 4, 0b00110000), AmpConfig("DAI1 attenuation (DV1)", 0x0, 0x2F, 0, 0b00001111), @@ -41,8 +41,8 @@ BASE_CONFIG = [ AmpConfig("ALC enable", 0b0, 0x43, 7, 0b10000000), AmpConfig("ALC/excursion limiter release time", 0b101, 0x43, 4, 0b01110000), AmpConfig("DAI1 EQ enable", 0b0, 0x49, 0, 0b00000001), - AmpConfig("DAI2 EQ enable", 0b1, 0x49, 1, 0b00000010), - AmpConfig("DAI2 EQ clip detection disabled", 0b0, 0x32, 4, 0b00010000), + AmpConfig("DAI2 EQ enable", 0b0, 0x49, 1, 0b00000010), + AmpConfig("DAI2 EQ clip detection disabled", 0b1, 0x32, 4, 0b00010000), AmpConfig("DAI2 EQ attenuation", 0x5, 0x32, 0, 0b00001111), AmpConfig("Excursion limiter upper corner freq", 0b100, 0x41, 4, 0b01110000), AmpConfig("Excursion limiter lower corner freq", 0b00, 0x41, 0, 0b00000011), @@ -57,6 +57,9 @@ BASE_CONFIG = [ AmpConfig("DAI2 audio port selector", 0b01, 0x1E, 6, 0b11000000), AmpConfig("Enable left digital microphone", 0b1, 0x48, 5, 0b00100000), AmpConfig("Enable right digital microphone", 0b1, 0x48, 4, 0b00010000), + AmpConfig("Enhanced volume smoothing disabled", 0b0, 0x49, 7, 0b10000000), + AmpConfig("Volume adjustment smoothing disabled", 0b0, 0x49, 6, 0b01000000), + AmpConfig("Zero-crossing detection disabled", 0b0, 0x49, 5, 0b00100000), ] BASE_CONFIG += configs_from_eq_params(0x84, EQParams(0x65C4, 0xC07C, 0x3D66, 0x07D9, 0x120F)) @@ -88,11 +91,11 @@ class Amplifier: self.set_config(AmpConfig("Global shutdown", 0b0 if amp_disabled else 0b1, 0x51, 7, 0b10000000)) def initialize_configuration(self): + self.set_global_shutdown(amp_disabled=True) + for config in BASE_CONFIG: self.set_config(config) - # Re-init amp - self.set_global_shutdown(amp_disabled=True) self.set_global_shutdown(amp_disabled=False) diff --git a/selfdrive/hardware/tici/hardware.h b/selfdrive/hardware/tici/hardware.h index 0ff73b840f..1626cda567 100644 --- a/selfdrive/hardware/tici/hardware.h +++ b/selfdrive/hardware/tici/hardware.h @@ -9,7 +9,7 @@ class HardwareTici : public HardwareNone { public: - static constexpr float MAX_VOLUME = 0.5; + static constexpr float MAX_VOLUME = 1.0; static constexpr float MIN_VOLUME = 0.4; static bool TICI() { return true; } static std::string get_os_version() { diff --git a/selfdrive/ui/soundd.cc b/selfdrive/ui/soundd.cc index 33fe57b9ae..318449930d 100644 --- a/selfdrive/ui/soundd.cc +++ b/selfdrive/ui/soundd.cc @@ -17,15 +17,17 @@ class Sound : public QObject { public: explicit Sound(QObject *parent = 0) { + // TODO: merge again and add EQ in the amp config + const QString sound_asset_path = Hardware::TICI ? "../assets/sounds_tici/" : "../assets/sounds/"; std::tuple sound_list[] = { - {AudibleAlert::CHIME_DISENGAGE, "../assets/sounds/disengaged.wav", false}, - {AudibleAlert::CHIME_ENGAGE, "../assets/sounds/engaged.wav", false}, - {AudibleAlert::CHIME_WARNING1, "../assets/sounds/warning_1.wav", false}, - {AudibleAlert::CHIME_WARNING2, "../assets/sounds/warning_2.wav", false}, - {AudibleAlert::CHIME_WARNING2_REPEAT, "../assets/sounds/warning_2.wav", true}, - {AudibleAlert::CHIME_WARNING_REPEAT, "../assets/sounds/warning_repeat.wav", true}, - {AudibleAlert::CHIME_ERROR, "../assets/sounds/error.wav", false}, - {AudibleAlert::CHIME_PROMPT, "../assets/sounds/error.wav", false} + {AudibleAlert::CHIME_DISENGAGE, sound_asset_path + "disengaged.wav", false}, + {AudibleAlert::CHIME_ENGAGE, sound_asset_path + "engaged.wav", false}, + {AudibleAlert::CHIME_WARNING1, sound_asset_path + "warning_1.wav", false}, + {AudibleAlert::CHIME_WARNING2, sound_asset_path + "warning_2.wav", false}, + {AudibleAlert::CHIME_WARNING2_REPEAT, sound_asset_path + "warning_2.wav", true}, + {AudibleAlert::CHIME_WARNING_REPEAT, sound_asset_path + "warning_repeat.wav", true}, + {AudibleAlert::CHIME_ERROR, sound_asset_path + "error.wav", false}, + {AudibleAlert::CHIME_PROMPT, sound_asset_path + "error.wav", false} }; for (auto &[alert, fn, loops] : sound_list) { sounds[alert].first.setSource(QUrl::fromLocalFile(fn));