diff --git a/openpilot/selfdrive/ui/translations/app.pot b/openpilot/selfdrive/ui/translations/app.pot index 61495377f9..c3f1016cf9 100644 --- a/openpilot/selfdrive/ui/translations/app.pot +++ b/openpilot/selfdrive/ui/translations/app.pot @@ -23499,6 +23499,10 @@ msgstr "" msgid "BMW M3" msgstr "" +#: openpilot/starpilot/engine_sound/profiles.py +msgid "BMW M3 Deep" +msgstr "" + #: openpilot/starpilot/engine_sound/profiles.py msgid "BMW M52" msgstr "" @@ -23520,7 +23524,11 @@ msgid "Jaguar F-Type" msgstr "" #: openpilot/starpilot/engine_sound/profiles.py -msgid "Nissan Super GT" +msgid "Nissan Super GT1" +msgstr "" + +#: openpilot/starpilot/engine_sound/profiles.py +msgid "Nissan Super GT2" msgstr "" #: openpilot/starpilot/engine_sound/profiles.py diff --git a/openpilot/selfdrive/ui/translations/app_de.po b/openpilot/selfdrive/ui/translations/app_de.po index 4b7a35ae2c..05dca77a8a 100644 --- a/openpilot/selfdrive/ui/translations/app_de.po +++ b/openpilot/selfdrive/ui/translations/app_de.po @@ -23518,6 +23518,10 @@ msgstr "Spielt über die Fahrzeuglautsprecher einen simulierten Motor ab, der de msgid "BMW M3" msgstr "BMW M3" +#: openpilot/starpilot/engine_sound/profiles.py +msgid "BMW M3 Deep" +msgstr "BMW M3 Deep" + #: openpilot/starpilot/engine_sound/profiles.py msgid "BMW M52" msgstr "BMW M52" @@ -23539,8 +23543,12 @@ msgid "Jaguar F-Type" msgstr "Jaguar F-Type" #: openpilot/starpilot/engine_sound/profiles.py -msgid "Nissan Super GT" -msgstr "Nissan Super GT" +msgid "Nissan Super GT1" +msgstr "Nissan Super GT1" + +#: openpilot/starpilot/engine_sound/profiles.py +msgid "Nissan Super GT2" +msgstr "Nissan Super GT2" #: openpilot/starpilot/engine_sound/profiles.py msgid "Supra Turbo" diff --git a/openpilot/selfdrive/ui/translations/app_es.po b/openpilot/selfdrive/ui/translations/app_es.po index 098b61a360..d417726742 100644 --- a/openpilot/selfdrive/ui/translations/app_es.po +++ b/openpilot/selfdrive/ui/translations/app_es.po @@ -23518,6 +23518,10 @@ msgstr "Reproduce un motor simulado en los altavoces del coche que sigue el peda msgid "BMW M3" msgstr "BMW M3" +#: openpilot/starpilot/engine_sound/profiles.py +msgid "BMW M3 Deep" +msgstr "BMW M3 Deep" + #: openpilot/starpilot/engine_sound/profiles.py msgid "BMW M52" msgstr "BMW M52" @@ -23539,8 +23543,12 @@ msgid "Jaguar F-Type" msgstr "Jaguar F-Type" #: openpilot/starpilot/engine_sound/profiles.py -msgid "Nissan Super GT" -msgstr "Nissan Super GT" +msgid "Nissan Super GT1" +msgstr "Nissan Super GT1" + +#: openpilot/starpilot/engine_sound/profiles.py +msgid "Nissan Super GT2" +msgstr "Nissan Super GT2" #: openpilot/starpilot/engine_sound/profiles.py msgid "Supra Turbo" diff --git a/openpilot/selfdrive/ui/translations/app_fr.po b/openpilot/selfdrive/ui/translations/app_fr.po index 9832544694..d86c75cc2d 100644 --- a/openpilot/selfdrive/ui/translations/app_fr.po +++ b/openpilot/selfdrive/ui/translations/app_fr.po @@ -23518,6 +23518,10 @@ msgstr "Diffuse un moteur simulé sur les haut-parleurs de la voiture qui suit l msgid "BMW M3" msgstr "BMW M3" +#: openpilot/starpilot/engine_sound/profiles.py +msgid "BMW M3 Deep" +msgstr "BMW M3 Deep" + #: openpilot/starpilot/engine_sound/profiles.py msgid "BMW M52" msgstr "BMW M52" @@ -23539,8 +23543,12 @@ msgid "Jaguar F-Type" msgstr "Jaguar F-Type" #: openpilot/starpilot/engine_sound/profiles.py -msgid "Nissan Super GT" -msgstr "Nissan Super GT" +msgid "Nissan Super GT1" +msgstr "Nissan Super GT1" + +#: openpilot/starpilot/engine_sound/profiles.py +msgid "Nissan Super GT2" +msgstr "Nissan Super GT2" #: openpilot/starpilot/engine_sound/profiles.py msgid "Supra Turbo" diff --git a/openpilot/selfdrive/ui/translations/app_ja.po b/openpilot/selfdrive/ui/translations/app_ja.po index 30ab75f16a..dd1a9b38e5 100644 --- a/openpilot/selfdrive/ui/translations/app_ja.po +++ b/openpilot/selfdrive/ui/translations/app_ja.po @@ -23514,6 +23514,10 @@ msgstr "アクセルペダルに合わせて、車のスピーカーで疑似エ msgid "BMW M3" msgstr "BMW M3" +#: openpilot/starpilot/engine_sound/profiles.py +msgid "BMW M3 Deep" +msgstr "BMW M3 Deep" + #: openpilot/starpilot/engine_sound/profiles.py msgid "BMW M52" msgstr "BMW M52" @@ -23535,8 +23539,12 @@ msgid "Jaguar F-Type" msgstr "Jaguar F-Type" #: openpilot/starpilot/engine_sound/profiles.py -msgid "Nissan Super GT" -msgstr "Nissan Super GT" +msgid "Nissan Super GT1" +msgstr "Nissan Super GT1" + +#: openpilot/starpilot/engine_sound/profiles.py +msgid "Nissan Super GT2" +msgstr "Nissan Super GT2" #: openpilot/starpilot/engine_sound/profiles.py msgid "Supra Turbo" diff --git a/openpilot/selfdrive/ui/translations/app_ko.po b/openpilot/selfdrive/ui/translations/app_ko.po index 8540b428ce..cb78fa5686 100644 --- a/openpilot/selfdrive/ui/translations/app_ko.po +++ b/openpilot/selfdrive/ui/translations/app_ko.po @@ -23514,6 +23514,10 @@ msgstr "가속 페달에 맞춰 차량 스피커로 가상 엔진 소리를 재 msgid "BMW M3" msgstr "BMW M3" +#: openpilot/starpilot/engine_sound/profiles.py +msgid "BMW M3 Deep" +msgstr "BMW M3 Deep" + #: openpilot/starpilot/engine_sound/profiles.py msgid "BMW M52" msgstr "BMW M52" @@ -23535,8 +23539,12 @@ msgid "Jaguar F-Type" msgstr "Jaguar F-Type" #: openpilot/starpilot/engine_sound/profiles.py -msgid "Nissan Super GT" -msgstr "Nissan Super GT" +msgid "Nissan Super GT1" +msgstr "Nissan Super GT1" + +#: openpilot/starpilot/engine_sound/profiles.py +msgid "Nissan Super GT2" +msgstr "Nissan Super GT2" #: openpilot/starpilot/engine_sound/profiles.py msgid "Supra Turbo" diff --git a/openpilot/selfdrive/ui/translations/app_vi.po b/openpilot/selfdrive/ui/translations/app_vi.po index bbde872156..93fbfa8ccc 100644 --- a/openpilot/selfdrive/ui/translations/app_vi.po +++ b/openpilot/selfdrive/ui/translations/app_vi.po @@ -23514,6 +23514,10 @@ msgstr "Phát âm thanh động cơ mô phỏng trên loa xe theo bàn đạp ga msgid "BMW M3" msgstr "BMW M3" +#: openpilot/starpilot/engine_sound/profiles.py +msgid "BMW M3 Deep" +msgstr "BMW M3 Deep" + #: openpilot/starpilot/engine_sound/profiles.py msgid "BMW M52" msgstr "BMW M52" @@ -23535,8 +23539,12 @@ msgid "Jaguar F-Type" msgstr "Jaguar F-Type" #: openpilot/starpilot/engine_sound/profiles.py -msgid "Nissan Super GT" -msgstr "Nissan Super GT" +msgid "Nissan Super GT1" +msgstr "Nissan Super GT1" + +#: openpilot/starpilot/engine_sound/profiles.py +msgid "Nissan Super GT2" +msgstr "Nissan Super GT2" #: openpilot/starpilot/engine_sound/profiles.py msgid "Supra Turbo" diff --git a/openpilot/starpilot/engine_sound/banks/LICENSE b/openpilot/starpilot/engine_sound/banks/LICENSE index 344643a5d1..c51116591d 100644 --- a/openpilot/starpilot/engine_sound/banks/LICENSE +++ b/openpilot/starpilot/engine_sound/banks/LICENSE @@ -10,6 +10,11 @@ commit 85f7c3b959a908ed5232ede4f1a4ac7eafe6b630), recorded with tools/esrec: lfa assets/engines/atg-video-2/10_lfa_v10.mr supra_turbo assets/engines/atg-video-2/03_2jz.mr + bmw_m3 the bmw_m52 bank lowered again with tools/lower_bank.py --pitch 1.15 --bass 3 --treble -3 --off-mix 0 + --off-mid 0 + bmw_m3_deep the bmw_m52 bank lowered again with tools/lower_bank.py --pitch 1.5 --bass 8 --treble -9 --off-mix 0 + --off-mid 0 + From recordings of real cars supplied for this project, built with tools/bank_from_recording.py: hellcat hellcat.wav: --cylinders 8 --anchor 14 700 --idle 10.5-17.5 --on 25-94 --off 94-119, @@ -21,7 +26,17 @@ From recordings of real cars supplied for this project, built with tools/bank_fr comb (whether that is rpm/120 or rpm/60 cannot be told from the recording; the profile uses the same units, so the pitch is right either way), pinned with --anchor at every 0.25 s point whose comb measured clearly, --idle 18.6-19.6 --on 9-17 19.7-65 79.4-88.2 --off 9-17 65-71 74.2-76 79.4-88.2, - not equalised + then the recording's wind hiss lowered 18 dB between the engine orders (fading in from 500 Hz, full + from 1 kHz up) and equalised with tools/lower_bank.py --pitch 1.0 --bass 4 --treble -8 --off-mix 0 + --off-mid 0 + nissan_super_gt2 the same loops, hiss lowered the same way, equalised with tools/lower_bank.py --pitch 1.3 --bass 6 + --treble -10 --off-mix 0 --off-mid 0 + +turbo/blowoff.wav is the blow-off flutter from 11.89-14.45 s of flutter.wav, a recording supplied for this project, +with the recording's own engine taken out from under it (high-passed at 180 Hz and its steady spectrum subtracted). + +pops/burble_grains.wav is the 62 pops of the two overrun bursts at 6.35-7.5 s and 9.85-11.3 s of burbles.wav, a +recording supplied for this project: 52 ms from 2 ms before each pop, band-passed 100 Hz-20 kHz, each normalised. engine-sim is distributed under the following license: diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3/bank.json b/openpilot/starpilot/engine_sound/banks/bmw_m3/bank.json new file mode 100644 index 0000000000..5e0e3b24a6 --- /dev/null +++ b/openpilot/starpilot/engine_sound/banks/bmw_m3/bank.json @@ -0,0 +1,114 @@ +{ + "version": 1, + "source": "engine-sim engines/bmw/M52B28.mr", + "layers": { + "on": [ + { + "rpm": 1208, + "file": "on_1208.wav" + }, + { + "rpm": 2070, + "file": "on_2070.wav" + }, + { + "rpm": 2932, + "file": "on_2932.wav" + }, + { + "rpm": 3795, + "file": "on_3795.wav" + }, + { + "rpm": 4658, + "file": "on_4658.wav" + }, + { + "rpm": 5520, + "file": "on_5520.wav" + }, + { + "rpm": 6382, + "file": "on_6382.wav" + }, + { + "rpm": 7245, + "file": "on_7245.wav" + }, + { + "rpm": 8107, + "file": "on_8107.wav" + }, + { + "rpm": 8970, + "file": "on_8970.wav" + }, + { + "rpm": 9832, + "file": "on_9832.wav" + }, + { + "rpm": 10695, + "file": "on_10695.wav" + }, + { + "rpm": 11558, + "file": "on_11558.wav" + } + ], + "off": [ + { + "rpm": 1208, + "file": "off_1208.wav" + }, + { + "rpm": 2070, + "file": "off_2070.wav" + }, + { + "rpm": 2932, + "file": "off_2932.wav" + }, + { + "rpm": 3795, + "file": "off_3795.wav" + }, + { + "rpm": 4658, + "file": "off_4658.wav" + }, + { + "rpm": 5520, + "file": "off_5520.wav" + }, + { + "rpm": 6382, + "file": "off_6382.wav" + }, + { + "rpm": 7245, + "file": "off_7245.wav" + }, + { + "rpm": 8107, + "file": "off_8107.wav" + }, + { + "rpm": 8970, + "file": "off_8970.wav" + }, + { + "rpm": 9832, + "file": "off_9832.wav" + }, + { + "rpm": 10695, + "file": "off_10695.wav" + }, + { + "rpm": 11558, + "file": "off_11558.wav" + } + ] + } +} diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3/off_10695.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3/off_10695.wav new file mode 100644 index 0000000000..b5dfa03191 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3/off_10695.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3/off_11558.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3/off_11558.wav new file mode 100644 index 0000000000..5ab2e5c0bc Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3/off_11558.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3/off_1208.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3/off_1208.wav new file mode 100644 index 0000000000..f177275d11 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3/off_1208.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3/off_2070.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3/off_2070.wav new file mode 100644 index 0000000000..783f344387 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3/off_2070.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3/off_2932.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3/off_2932.wav new file mode 100644 index 0000000000..e60ba90d3c Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3/off_2932.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3/off_3795.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3/off_3795.wav new file mode 100644 index 0000000000..439eca475e Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3/off_3795.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3/off_4658.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3/off_4658.wav new file mode 100644 index 0000000000..5c98a1f0b9 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3/off_4658.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3/off_5520.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3/off_5520.wav new file mode 100644 index 0000000000..68d5a843f9 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3/off_5520.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3/off_6382.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3/off_6382.wav new file mode 100644 index 0000000000..1e2a5b2653 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3/off_6382.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3/off_7245.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3/off_7245.wav new file mode 100644 index 0000000000..c0d703b97b Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3/off_7245.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3/off_8107.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3/off_8107.wav new file mode 100644 index 0000000000..e4b1fefe32 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3/off_8107.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3/off_8970.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3/off_8970.wav new file mode 100644 index 0000000000..4daeb60cb6 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3/off_8970.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3/off_9832.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3/off_9832.wav new file mode 100644 index 0000000000..fd5bf3d778 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3/off_9832.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3/on_10695.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3/on_10695.wav new file mode 100644 index 0000000000..8a6dd421a5 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3/on_10695.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3/on_11558.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3/on_11558.wav new file mode 100644 index 0000000000..26ae981c1d Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3/on_11558.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3/on_1208.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3/on_1208.wav new file mode 100644 index 0000000000..1d9d1b46d5 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3/on_1208.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3/on_2070.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3/on_2070.wav new file mode 100644 index 0000000000..a93254b75e Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3/on_2070.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3/on_2932.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3/on_2932.wav new file mode 100644 index 0000000000..410d22417a Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3/on_2932.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3/on_3795.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3/on_3795.wav new file mode 100644 index 0000000000..94c247f737 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3/on_3795.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3/on_4658.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3/on_4658.wav new file mode 100644 index 0000000000..441fb5e507 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3/on_4658.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3/on_5520.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3/on_5520.wav new file mode 100644 index 0000000000..2dceda1a71 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3/on_5520.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3/on_6382.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3/on_6382.wav new file mode 100644 index 0000000000..37f657528b Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3/on_6382.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3/on_7245.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3/on_7245.wav new file mode 100644 index 0000000000..be1aa9786a Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3/on_7245.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3/on_8107.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3/on_8107.wav new file mode 100644 index 0000000000..d46d72d024 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3/on_8107.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3/on_8970.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3/on_8970.wav new file mode 100644 index 0000000000..c304c6c1fe Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3/on_8970.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3/on_9832.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3/on_9832.wav new file mode 100644 index 0000000000..6f2b69f557 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3/on_9832.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/bank.json b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/bank.json new file mode 100644 index 0000000000..8e573d0075 --- /dev/null +++ b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/bank.json @@ -0,0 +1,114 @@ +{ + "version": 1, + "source": "engine-sim engines/bmw/M52B28.mr", + "layers": { + "on": [ + { + "rpm": 1575, + "file": "on_1575.wav" + }, + { + "rpm": 2700, + "file": "on_2700.wav" + }, + { + "rpm": 3825, + "file": "on_3825.wav" + }, + { + "rpm": 4950, + "file": "on_4950.wav" + }, + { + "rpm": 6075, + "file": "on_6075.wav" + }, + { + "rpm": 7200, + "file": "on_7200.wav" + }, + { + "rpm": 8325, + "file": "on_8325.wav" + }, + { + "rpm": 9450, + "file": "on_9450.wav" + }, + { + "rpm": 10575, + "file": "on_10575.wav" + }, + { + "rpm": 11700, + "file": "on_11700.wav" + }, + { + "rpm": 12825, + "file": "on_12825.wav" + }, + { + "rpm": 13950, + "file": "on_13950.wav" + }, + { + "rpm": 15075, + "file": "on_15075.wav" + } + ], + "off": [ + { + "rpm": 1575, + "file": "off_1575.wav" + }, + { + "rpm": 2700, + "file": "off_2700.wav" + }, + { + "rpm": 3825, + "file": "off_3825.wav" + }, + { + "rpm": 4950, + "file": "off_4950.wav" + }, + { + "rpm": 6075, + "file": "off_6075.wav" + }, + { + "rpm": 7200, + "file": "off_7200.wav" + }, + { + "rpm": 8325, + "file": "off_8325.wav" + }, + { + "rpm": 9450, + "file": "off_9450.wav" + }, + { + "rpm": 10575, + "file": "off_10575.wav" + }, + { + "rpm": 11700, + "file": "off_11700.wav" + }, + { + "rpm": 12825, + "file": "off_12825.wav" + }, + { + "rpm": 13950, + "file": "off_13950.wav" + }, + { + "rpm": 15075, + "file": "off_15075.wav" + } + ] + } +} diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/off_10575.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/off_10575.wav new file mode 100644 index 0000000000..04c25c0781 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/off_10575.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/off_11700.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/off_11700.wav new file mode 100644 index 0000000000..679f91ab75 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/off_11700.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/off_12825.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/off_12825.wav new file mode 100644 index 0000000000..36249b1acd Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/off_12825.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/off_13950.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/off_13950.wav new file mode 100644 index 0000000000..7b9722aadf Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/off_13950.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/off_15075.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/off_15075.wav new file mode 100644 index 0000000000..0d1b52ffb6 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/off_15075.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/off_1575.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/off_1575.wav new file mode 100644 index 0000000000..d06308c9a7 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/off_1575.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/off_2700.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/off_2700.wav new file mode 100644 index 0000000000..b2c517f8ac Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/off_2700.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/off_3825.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/off_3825.wav new file mode 100644 index 0000000000..7a09466c60 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/off_3825.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/off_4950.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/off_4950.wav new file mode 100644 index 0000000000..3bf34cb401 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/off_4950.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/off_6075.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/off_6075.wav new file mode 100644 index 0000000000..f6e51163c9 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/off_6075.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/off_7200.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/off_7200.wav new file mode 100644 index 0000000000..6e489e8e79 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/off_7200.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/off_8325.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/off_8325.wav new file mode 100644 index 0000000000..0af6087c58 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/off_8325.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/off_9450.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/off_9450.wav new file mode 100644 index 0000000000..81d389026f Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/off_9450.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/on_10575.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/on_10575.wav new file mode 100644 index 0000000000..d5a3c89013 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/on_10575.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/on_11700.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/on_11700.wav new file mode 100644 index 0000000000..45f9eda725 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/on_11700.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/on_12825.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/on_12825.wav new file mode 100644 index 0000000000..5c9a99da3b Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/on_12825.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/on_13950.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/on_13950.wav new file mode 100644 index 0000000000..c6374e3aa6 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/on_13950.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/on_15075.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/on_15075.wav new file mode 100644 index 0000000000..0877f4e0c4 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/on_15075.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/on_1575.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/on_1575.wav new file mode 100644 index 0000000000..c4e5d34b4b Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/on_1575.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/on_2700.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/on_2700.wav new file mode 100644 index 0000000000..cdb901496f Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/on_2700.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/on_3825.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/on_3825.wav new file mode 100644 index 0000000000..b4fba53fe3 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/on_3825.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/on_4950.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/on_4950.wav new file mode 100644 index 0000000000..9f58eb29fa Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/on_4950.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/on_6075.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/on_6075.wav new file mode 100644 index 0000000000..25720a587f Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/on_6075.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/on_7200.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/on_7200.wav new file mode 100644 index 0000000000..3ef8e3adde Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/on_7200.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/on_8325.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/on_8325.wav new file mode 100644 index 0000000000..47a9be02dc Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/on_8325.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/on_9450.wav b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/on_9450.wav new file mode 100644 index 0000000000..6c101d888e Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/bmw_m3_deep/on_9450.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_1556.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_1556.wav index 1c8254a05b..7db4a2b466 100644 Binary files a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_1556.wav and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_1556.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_4000.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_4000.wav index 7227e5cd3d..46c25ebe21 100644 Binary files a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_4000.wav and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_4000.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_4250.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_4250.wav index 4bf8138dc1..72159a4194 100644 Binary files a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_4250.wav and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_4250.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_4500.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_4500.wav index b0f180c2dc..0319e38bb3 100644 Binary files a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_4500.wav and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_4500.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_4750.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_4750.wav index 1b4c5564e9..a609136c6f 100644 Binary files a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_4750.wav and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_4750.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_5000.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_5000.wav index 8c1adf30f1..ea35d1a12e 100644 Binary files a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_5000.wav and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_5000.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_5250.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_5250.wav index a3ea95d9ec..be55253d18 100644 Binary files a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_5250.wav and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_5250.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_5500.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_5500.wav index c7106329a4..a5537c7871 100644 Binary files a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_5500.wav and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_5500.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_5750.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_5750.wav index 7294a86e54..0d24ed2a71 100644 Binary files a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_5750.wav and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_5750.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_6000.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_6000.wav index a75422e55c..4a5bc02a2f 100644 Binary files a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_6000.wav and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_6000.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_6250.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_6250.wav index 9419c393db..b451b971a4 100644 Binary files a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_6250.wav and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_6250.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_6500.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_6500.wav index 781c22e960..7c85dbec14 100644 Binary files a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_6500.wav and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_6500.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_6750.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_6750.wav index be5d996d29..1a67c39817 100644 Binary files a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_6750.wav and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_6750.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_7000.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_7000.wav index 344419b490..8481b43826 100644 Binary files a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_7000.wav and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/off_7000.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_1556.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_1556.wav index 50a98d1af4..5d354d78c3 100644 Binary files a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_1556.wav and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_1556.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_3250.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_3250.wav index 14a1852fbd..d1aa0ba41b 100644 Binary files a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_3250.wav and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_3250.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_3500.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_3500.wav index e7fe3ec867..a3a24b83f8 100644 Binary files a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_3500.wav and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_3500.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_3750.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_3750.wav index ce04f75777..08c63bdb17 100644 Binary files a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_3750.wav and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_3750.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_4000.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_4000.wav index eebe05fe53..1f43e13138 100644 Binary files a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_4000.wav and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_4000.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_4250.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_4250.wav index 16155befd4..b995bf1732 100644 Binary files a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_4250.wav and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_4250.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_4500.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_4500.wav index 7fabba6b87..a9b75c9673 100644 Binary files a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_4500.wav and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_4500.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_4750.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_4750.wav index 8999eca2e4..2d3115deec 100644 Binary files a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_4750.wav and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_4750.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_5000.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_5000.wav index a858682147..cef05079ef 100644 Binary files a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_5000.wav and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_5000.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_5250.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_5250.wav index 9fd7abe84f..6c8328cd22 100644 Binary files a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_5250.wav and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_5250.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_5500.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_5500.wav index 6749c98756..983c5e2825 100644 Binary files a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_5500.wav and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_5500.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_5750.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_5750.wav index a35c7da649..6296dbda61 100644 Binary files a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_5750.wav and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_5750.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_6000.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_6000.wav index 752b95a7ca..f274c69b5d 100644 Binary files a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_6000.wav and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_6000.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_6250.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_6250.wav index 5369fbf89c..c10a3f3d1c 100644 Binary files a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_6250.wav and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_6250.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_6500.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_6500.wav index aaf938df86..4bf7abdf75 100644 Binary files a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_6500.wav and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_6500.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_6750.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_6750.wav index 55407759cb..b6655813bc 100644 Binary files a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_6750.wav and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_6750.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_7000.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_7000.wav index 0f83979ac4..f2a79f679b 100644 Binary files a/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_7000.wav and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt/on_7000.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/bank.json b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/bank.json new file mode 100644 index 0000000000..cf8df23de2 --- /dev/null +++ b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/bank.json @@ -0,0 +1,134 @@ +{ + "version": 1, + "source": "recording NissanSuperGT.wav", + "layers": { + "off": [ + { + "rpm": 2023, + "file": "off_2023.wav" + }, + { + "rpm": 5200, + "file": "off_5200.wav" + }, + { + "rpm": 5525, + "file": "off_5525.wav" + }, + { + "rpm": 5850, + "file": "off_5850.wav" + }, + { + "rpm": 6175, + "file": "off_6175.wav" + }, + { + "rpm": 6500, + "file": "off_6500.wav" + }, + { + "rpm": 6825, + "file": "off_6825.wav" + }, + { + "rpm": 7150, + "file": "off_7150.wav" + }, + { + "rpm": 7475, + "file": "off_7475.wav" + }, + { + "rpm": 7800, + "file": "off_7800.wav" + }, + { + "rpm": 8125, + "file": "off_8125.wav" + }, + { + "rpm": 8450, + "file": "off_8450.wav" + }, + { + "rpm": 8775, + "file": "off_8775.wav" + }, + { + "rpm": 9100, + "file": "off_9100.wav" + } + ], + "on": [ + { + "rpm": 2023, + "file": "on_2023.wav" + }, + { + "rpm": 4225, + "file": "on_4225.wav" + }, + { + "rpm": 4550, + "file": "on_4550.wav" + }, + { + "rpm": 4875, + "file": "on_4875.wav" + }, + { + "rpm": 5200, + "file": "on_5200.wav" + }, + { + "rpm": 5525, + "file": "on_5525.wav" + }, + { + "rpm": 5850, + "file": "on_5850.wav" + }, + { + "rpm": 6175, + "file": "on_6175.wav" + }, + { + "rpm": 6500, + "file": "on_6500.wav" + }, + { + "rpm": 6825, + "file": "on_6825.wav" + }, + { + "rpm": 7150, + "file": "on_7150.wav" + }, + { + "rpm": 7475, + "file": "on_7475.wav" + }, + { + "rpm": 7800, + "file": "on_7800.wav" + }, + { + "rpm": 8125, + "file": "on_8125.wav" + }, + { + "rpm": 8450, + "file": "on_8450.wav" + }, + { + "rpm": 8775, + "file": "on_8775.wav" + }, + { + "rpm": 9100, + "file": "on_9100.wav" + } + ] + } +} diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/off_2023.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/off_2023.wav new file mode 100644 index 0000000000..d058bcce87 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/off_2023.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/off_5200.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/off_5200.wav new file mode 100644 index 0000000000..f39e827141 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/off_5200.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/off_5525.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/off_5525.wav new file mode 100644 index 0000000000..4dfa1cd43b Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/off_5525.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/off_5850.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/off_5850.wav new file mode 100644 index 0000000000..7b39d34644 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/off_5850.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/off_6175.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/off_6175.wav new file mode 100644 index 0000000000..1a87cee18f Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/off_6175.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/off_6500.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/off_6500.wav new file mode 100644 index 0000000000..3831f72918 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/off_6500.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/off_6825.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/off_6825.wav new file mode 100644 index 0000000000..915b64391a Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/off_6825.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/off_7150.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/off_7150.wav new file mode 100644 index 0000000000..98a65ffe85 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/off_7150.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/off_7475.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/off_7475.wav new file mode 100644 index 0000000000..196b06e544 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/off_7475.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/off_7800.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/off_7800.wav new file mode 100644 index 0000000000..c5ad09f561 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/off_7800.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/off_8125.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/off_8125.wav new file mode 100644 index 0000000000..865ba9a620 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/off_8125.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/off_8450.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/off_8450.wav new file mode 100644 index 0000000000..61ad06de86 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/off_8450.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/off_8775.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/off_8775.wav new file mode 100644 index 0000000000..4fa30f5a6f Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/off_8775.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/off_9100.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/off_9100.wav new file mode 100644 index 0000000000..ee37cada2b Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/off_9100.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_2023.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_2023.wav new file mode 100644 index 0000000000..a26aa91a95 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_2023.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_4225.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_4225.wav new file mode 100644 index 0000000000..c499ac2cb8 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_4225.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_4550.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_4550.wav new file mode 100644 index 0000000000..6f4215c5fc Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_4550.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_4875.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_4875.wav new file mode 100644 index 0000000000..7a3a0acbd4 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_4875.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_5200.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_5200.wav new file mode 100644 index 0000000000..e2972aef17 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_5200.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_5525.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_5525.wav new file mode 100644 index 0000000000..304dc713c1 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_5525.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_5850.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_5850.wav new file mode 100644 index 0000000000..78233aaa83 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_5850.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_6175.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_6175.wav new file mode 100644 index 0000000000..aa9a131f3f Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_6175.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_6500.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_6500.wav new file mode 100644 index 0000000000..97c93afd99 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_6500.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_6825.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_6825.wav new file mode 100644 index 0000000000..4bb124b412 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_6825.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_7150.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_7150.wav new file mode 100644 index 0000000000..fe27003827 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_7150.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_7475.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_7475.wav new file mode 100644 index 0000000000..d54c3d1247 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_7475.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_7800.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_7800.wav new file mode 100644 index 0000000000..3e797d47c9 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_7800.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_8125.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_8125.wav new file mode 100644 index 0000000000..6ece93df31 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_8125.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_8450.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_8450.wav new file mode 100644 index 0000000000..6aeb7317da Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_8450.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_8775.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_8775.wav new file mode 100644 index 0000000000..b583669758 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_8775.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_9100.wav b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_9100.wav new file mode 100644 index 0000000000..5086675205 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/nissan_super_gt2/on_9100.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/pops/burble_grains.wav b/openpilot/starpilot/engine_sound/banks/pops/burble_grains.wav new file mode 100644 index 0000000000..9d3a0f1afd Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/pops/burble_grains.wav differ diff --git a/openpilot/starpilot/engine_sound/banks/turbo/blowoff.wav b/openpilot/starpilot/engine_sound/banks/turbo/blowoff.wav new file mode 100644 index 0000000000..3831b25557 Binary files /dev/null and b/openpilot/starpilot/engine_sound/banks/turbo/blowoff.wav differ diff --git a/openpilot/starpilot/engine_sound/effects.py b/openpilot/starpilot/engine_sound/effects.py index fc317a10f7..e8910b8a89 100644 --- a/openpilot/starpilot/engine_sound/effects.py +++ b/openpilot/starpilot/engine_sound/effects.py @@ -9,7 +9,8 @@ from openpilot.starpilot.engine_sound.turbo import Turbo def layers(profile: Profile, sample_rate: int) -> list: out: list = [] if profile.pops: - out.append(Pops(profile.pops, profile.idle_rpm, profile.redline_rpm, sample_rate)) + out.append(Pops(profile.pops, profile.idle_rpm, profile.redline_rpm, sample_rate, burble=profile.burble, + pitch=profile.pop_pitch)) if profile.turbo: out.append(Turbo(profile.turbo, profile.idle_rpm, profile.redline_rpm, sample_rate)) return out diff --git a/openpilot/starpilot/engine_sound/loops.py b/openpilot/starpilot/engine_sound/loops.py index b7049dc57b..42ff7cae59 100644 --- a/openpilot/starpilot/engine_sound/loops.py +++ b/openpilot/starpilot/engine_sound/loops.py @@ -126,6 +126,8 @@ class LoopSynth: out = on * np.sqrt(load_ramp) + off * np.sqrt(1 - load_ramp) self.rpm, self.load, self.gain = rpm, load, target_gain out = out * gain + added = np.zeros(frames, dtype=np.float32) for layer in self.effects: - out = out + layer.render(rpm, load, frames, volume) - return np.tanh(out).astype(np.float32) + added = added + layer.render(rpm, load, frames, volume) + out = out * getattr(layer, 'engine_gain', 1.0) + return np.tanh(out + added).astype(np.float32) diff --git a/openpilot/starpilot/engine_sound/pops.py b/openpilot/starpilot/engine_sound/pops.py index bd9e460320..939f422b81 100644 --- a/openpilot/starpilot/engine_sound/pops.py +++ b/openpilot/starpilot/engine_sound/pops.py @@ -4,10 +4,16 @@ Each pop is a one-shot from a library built once at start; firing only mixes sam """ from __future__ import annotations +import wave +from pathlib import Path + import numpy as np from openpilot.starpilot.engine_sound.synth import SAMPLE_RATE +GRAINS = Path(__file__).with_name('banks') / 'pops' / 'burble_grains.wav' +GRAIN_SECONDS = 0.052 + LIBRARY_SIZE = 12 # per kind LIFT_FROM = 0.2 # load a lift must come down from OVERRUN = 0.08 # at or below this load the engine is on overrun @@ -24,6 +30,26 @@ KIND_SHARES = (0.45, 0.35, 0.2) LEVEL = 1.0 TOP_HZ = 1000.0 +# Burble mode: below the crackle range, bursts of pops recorded from a real V8 on overrun, with the recording's timing, +# then a low rumble. Single pops at low revs sound like isolated clicks on car speakers. +SLOW_SHARE = 0.25 # lifts below this share (revs x load) burble instead of crackling +BURBLE_LIFT_SECONDS = 1.2 +BURBLE_GAP_SECONDS = 0.037 # median gap between pops, lognormal spread +BURBLE_GAP_SPREAD = 0.7 +BURBLE_GAP_RANGE = (0.011, 0.16) +BURBLE_FADE_FROM = 0.7 # share of a burst after which it thins out +GRAIN_LEVEL = 0.175 +DOWNSHIFT_CHANCE = 0.3 # never two downshifts in a row +DOWNSHIFT_MAX = 3 # per slow-down +DOWNSHIFT_SECONDS = 0.35 +DOWNSHIFT_TAPER = 0.6 # each later burst of a slow-down is this much shorter +DOWNSHIFT_FADE = 0.75 # and this much quieter +RUMBLE_SECONDS = (1.8, 1.0) # after a lift, after a downshift +RUMBLE_LEVEL = 0.0118 +RUMBLE_BAND_HZ = (150.0, 700.0) +RUMBLE_HZ = 15.6 +RUMBLE_WOBBLE_DB = 2.0 + def _resonator(excitation: np.ndarray, frequency: float, q: float, sample_rate: int) -> np.ndarray: """Two-pole band-pass applied in the frequency domain; padding keeps the decay from wrapping.""" @@ -78,14 +104,43 @@ def library(sample_rate: int = SAMPLE_RATE, seed: int = 3) -> dict[str, list[np. 'crackle': [_crackle(rng, sample_rate) for _ in range(LIBRARY_SIZE)]} +def load_grains(path: Path = GRAINS, sample_rate: int = SAMPLE_RATE) -> list[np.ndarray]: + """Recorded pops of GRAIN_SECONDS each, back to back; none if the recording is missing or unreadable.""" + try: + with wave.open(str(path)) as source: + if source.getnchannels() != 1 or source.getsampwidth() != 2 or source.getframerate() != sample_rate: + return [] + audio = np.frombuffer(source.readframes(source.getnframes()), ' np.ndarray: + noise = np.random.default_rng(seed).standard_normal(int(seconds * sample_rate)) + freq = np.fft.rfftfreq(len(noise), 1 / sample_rate) + out = np.fft.irfft(np.fft.rfft(noise) * ((freq >= band[0]) & (freq <= band[1])), len(noise)) + return (out / np.sqrt(np.mean(out ** 2))).astype(np.float32) + + +def _lowered(sample: np.ndarray, pitch: float) -> np.ndarray: + if pitch == 1.0: + return sample + return np.interp(np.arange(0, len(sample) - 1, pitch), np.arange(len(sample)), sample).astype(np.float32) + + class Pops: - def __init__(self, intensity: float, idle_rpm: float, redline_rpm: float, sample_rate: int = SAMPLE_RATE, seed: int = 5): + def __init__(self, intensity: float, idle_rpm: float, redline_rpm: float, sample_rate: int = SAMPLE_RATE, seed: int = 5, + burble: bool = False, pitch: float = 1.0): self.intensity = intensity self.min_rpm = max(idle_rpm, MIN_RPM_SHARE * redline_rpm) self.redline_rpm = redline_rpm self.sample_rate = sample_rate - self.samples = library(sample_rate) - self.longest = max(len(sample) for samples in self.samples.values() for sample in samples) + self.samples = {kind: [_lowered(sample, pitch) for sample in samples] for kind, samples in library(sample_rate).items()} + self.grains = [_lowered(grain, pitch) for grain in load_grains(sample_rate=sample_rate)] if burble else [] + self.burble = bool(self.grains) + self.longest = max(len(sample) for samples in (*self.samples.values(), self.grains) for sample in samples) self.tail = np.zeros(0, dtype=np.float32) self.rng = np.random.default_rng(seed) self.rpm: float | None = None @@ -95,6 +150,20 @@ class Pops: self.window = 0.0 # seconds of pops left self.length = 1.0 # length of the current window self.strength = 0.0 + self.blipping = False + self.burst = 0.0 # seconds of burble burst left + self.burst_length = 1.0 + self.burst_level = 1.0 + self.next_grain = 0.0 # seconds into the coming block + self.from_downshift = False + self.downshift_bursts = 0 + self.last_downshift_burst = False + self.rumble = 0.0 # seconds of rumble left + self.rumble_length = 1.0 + self.rumble_after = 0.0 + self.rumble_noise = _band_noise(sample_rate, RUMBLE_BAND_HZ, 4.0, seed) if self.burble else np.zeros(1, np.float32) + self.rumble_at = 0 + self.rumble_phase = 0.0 def _rpm_share(self, rpm: float) -> float: return min(max((rpm - self.min_rpm) / (self.redline_rpm - self.min_rpm), 0.0), 1.0) @@ -102,28 +171,85 @@ class Pops: def _blip(self, rpm: float, load: float, dt: float) -> bool: return self.rpm is not None and load <= OVERRUN and (rpm - self.rpm) / dt >= BLIP_RPM_PER_SECOND and rpm >= self.min_rpm + def _start_burst(self, seconds: float, level: float, rumble_seconds: float, downshift: bool) -> None: + if self.burst <= 0.0: + self.next_grain = 0.0 + self.burst_length = self.burst = seconds + elif seconds > self.burst: + self.burst_length += seconds - self.burst + self.burst = seconds + self.rumble = 0.0 + self.burst_level, self.rumble_after, self.from_downshift = level, rumble_seconds, downshift + + def _downshift(self) -> None: + if self.burst > 0.0 and not self.from_downshift: + return + fire = (self.downshift_bursts < DOWNSHIFT_MAX and not self.last_downshift_burst + and self.rng.random() < DOWNSHIFT_CHANCE) + self.last_downshift_burst = fire + if fire: + taper = DOWNSHIFT_TAPER ** self.downshift_bursts + self.downshift_bursts += 1 + self._start_burst(DOWNSHIFT_SECONDS * taper, DOWNSHIFT_FADE ** self.downshift_bursts, RUMBLE_SECONDS[1] * taper, True) + def _update(self, rpm: float, load: float, dt: float, blip: bool) -> None: self.peak_load = max(load, self.peak_load * np.exp(-dt / 1.5)) self.armed = self.armed or load > LIFT_FROM if load >= RESUME or rpm < 0.8 * self.min_rpm: - self.window = 0.0 + self.window = self.burst = self.rumble = 0.0 + self.downshift_bursts, self.last_downshift_burst = 0, False elif load <= OVERRUN and self.armed and rpm >= self.min_rpm: self.armed = False + self.downshift_bursts, self.last_downshift_burst = 0, False share = self._rpm_share(rpm) * self.peak_load - self.length = self.window = WINDOW_SECONDS[0] + (WINDOW_SECONDS[1] - WINDOW_SECONDS[0]) * share - self.strength = 0.4 + 0.6 * share + if self.burble and share < SLOW_SHARE: + self.window = 0.0 + self._start_burst(BURBLE_LIFT_SECONDS, 1.0, RUMBLE_SECONDS[0], False) + else: + self.length = self.window = WINDOW_SECONDS[0] + (WINDOW_SECONDS[1] - WINDOW_SECONDS[0]) * share + self.strength = 0.4 + 0.6 * share + elif blip and self.burble: + if not self.blipping: + self._downshift() + self.window = max(self.window - dt, 0.0) elif blip: self.window = max(self.window, BLIP_EXTEND_SECONDS) self.length = max(self.length, self.window) self.strength = max(self.strength, 0.7) else: self.window = max(self.window - dt, 0.0) + self.blipping = blip self.rpm, self.load = rpm, load + def _render_burst(self, out: np.ndarray, dt: float, gain: float) -> None: + while self.next_grain < dt: + progress = 1.0 - (self.burst - self.next_grain) / self.burst_length + thin = 1.0 if progress < BURBLE_FADE_FROM else max(1.0 - (progress - BURBLE_FADE_FROM) / (1.0 - BURBLE_FADE_FROM) * 0.7, 0.3) + grain = self.grains[self.rng.integers(len(self.grains))] + start = int(self.next_grain * self.sample_rate) + out[start:start + len(grain)] += GRAIN_LEVEL * self.burst_level * gain * thin * self.rng.uniform(0.7, 1.0) * grain + gap = BURBLE_GAP_SECONDS * np.exp(BURBLE_GAP_SPREAD * self.rng.standard_normal()) + self.next_grain += float(np.clip(gap, *BURBLE_GAP_RANGE)) + self.next_grain -= dt + self.burst -= dt + if self.burst <= 0.0: + self.burst = 0.0 + self.rumble_length = self.rumble = self.rumble_after + + def _render_rumble(self, out: np.ndarray, frames: int, dt: float, gain: float) -> None: + index = (self.rumble_at + np.arange(frames)) % len(self.rumble_noise) + self.rumble_at = int(index[-1] + 1) + wobble = 10 ** (RUMBLE_WOBBLE_DB * np.sin(2 * np.pi * (self.rumble_phase + RUMBLE_HZ * np.arange(frames) / self.sample_rate)) / 20) + self.rumble_phase = (self.rumble_phase + RUMBLE_HZ * dt) % 1.0 + envelope = (self.rumble / self.rumble_length) ** 1.5 + out[:frames] += RUMBLE_LEVEL * self.burst_level * gain * envelope * wobble * self.rumble_noise[index] + self.rumble = max(self.rumble - dt, 0.0) + def render(self, rpm: float, load: float, frames: int, volume: float) -> np.ndarray: dt = frames / self.sample_rate blip = self._blip(rpm, load, dt) self._update(rpm, load, dt, blip) + blip = blip and not self.burble out = np.zeros(frames + self.longest, dtype=np.float32) out[:len(self.tail)] += self.tail if self.window > 0.0 and self.intensity > 0.0 and volume > 0.0: @@ -136,6 +262,10 @@ class Pops: level = LEVEL * self.intensity * volume * envelope ** 0.3 * self.rng.uniform(0.5, 1.0) out[start:start + len(sample)] += level * sample blip = False + if self.burst > 0.0: + self._render_burst(out, dt, self.intensity * volume) + if self.rumble > 0.0: + self._render_rumble(out, frames, dt, self.intensity * volume) self.tail = out[frames:frames + self.longest].copy() if not self.tail.any(): self.tail = self.tail[:0] diff --git a/openpilot/starpilot/engine_sound/profiles.py b/openpilot/starpilot/engine_sound/profiles.py index 2a596ae7be..2ac569afe1 100644 --- a/openpilot/starpilot/engine_sound/profiles.py +++ b/openpilot/starpilot/engine_sound/profiles.py @@ -38,6 +38,8 @@ class Profile: tremolo: tuple[float, float] = (0.0, 0.0) # rate in Hz, depth gain: tuple[float, float] = (0.35, 1.0) # loudness at no load and full load pops: float = 0.0 # overrun pops and crackle, 0 none to 1 heavy + burble: bool = False # recorded burble bursts instead of single pops at low revs and on downshifts + pop_pitch: float = 1.0 # playback speed of every pop; below 1 is deeper turbo: float = 0.0 # turbo whistle and blow-off valve, 0 none to 1 loud @@ -58,7 +60,8 @@ RACE_REDLINE = 8600.0 def _recorded(name: str, label: str, *, cylinders: int, idle: float, redline: float, loops: str = '', pops: float = 0.0, - turbo: float = 0.0, upshift: float = 0.38, downshift: float = 0.2, gearing: float = 1.0) -> Profile: + burble: bool = False, pop_pitch: float = 1.0, turbo: float = 0.0, upshift: float = 0.38, + downshift: float = 0.2, gearing: float = 1.0) -> Profile: """A bundled loop bank (of the same name unless given), geared like the race car but scaled to its own rev range. upshift and downshift are the light-throttle shift points as shares of redline; full throttle always shifts at 96%. @@ -66,7 +69,7 @@ def _recorded(name: str, label: str, *, cylinders: int, idle: float, redline: fl """ scale = redline / RACE_REDLINE * gearing return Profile( - name=name, label=label, loops=loops or name, pops=pops, turbo=turbo, + name=name, label=label, loops=loops or name, pops=pops, burble=burble, pop_pitch=pop_pitch, turbo=turbo, idle_rpm=idle, redline_rpm=redline, gears=tuple(ratio * scale for ratio in RACE_GEARS), upshift_rpm=(upshift * redline, 0.96 * redline), downshift_rpm=(downshift * redline, max(0.6, downshift + 0.25) * redline), @@ -77,16 +80,19 @@ def _recorded(name: str, label: str, *, cylinders: int, idle: float, redline: fl PROFILES: dict[str, Profile] = {profile.name: profile for profile in ( - _recorded('bmw_m3', 'BMW M3', cylinders=6, idle=700.0, redline=7000.0, loops='bmw_m52', pops=1.0), + _recorded('bmw_m3', 'BMW M3', cylinders=6, idle=700.0, redline=7000.0, pops=1.0, burble=True), + _recorded('bmw_m3_deep', 'BMW M3 Deep', cylinders=6, idle=700.0, redline=7000.0, pops=1.0, burble=True, pop_pitch=0.8), _recorded('bmw_m52', 'BMW M52', cylinders=6, idle=700.0, redline=7000.0), _recorded('f1_car', 'F1 Car', cylinders=12, idle=2000.0, redline=17000.0), _recorded('ferrari_f136', 'Ferrari F136', cylinders=8, idle=1000.0, redline=9000.0), # Banks from real recordings that end at 3000 and 5250 rpm; above about 1.5 times that the loops sound sped up. _recorded('hellcat', 'Hellcat', cylinders=8, idle=700.0, redline=4500.0), - _recorded('jaguar_ftype', 'Jaguar F-Type', cylinders=8, idle=721.0, redline=6500.0, pops=1.0), + _recorded('jaguar_ftype', 'Jaguar F-Type', cylinders=8, idle=721.0, redline=6500.0, pops=1.0, burble=True), _recorded('lfa', 'LFA', cylinders=10, idle=1000.0, redline=9000.0), # Recorded only at idle and from 3250 rpm up, so it is geared short and shifts like a race car to stay in that range. - _recorded('nissan_super_gt', 'Nissan Super GT', cylinders=4, idle=1556.0, redline=7500.0, upshift=0.62, downshift=0.45, + _recorded('nissan_super_gt', 'Nissan Super GT1', cylinders=4, idle=1556.0, redline=7500.0, upshift=0.62, downshift=0.45, + gearing=1.2), + _recorded('nissan_super_gt2', 'Nissan Super GT2', cylinders=4, idle=1556.0, redline=7500.0, upshift=0.62, downshift=0.45, gearing=1.2), _recorded('supra_turbo', 'Supra Turbo', cylinders=6, idle=800.0, redline=6000.0, turbo=1.0), )} diff --git a/openpilot/starpilot/engine_sound/synth.py b/openpilot/starpilot/engine_sound/synth.py index ad91ee61c7..4b4fbc4183 100644 --- a/openpilot/starpilot/engine_sound/synth.py +++ b/openpilot/starpilot/engine_sound/synth.py @@ -84,8 +84,11 @@ class Synth: self.phase = float(phase[-1] % 1.0) self.frequency, self.load, self.gain = float(frequency[-1]), load, target_gain out = 0.8 * out * gain + added = np.zeros(frames, dtype=np.float32) for layer in self.effects: - out = out + layer.render(rpm, load, frames, volume) + added = added + layer.render(rpm, load, frames, volume) + out = out * getattr(layer, 'engine_gain', 1.0) + out = out + added return np.tanh(out).astype(np.float32) diff --git a/openpilot/starpilot/engine_sound/tests/test_pops.py b/openpilot/starpilot/engine_sound/tests/test_pops.py index e865b40898..4ee33557ed 100644 --- a/openpilot/starpilot/engine_sound/tests/test_pops.py +++ b/openpilot/starpilot/engine_sound/tests/test_pops.py @@ -1,9 +1,10 @@ from dataclasses import replace import numpy as np +import pytest from openpilot.starpilot.engine_sound.loops import LoopSynth, load_bank -from openpilot.starpilot.engine_sound.pops import Pops, library +from openpilot.starpilot.engine_sound.pops import GRAIN_SECONDS, Pops, library, load_grains from openpilot.starpilot.engine_sound.profiles import PROFILES from openpilot.starpilot.engine_sound.tests.test_loops import make_bank @@ -71,6 +72,71 @@ def test_quiet_at_zero_volume_and_profiles_without_pops_are_unchanged(tmp_path): assert np.abs(loud - quiet).max() > 0.05 and np.abs(loud).max() <= 1.0 -def test_the_m3_pops_and_the_m52_does_not(): - assert PROFILES['bmw_m3'].pops > 0 and PROFILES['bmw_m3'].loops == 'bmw_m52' +def test_the_m3s_pop_on_their_own_banks_and_the_m52_does_not(): + assert (PROFILES['bmw_m3'].loops, PROFILES['bmw_m3_deep'].loops) == ('bmw_m3', 'bmw_m3_deep') + assert PROFILES['bmw_m3'].pops > 0 and PROFILES['bmw_m3_deep'].pops > 0 assert PROFILES['bmw_m52'].pops == 0 + + +def test_burbling_profiles(): + assert [name for name, profile in PROFILES.items() if profile.burble] == ['bmw_m3', 'bmw_m3_deep', 'jaguar_ftype'] + assert all(PROFILES[name].pops > 0 for name in ('bmw_m3', 'bmw_m3_deep', 'jaguar_ftype')) + assert [name for name, profile in PROFILES.items() if profile.pop_pitch != 1.0] == ['bmw_m3_deep'] + + +def test_a_lower_pop_pitch_plays_every_pop_slower(): + plain, deep = Pops(1.0, 700.0, 7000.0, burble=True), Pops(1.0, 700.0, 7000.0, burble=True, pitch=0.8) + assert len(deep.grains) == len(plain.grains) + assert len(deep.grains[0]) == pytest.approx(len(plain.grains[0]) / 0.8, abs=2) + assert len(deep.samples['pop'][0]) == pytest.approx(len(plain.samples['pop'][0]) / 0.8, abs=2) + assert deep.longest > plain.longest + + +def test_recorded_grains_load_and_a_missing_recording_falls_back_to_plain_pops(tmp_path): + grains = load_grains() + assert len(grains) == 62 and all(len(g) == int(GRAIN_SECONDS * 48000) for g in grains) + assert load_grains(tmp_path / 'missing.wav') == [] + assert not Pops(1.0, 721.0, 6500.0, sample_rate=44100, burble=True).burble + + +def test_a_low_rev_lift_burbles_then_rumbles_and_a_high_rev_lift_still_crackles(): + pops = Pops(1.0, 721.0, 6500.0, burble=True) + run(pops, [(2300.0, 0.3)] * 100) + burst = run(pops, [(2300.0 - 2 * i, 0.0) for i in range(110)]) + assert pops.window == 0.0 and np.abs(burst).max() > 0.05 + run(pops, [(2000.0, 0.0)] * 15) + assert pops.burst == 0.0 and pops.rumble > 0.0 + rumble = run(pops, [(2000.0, 0.0)] * 50) + assert 0.003 < np.sqrt(np.mean(rumble[4 * FRAMES:] ** 2)) < 0.03 + assert not run(pops, [(2000.0, 0.0)] * 200)[-50 * FRAMES:].any() + + high = Pops(1.0, 721.0, 6500.0, burble=True) + run(high, [(5500.0, 0.9)] * 100) + run(high, [(5500.0, 0.0)]) + assert high.window > 0.0 and high.burst == 0.0 + + +def test_downshift_bursts_are_occasional_never_back_to_back_and_shrink(): + first, lengths = 0, {1: set(), 2: set(), 3: set()} + for seed in range(300): + pops = Pops(1.0, 721.0, 6500.0, seed=seed, burble=True) + fired = [] + for _ in range(8): + pops.burst = 0.0 + before = pops.downshift_bursts + pops._downshift() + fired.append(pops.downshift_bursts > before) + if fired[-1]: + lengths[pops.downshift_bursts].add(round(pops.burst, 4)) + assert not any(a and b for a, b in zip(fired, fired[1:], strict=False)) and sum(fired) <= 3 + first += fired[0] + assert 0.2 < first / 300 < 0.4 + assert lengths[1] == {0.35} and lengths[2] == {0.21} and lengths[3] == {0.126} + + +def test_a_downshift_blip_in_burble_mode_never_fires_a_single_pop(): + for seed in range(20): + pops = Pops(1.0, 721.0, 6500.0, seed=seed, burble=True) + run(pops, [(1400.0, 0.0)] * 50) + blip = run(pops, [(1400.0 + 60 * i, 0.0) for i in range(8)] + [(1880.0, 0.0)] * 60) + assert blip.any() == (pops.downshift_bursts == 1) diff --git a/openpilot/starpilot/engine_sound/tests/test_profiles.py b/openpilot/starpilot/engine_sound/tests/test_profiles.py index 5ccc0d941b..257bc146e8 100644 --- a/openpilot/starpilot/engine_sound/tests/test_profiles.py +++ b/openpilot/starpilot/engine_sound/tests/test_profiles.py @@ -7,7 +7,10 @@ DT = 0.01 SUPER_GT_RECORDED_FROM = 3250.0 -@pytest.mark.parametrize('name', [name for name in PROFILES if name != 'nissan_super_gt']) +SUPER_GTS = ('nissan_super_gt', 'nissan_super_gt2') + + +@pytest.mark.parametrize('name', [name for name in PROFILES if name not in SUPER_GTS]) def test_default_gearing_and_shift_points(name): p = PROFILES[name] assert p.upshift_rpm == pytest.approx((0.38 * p.redline_rpm, 0.96 * p.redline_rpm)) @@ -15,15 +18,22 @@ def test_default_gearing_and_shift_points(name): assert p.gears == pytest.approx(tuple(ratio * p.redline_rpm / RACE_REDLINE for ratio in RACE_GEARS)) -def test_super_gt_is_geared_short_and_holds_revs(): - p = PROFILES['nissan_super_gt'] +@pytest.mark.parametrize('name', SUPER_GTS) +def test_super_gt_is_geared_short_and_holds_revs(name): + p = PROFILES[name] assert p.gears[0] == pytest.approx(RACE_GEARS[0] * p.redline_rpm / RACE_REDLINE * 1.2) assert p.upshift_rpm[0] == pytest.approx(0.62 * p.redline_rpm) assert p.downshift_rpm == pytest.approx((0.45 * p.redline_rpm, 0.7 * p.redline_rpm)) -def test_super_gt_light_pedal_stays_in_the_recorded_range_and_clear_of_redline(): - p = PROFILES['nissan_super_gt'] +def test_super_gt2_plays_its_own_lower_bank(): + assert PROFILES['nissan_super_gt'].loops == 'nissan_super_gt' and PROFILES['nissan_super_gt2'].loops == 'nissan_super_gt2' + assert (PROFILES['nissan_super_gt'].label, PROFILES['nissan_super_gt2'].label) == ('Nissan Super GT1', 'Nissan Super GT2') + + +@pytest.mark.parametrize('name', SUPER_GTS) +def test_super_gt_light_pedal_stays_in_the_recorded_range_and_clear_of_redline(name): + p = PROFILES[name] model = EngineModel(p) speed, revs = 0.0, [] while speed < 30.0: diff --git a/openpilot/starpilot/engine_sound/tests/test_turbo.py b/openpilot/starpilot/engine_sound/tests/test_turbo.py index b6e7e5d639..6451dd658c 100644 --- a/openpilot/starpilot/engine_sound/tests/test_turbo.py +++ b/openpilot/starpilot/engine_sound/tests/test_turbo.py @@ -1,6 +1,7 @@ from dataclasses import replace import numpy as np +import pytest from openpilot.starpilot.engine_sound.loops import LoopSynth, load_bank from openpilot.starpilot.engine_sound.profiles import PROFILES @@ -18,32 +19,69 @@ def test_boost_lags_the_throttle_and_needs_revs(): turbo = Turbo(1.0, 800.0, 6000.0) run(turbo, [(4000.0, 1.0)] * 10) early = turbo.boost - run(turbo, [(4000.0, 1.0)] * 150) + run(turbo, [(4000.0, 1.0)] * 250) assert early < 0.25 < 0.8 < turbo.boost low = Turbo(1.0, 800.0, 6000.0) run(low, [(850.0, 1.0)] * 200) assert low.boost == 0.0 +def test_the_first_tenth_of_pedal_makes_no_boost_and_part_boost_whistles_faintly(): + light = Turbo(1.0, 800.0, 6000.0) + assert not run(light, [(4000.0, 0.1)] * 300).any() and light.boost == 0.0 + part, full = Turbo(1.0, 800.0, 6000.0), Turbo(1.0, 800.0, 6000.0) + run(part, [(4000.0, 0.2)] * 400) + run(full, [(4000.0, 1.0)] * 400) + quiet, loud = np.abs(run(part, [(4000.0, 0.2)] * 20)).max(), np.abs(run(full, [(4000.0, 1.0)] * 20)).max() + assert quiet < 0.3 * loud + + def test_lifting_on_boost_fires_the_valve_and_vents_it(): turbo = Turbo(1.0, 800.0, 6000.0) run(turbo, [(4000.0, 1.0)] * 200) on_boost = np.abs(run(turbo, [(4000.0, 1.0)] * 20)).max() - release = run(turbo, [(3800.0, 0.0)] * 160) - assert np.abs(release).max() > 4 * on_boost + release = run(turbo, [(3800.0, 0.0)] * 190) + assert np.abs(release).max() > 2.5 * on_boost assert turbo.boost < 0.1 assert np.abs(release[-FRAMES * 10:]).max() < 0.5 * np.abs(release[FRAMES * 10:FRAMES * 20]).max() -def test_the_release_stutters_about_eleven_times_a_second(): - from openpilot.starpilot.engine_sound.turbo import BOV_SECONDS, FLUTTER_START, _release - release = _release(np.random.default_rng(0), BOV_SECONDS[1], 48000).astype(np.float64) - envelope = np.sqrt(np.convolve(release ** 2, np.ones(192) / 192, mode='same'))[::48] - body = envelope[int(FLUTTER_START * 1000) + 50:1100] - spectrum = np.abs(np.fft.rfft((body - body.mean()) * np.hanning(len(body)), 1 << 14)) - freq = np.fft.rfftfreq(1 << 14, 1 / 1000) - band = (freq > 4) & (freq < 40) - assert 10.0 < freq[band][np.argmax(spectrum[band])] < 13.5 +def test_the_recorded_release_loads_at_three_speeds_and_flutters(): + from openpilot.starpilot.engine_sound.turbo import BOV_SPEEDS, load_releases + releases = load_releases() + assert len(releases) == len(BOV_SPEEDS) + assert len(releases[0]) > len(releases[1]) > len(releases[2]) > 2 * 48000 + release = releases[1].astype(np.float64) + spectrum = np.fft.rfft(release) + freq = np.fft.rfftfreq(len(release), 1 / 48000) + spectrum[(freq < 1200) | (freq > 9000)] = 0 + high = np.fft.irfft(spectrum, len(release)) + db = 20 * np.log10(np.sqrt(np.convolve(high ** 2, np.ones(96) / 96, mode='same'))[::48] + 1e-9) + peaks = [i for i in range(12, len(db) - 12) if db[i] == db[i - 12:i + 13].max() and db[i] > np.median(db[max(0, i - 60):i + 60]) + 3] + assert 12.0 < len(peaks) / (len(db) / 1000) < 20.0 + + +def test_the_release_fades_in_and_the_engine_dips_under_it_then_recovers(): + from openpilot.starpilot.engine_sound.turbo import ENGINE_DUCK_DB + turbo = Turbo(1.0, 800.0, 6000.0) + run(turbo, [(4000.0, 1.0)] * 200) + assert np.all(turbo.engine_gain == 1.0) + run(turbo, [(3800.0, 0.0)] * 10) + first = turbo.render(3800.0, 0.0, FRAMES, 1.0) + later = run(turbo, [(3800.0, 0.0)] * 30) + assert np.abs(first[:48]).max() < np.abs(later).max() + assert turbo.engine_gain[-1] == pytest.approx(10 ** (-ENGINE_DUCK_DB / 20), rel=0.05) + run(turbo, [(3800.0, 0.0)] * 400) + assert turbo.engine_gain[-1] == pytest.approx(1.0, abs=1e-3) + + +def test_a_missing_recording_means_no_release_and_no_crash(tmp_path, monkeypatch): + from openpilot.starpilot.engine_sound import turbo as module + assert module.load_releases(tmp_path / 'missing.wav') == [] + monkeypatch.setattr(module, 'load_releases', lambda **kwargs: []) + quiet = Turbo(1.0, 800.0, 6000.0) + run(quiet, [(4000.0, 1.0)] * 200) + assert np.abs(run(quiet, [(3800.0, 0.0)] * 50)).max() < 0.1 def test_a_rev_limiter_cut_does_not_open_the_valve(): diff --git a/openpilot/starpilot/engine_sound/turbo.py b/openpilot/starpilot/engine_sound/turbo.py index 76dc3825a2..4025b1476a 100644 --- a/openpilot/starpilot/engine_sound/turbo.py +++ b/openpilot/starpilot/engine_sound/turbo.py @@ -1,91 +1,72 @@ """Turbocharger: a spool whistle that follows boost, and a blow-off valve release when the throttle closes on boost. Boost builds with load once the engine is spinning fast enough, with lag. Lifting while boosted fires the blow-off valve, -which vents the boost. The valve sounds are built once at start, so firing one only mixes a sample. +which vents the boost. The valve sound is a recording loaded once at start, so firing one only mixes a sample. """ from __future__ import annotations +import wave +from pathlib import Path + import numpy as np from openpilot.starpilot.engine_sound.synth import SAMPLE_RATE +BLOWOFF = Path(__file__).with_name('banks') / 'turbo' / 'blowoff.wav' + SPOOL_SHARE = (0.15, 0.4) # share of redline where boost starts and where it can be full -SPOOL_SECONDS = 0.8 # lag while boost builds +SPOOL_SECONDS = 1.1 # lag while boost builds BLEED_SECONDS = 0.35 # boost falling on a part lift that does not open the valve -VENT_SECONDS = 0.08 # boost falling through the open valve -LOAD_CURVE = 0.5 # an EV pulls on little pedal, so modest load still makes boost +VENT_SECONDS = 0.35 # boost falling through the open valve; the whistle fades into the release +PEDAL_DEADZONE = 0.1 # load below this makes no boost at all +LOAD_CURVE = 0.5 # an EV pulls on little pedal, so modest load past the dead zone still makes boost LIFT_FROM = 0.3 # load the throttle must come down from CLOSED = 0.1 # at or below this load the throttle counts as closed CLOSED_SECONDS = 0.1 # longer than a rev-limiter cut, which must not open the valve BOV_FROM = 0.3 # boost needed for the valve to open -BOV_LEVEL = 0.55 # A-weighted, about 5 dB over the coasting engine and just under it at full throttle -BOV_SECONDS = (0.6, 1.3) # release length from just enough boost to full boost -# The release follows a recording the user picked. Its spectrum, measured in four stages (the opening whump, the rush, -# the stutter, the tail) as dB per Hz in third-octave bands, shapes the noise; from 0.45 s it stutters about 11.5 times -# a second (80 ms between pulses, slowing to 96 ms, 7 dB deep). -SHAPE_HZ = (63.0, 100.0, 160.0, 250.0, 400.0, 630.0, 1000.0, 1600.0, 2500.0, 4000.0, 6300.0, 10000.0) -SHAPE_SECONDS = (0.075, 0.3, 0.725, 1.15) -SHAPE_DB = ( - (-23.0, -22.3, -12.0, -4.2, -17.7, -21.4, -29.6, -25.8, -31.3, -34.0, -24.9, -35.8), - (-29.5, -22.9, -13.2, -5.8, -7.1, -14.9, -17.2, -16.4, -19.2, -24.3, -19.0, -25.3), - (-25.6, -17.7, -14.2, 0.0, -3.3, -10.7, -15.9, -17.3, -20.8, -22.9, -20.0, -25.3), - (-22.5, -21.7, -14.8, -14.7, -8.5, -26.7, -29.5, -29.4, -30.6, -33.5, -30.0, -40.1), -) -LOW_CUT_HZ = 90.0 # below this the recording carries the engine, not the valve -FLUTTER_START = 0.45 -FLUTTER_PERIOD = (0.08, 0.096) -FLUTTER_DEPTH_DB = 7.0 +BOV_LEVEL = 0.267 # A-weighted, about 2 dB over the coasting engine before it dips +BOV_SECONDS = 0.8 # just enough boost plays this much of the recording; full boost plays all of it +BOV_SPEEDS = (0.97, 1.0, 1.03) # each release plays one of these, so repeats are not identical +# The release blends in rather than arriving as a separate clip: it fades in, sits a little darker, and the engine dips +# under it while it plays. +BOV_ATTACK_SECONDS = 0.08 # fade-in at the start of a release +BOV_HIGH_CUT_DB = -6.0 # level change above 3 kHz, so the release sits inside the engine's tone +ENGINE_DUCK_DB = 5.0 # the engine dips by this much while a release plays +DUCK_SECONDS = (0.06, 0.4) # how fast the engine dips and comes back +# A spool whistle is air, not a pure tone: mostly a band of noise around the pitch, with a little tone in it. WHISTLE_HZ = (1400.0, 3200.0) # whistle pitch from no boost to full boost +WHISTLE_CURVE = 3.0 # faint until boost is well built +WHISTLE_TONE = 0.15 # share of the whistle that is a plain tone +WHISTLE_WIDTH_HZ = 250.0 # width of the noise band around the pitch WHISTLE_LEVEL = 0.045 # with the intake rush, about 8 dB under the engine on boost, A-weighted WHOOSH_LEVEL = 0.038 -VARIANTS = 6 -def _flutter(rng: np.random.Generator, t: np.ndarray) -> np.ndarray: - """Gain that pulses as the valve chatters: unity on each pulse, FLUTTER_DEPTH_DB down between them.""" - floor = 10 ** (-FLUTTER_DEPTH_DB / 20) - gain = np.ones(len(t)) - at, pulses = FLUTTER_START, [] - while at < t[-1]: - share = min((at - FLUTTER_START) / (t[-1] - FLUTTER_START), 1.0) - period = (FLUTTER_PERIOD[0] + (FLUTTER_PERIOD[1] - FLUTTER_PERIOD[0]) * share) * rng.uniform(0.92, 1.08) - pulses.append((at, period)) - at += period - inside = t >= FLUTTER_START - gain[inside] = floor - for start, period in pulses: - width = 0.6 * period - sel = (t >= start) & (t < start + width) - gain[sel] = floor + (1 - floor) * np.sin(np.pi * (t[sel] - start) / width) ** 2 - onset = np.clip((t - FLUTTER_START + 0.05) / 0.05, 0.0, 1.0) - return 1.0 - onset * (1.0 - gain) +def load_releases(path: Path = BLOWOFF, sample_rate: int = SAMPLE_RATE) -> list[np.ndarray]: + """The recorded release at each of BOV_SPEEDS; none if the recording is missing or unreadable.""" + try: + with wave.open(str(path)) as source: + if source.getnchannels() != 1 or source.getsampwidth() != 2 or source.getframerate() != sample_rate: + return [] + audio = np.frombuffer(source.readframes(source.getnframes()), ' np.ndarray: - """Noise given the recording's spectrum stage by stage, then its stutter and decay.""" - frame, hop = 2048, 512 - length = int(seconds * sample_rate) + frame - noise = rng.standard_normal(length) - window = np.hanning(frame) - freq = np.fft.rfftfreq(frame, 1 / sample_rate) - log_freq = np.log2(np.maximum(freq, 20.0)) - low_cut = np.where(freq < LOW_CUT_HZ, -12.0 * np.log2(LOW_CUT_HZ / np.maximum(freq, 20.0)), 0.0) - shape = np.array(SHAPE_DB) - out = np.zeros(length) - norm = np.zeros(length) - for at in range(0, length - frame, hop): - t = (at + frame / 2) / sample_rate - stage = [np.interp(t, SHAPE_SECONDS, shape[:, band]) for band in range(len(SHAPE_HZ))] - gain = 10 ** ((np.interp(log_freq, np.log2(SHAPE_HZ), stage) + low_cut) / 20) - out[at:at + frame] += np.fft.irfft(np.fft.rfft(noise[at:at + frame] * window) * gain, frame) * window - norm[at:at + frame] += window ** 2 - out = out[:length - frame] / np.maximum(norm[:length - frame], 1e-3) - t = np.arange(len(out)) / sample_rate - decay = np.where(t < 0.9 * seconds / BOV_SECONDS[1], 1.0, np.exp(-(t - 0.9 * seconds / BOV_SECONDS[1]) / 0.18)) - envelope = np.minimum(t / 0.003, 1.0) * decay * _flutter(rng, t) - envelope[-512:] *= np.linspace(1.0, 0.0, 512) - out = out * envelope - return (out / np.max(np.abs(out))).astype(np.float32) +def _low_noise(sample_rate: int, width_hz: float, seconds: float, seed: int) -> np.ndarray: + """Noise only below width_hz; multiplied onto a carrier it becomes a band that wide around the carrier.""" + noise = np.random.default_rng(seed).standard_normal(int(seconds * sample_rate)) + freq = np.fft.rfftfreq(len(noise), 1 / sample_rate) + low = np.fft.irfft(np.fft.rfft(noise) * (freq < width_hz), len(noise)) + return (low / np.sqrt(np.mean(low ** 2))).astype(np.float32) def _whoosh(sample_rate: int, seconds: float = 2.0, seed: int = 9) -> np.ndarray: @@ -101,9 +82,10 @@ class Turbo: self.spool = (SPOOL_SHARE[0] * redline_rpm, SPOOL_SHARE[1] * redline_rpm) self.sample_rate = sample_rate rng = np.random.default_rng(seed) - self.releases = [_release(rng, BOV_SECONDS[1], sample_rate) for _ in range(VARIANTS)] - self.longest = max(len(release) for release in self.releases) + self.releases = load_releases(sample_rate=sample_rate) + self.longest = max((len(release) for release in self.releases), default=0) self.noise = _whoosh(sample_rate) + self.band = (_low_noise(sample_rate, WHISTLE_WIDTH_HZ / 2, 2.0, 11), _low_noise(sample_rate, WHISTLE_WIDTH_HZ / 2, 2.0, 12)) self.noise_at = 0 self.rng = rng self.tail = np.zeros(0, dtype=np.float32) @@ -113,11 +95,32 @@ class Turbo: self.closed = 0.0 self.venting = False self.phase = 0.0 - self.whistle_hz = WHISTLE_HZ[0] + self.playing = 0 # samples of the current release still to come + self.duck = 1.0 + self.engine_gain = np.ones(1, dtype=np.float32) + + def _duck(self, frames: int) -> None: + """Per-sample gain for the engine under this block: down by ENGINE_DUCK_DB while a release plays.""" + target = 10 ** (-ENGINE_DUCK_DB / 20) if self.playing > 0 else 1.0 + seconds = DUCK_SECONDS[0] if target < self.duck else DUCK_SECONDS[1] + start = self.duck + self.duck = target + (self.duck - target) * float(np.exp(-frames / self.sample_rate / seconds)) + self.engine_gain = (start + (self.duck - start) * np.arange(1, frames + 1) / frames).astype(np.float32) + self.playing = max(self.playing - frames, 0) def _target(self, rpm: float, load: float) -> float: spool = min(max((rpm - self.spool[0]) / (self.spool[1] - self.spool[0]), 0.0), 1.0) - return spool * max(load, 0.0) ** LOAD_CURVE + pedal = max(load - PEDAL_DEADZONE, 0.0) / (1.0 - PEDAL_DEADZONE) + return spool * pedal ** LOAD_CURVE + + def _whistle(self, boost: np.ndarray, index: np.ndarray) -> np.ndarray: + hz = WHISTLE_HZ[0] + (WHISTLE_HZ[1] - WHISTLE_HZ[0]) * boost + phase = self.phase + np.cumsum(hz) / self.sample_rate + self.phase = float(phase[-1] % 1.0) + carrier = 2 * np.pi * phase + air = (self.band[0][index] * np.cos(carrier) + self.band[1][index] * np.sin(carrier)) / np.sqrt(2) + out = WHISTLE_TONE * np.sin(carrier) + (1 - WHISTLE_TONE) * air + return (out * boost ** WHISTLE_CURVE).astype(np.float32) def render(self, rpm: float, load: float, frames: int, volume: float) -> np.ndarray: dt = frames / self.sample_rate @@ -142,20 +145,22 @@ class Turbo: level = self.intensity * volume if level > 0.0: ramp = (start + (self.boost - start) * np.arange(1, frames + 1) / frames).astype(np.float32) - hz = WHISTLE_HZ[0] + (WHISTLE_HZ[1] - WHISTLE_HZ[0]) * ramp - phase = self.phase + np.cumsum(hz) / self.sample_rate - self.phase = float(phase[-1] % 1.0) index = (self.noise_at + np.arange(frames)) % len(self.noise) self.noise_at = int((self.noise_at + frames) % len(self.noise)) - out[:frames] += level * (WHISTLE_LEVEL * ramp ** 1.5 * np.sin(2 * np.pi * phase).astype(np.float32) + - WHOOSH_LEVEL * ramp * self.noise[index]) - if release is not None: - sample = self.releases[self.rng.integers(VARIANTS)] + out[:frames] += level * (WHISTLE_LEVEL * self._whistle(ramp, index % len(self.band[0])) + + WHOOSH_LEVEL * ramp ** 1.5 * self.noise[index]) + if release is not None and self.releases: + sample = self.releases[self.rng.integers(len(self.releases))] share = min((release - BOV_FROM) / (1.0 - BOV_FROM), 1.0) - size = int((BOV_SECONDS[0] + (BOV_SECONDS[1] - BOV_SECONDS[0]) * share) / BOV_SECONDS[1] * len(sample)) + size = min(len(sample), int((BOV_SECONDS + (len(sample) / self.sample_rate - BOV_SECONDS) * share) * self.sample_rate)) fade = np.ones(size, dtype=np.float32) - fade[-min(size, 2048):] = np.linspace(1.0, 0.0, min(size, 2048)) + fade[-min(size, 4800):] = np.linspace(1.0, 0.0, min(size, 4800)) + if BOV_ATTACK_SECONDS > 0: + attack = min(size, int(BOV_ATTACK_SECONDS * self.sample_rate)) + fade[:attack] *= np.linspace(0.0, 1.0, attack) out[:size] += level * BOV_LEVEL * (0.6 + 0.4 * share) * sample[:size] * fade + self.playing = size + self._duck(frames) self.tail = out[frames:frames + self.longest].copy() if not self.tail.any(): self.tail = self.tail[:0] diff --git a/openpilot/starpilot/galaxy/tests/test_settings_controls.mjs b/openpilot/starpilot/galaxy/tests/test_settings_controls.mjs index d9f13d081e..e2865d18e8 100644 --- a/openpilot/starpilot/galaxy/tests/test_settings_controls.mjs +++ b/openpilot/starpilot/galaxy/tests/test_settings_controls.mjs @@ -272,7 +272,7 @@ assert.equal(previewVolume.vm.soundError, "Keep the comma offroad") assert.equal(previewVolume.vm.previewLabel, "Test alert") { - const engine = control({ label: "Engine Type", value: "LFA", choices: ["BMW M3", "BMW M52","F1 Car","Ferrari F136", "Hellcat", "Jaguar F-Type", "LFA", "Nissan Super GT", "Supra Turbo"], + const engine = control({ label: "Engine Type", value: "LFA", choices: ["BMW M3", "BMW M3 Deep", "BMW M52","F1 Car","Ferrari F136", "Hellcat", "Jaguar F-Type", "LFA", "Nissan Super GT1", "Nissan Super GT2", "Supra Turbo"], available: true, action: true, previewSound: "EngineSoundProfile" }) assert.equal(settingControl(engine.vm.row), "select") assert.equal(engine.vm.previewLabel, "Rev engine") diff --git a/openpilot/starpilot/ui/tests/test_sounds_settings.py b/openpilot/starpilot/ui/tests/test_sounds_settings.py index 8eeeecba24..1b99d09678 100644 --- a/openpilot/starpilot/ui/tests/test_sounds_settings.py +++ b/openpilot/starpilot/ui/tests/test_sounds_settings.py @@ -122,7 +122,7 @@ class SoundsSettingsTests(unittest.TestCase): self.params.put("EngineSoundProfile", "race_car", block=True) row = self.row("EngineSoundProfile") self.assertEqual((row.value, row.repair_value), ("LFA", "")) - self.assertEqual([r.value for r in self.owner.engine_type_snapshot().rows], ["", "", "", "", "", "", "Active", "", ""]) + self.assertEqual([r.value for r in self.owner.engine_type_snapshot().rows], ["", "", "", "", "", "", "", "Active", "", "", ""]) self.assertTrue(self.owner.apply(FeatureSettingsRequest("EngineSoundProfile", row.source, "BMW M52"))) self.assertEqual(self.params.get("EngineSoundProfile"), "bmw_m52") @@ -158,18 +158,19 @@ class SoundsSettingsTests(unittest.TestCase): picker = owner.engine_type_snapshot() self.assertEqual((picker.page, picker.title, picker.parent_title), (ENGINE_TYPE_PAGE, "Engine Type", "Engine Sounds")) self.assertEqual([(row.label, row.value, row.actions) for row in picker.rows], - [("BMW M3", "", (("Use", True),)), ("BMW M52", "", (("Use", True),)), ("F1 Car", "", (("Use", True),)), - ("Ferrari F136", "", (("Use", True),)), ("Hellcat", "", (("Use", True),)), + [("BMW M3", "", (("Use", True),)), ("BMW M3 Deep", "", (("Use", True),)), ("BMW M52", "", (("Use", True),)), + ("F1 Car", "", (("Use", True),)), ("Ferrari F136", "", (("Use", True),)), ("Hellcat", "", (("Use", True),)), ("Jaguar F-Type", "", (("Use", True),)), ("LFA", "Active", (("Active", True),)), - ("Nissan Super GT", "", (("Use", True),)), ("Supra Turbo", "", (("Use", True),))]) - stale = picker.rows[1] + ("Nissan Super GT1", "", (("Use", True),)), ("Nissan Super GT2", "", (("Use", True),)), + ("Supra Turbo", "", (("Use", True),))]) + stale = picker.rows[2] request = owner.engine_choice_request(stale) assert request is not None self.assertTrue(owner.apply(request)) self.assertEqual((self.params.get("EngineSoundProfile"), revs), ("bmw_m52", [1])) picker = owner.engine_type_snapshot() - self.assertEqual([row.value for row in picker.rows], ["", "Active", "", "", "", "", "", "", ""]) - replay = owner.engine_choice_request(picker.rows[1]) + self.assertEqual([row.value for row in picker.rows], ["", "", "Active", "", "", "", "", "", "", "", ""]) + replay = owner.engine_choice_request(picker.rows[2]) assert replay is not None self.assertTrue(owner.apply(replay)) self.assertEqual(revs, [1, 1]) @@ -200,7 +201,7 @@ class SoundsSettingsTests(unittest.TestCase): session._sounds_ui(FeatureUiAction("open", engine_type)) picker = session.sounds_snapshot() self.assertEqual(picker.page, ENGINE_TYPE_PAGE) - session._sounds_ui(FeatureUiAction("action", picker.rows[1], 0)) + session._sounds_ui(FeatureUiAction("action", picker.rows[2], 0)) self.assertEqual((self.params.get("EngineSoundProfile"), revs), ("bmw_m52", [1])) session._sounds_ui(FeatureUiAction("back")) self.assertEqual(session.sounds_menu, ENGINE_PAGE) diff --git a/openpilot/starpilot/ui/translation_messages.json b/openpilot/starpilot/ui/translation_messages.json index 34a0ab1eca..0bf28f9b13 100644 --- a/openpilot/starpilot/ui/translation_messages.json +++ b/openpilot/starpilot/ui/translation_messages.json @@ -32212,6 +32212,12 @@ "openpilot/starpilot/engine_sound/profiles.py" ] }, + { + "source": "BMW M3 Deep", + "refs": [ + "openpilot/starpilot/engine_sound/profiles.py" + ] + }, { "source": "BMW M52", "refs": [ @@ -32243,7 +32249,13 @@ ] }, { - "source": "Nissan Super GT", + "source": "Nissan Super GT1", + "refs": [ + "openpilot/starpilot/engine_sound/profiles.py" + ] + }, + { + "source": "Nissan Super GT2", "refs": [ "openpilot/starpilot/engine_sound/profiles.py" ] diff --git a/prebuilt.json b/prebuilt.json index d83d3f77e6..5e61610346 100644 --- a/prebuilt.json +++ b/prebuilt.json @@ -1 +1 @@ -{"protected_inventory_sha256": "60169ddc374d4c16f1fc902fc4182dc76c8f43c7f794491f9d2f126d201e38a1", "schema_version": 1} +{"protected_inventory_sha256": "36e558c11f405fbffb09905de14c222921db79be5d9495124d8d0b1e53b2e775", "schema_version": 1}