From aa2f1b6b294b74d87d7e6d9e21ed276011a417ca Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Sun, 13 Sep 2020 21:45:42 +0300 Subject: [PATCH 01/10] vehicle audio(first part) and temp fix for openAL --- .gitignore | 3 +- src/audio/AudioLogic.cpp | 381 ++++++++++++++++++++++++++++----------- src/audio/AudioManager.h | 2 + src/core/Frontend.cpp | 18 +- src/vehicles/Bike.cpp | 2 +- src/vehicles/Bike.h | 2 +- 6 files changed, 288 insertions(+), 120 deletions(-) diff --git a/.gitignore b/.gitignore index c7ebb3d1..cfb56bb6 100644 --- a/.gitignore +++ b/.gitignore @@ -351,4 +351,5 @@ MigrationBackup/ vendor/glew-2.1.0/ vendor/glfw-3.3.2.bin.WIN32/ -vendor/glfw-3.3.2.bin.WIN64/ \ No newline at end of file +vendor/glfw-3.3.2.bin.WIN64/ +/vendor/glfw-3.3.2 diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 98ebf0d8..613d847c 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -37,6 +37,7 @@ #include "Weather.h" #include "ZoneCull.h" #include "sampman.h" +#include const int channels = ARRAY_SIZE(cAudioManager::m_asActiveSamples); const int policeChannel = channels + 1; @@ -550,116 +551,116 @@ struct tVehicleSampleData { uint8 m_bDoorType; }; -const tVehicleSampleData aVehicleSettings[110] = { {SFX_CAR_REV_2, 2, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_HORN_JEEP, 9935, 1}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_56CHEV, 11487, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_8, 8, SFX_CAR_HORN_PORSCHE, 11025, SFX_CAR_HORN_JEEP, 10928, 1}, - {SFX_CAR_REV_6, 6, SFX_CAR_HORN_TRUCK, 29711, SFX_CAR_HORN_JEEP, 9935, 2}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_56CHEV, 12893, SFX_CAR_HORN_JEEP, 8941, 0}, - {SFX_CAR_REV_5, 5, SFX_CAR_HORN_BMW328, 10706, SFX_CAR_HORN_JEEP, 11922, 1}, - {SFX_CAR_REV_4, 4, SFX_CAR_HORN_TRUCK, 29711, SFX_CAR_HORN_JEEP, 7948, 2}, - {SFX_CAR_REV_6, 6, SFX_CAR_HORN_TRUCK, 29711, SFX_POLICE_SIREN_SLOW, 11556, 2}, - {SFX_CAR_REV_6, 6, SFX_CAR_HORN_TRUCK, 31478, SFX_CAR_HORN_JEEP, 8941, 2}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_BMW328, 9538, SFX_CAR_HORN_JEEP, 12220, 1}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_56CHEV, 10842, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_3, 3, SFX_CAR_HORN_BMW328, 12017, SFX_CAR_HORN_JEEP, 9935, 1}, - {SFX_CAR_REV_2, 2, SFX_CAR_HORN_JEEP, 22295, SFX_CAR_HORN_JEEP, 12200, 1}, - {SFX_CAR_REV_4, 4, SFX_CAR_HORN_BUS2, 18000, SFX_CAR_HORN_JEEP, 13400, 1}, - {SFX_CAR_REV_4, 4, SFX_CAR_HORN_BUS, 18286, SFX_CAR_HORN_JEEP, 9935, 2}, - {SFX_CAR_REV_3, 3, SFX_CAR_HORN_PORSCHE, 11025, SFX_CAR_HORN_JEEP, 13600, 1}, - {SFX_CAR_REV_4, 4, SFX_CAR_HORN_JEEP, 22295, SFX_AMBULANCE_SIREN_SLOW, 8795, 2}, - {SFX_CAR_REV_5, 5, SFX_CAR_HORN_PORSCHE, 9271, SFX_POLICE_SIREN_SLOW, 16168, 1}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_56CHEV, 12170, SFX_CAR_HORN_JEEP, 8000, 1}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_BUS2, 12345, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_2, 2, SFX_CAR_HORN_BMW328, 10796, SFX_CAR_HORN_JEEP, 8543, 1}, - {SFX_CAR_REV_5, 5, SFX_CAR_HORN_PORSCHE, 9271, SFX_CAR_HORN_JEEP, 9935, 1}, - {SFX_CAR_REV_2, 2, SFX_CAR_HORN_PICKUP, 10924, SFX_CAR_HORN_JEEP, 9935, 1}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_PICKUP, 11025, SFX_ICE_CREAM_TUNE, 11025, 0}, - {SFX_CAR_REV_7, 7, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_HORN_JEEP, 9935, 1}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_HORN_JEEP, 10000, 0}, - {SFX_CAR_REV_5, 5, SFX_CAR_HORN_BMW328, 10706, SFX_POLICE_SIREN_SLOW, 13596, 1}, - {SFX_CAR_REV_4, 4, SFX_CAR_HORN_BUS, 17260, SFX_POLICE_SIREN_SLOW, 13000, 2}, - {SFX_CAR_REV_4, 4, SFX_CAR_HORN_PICKUP, 8670, SFX_CAR_HORN_JEEP, 9935, 2}, - {SFX_CAR_REV_8, 8, SFX_CAR_HORN_PORSCHE, 10400, SFX_CAR_HORN_JEEP, 10123, 1}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 26513, SFX_POLICE_SIREN_SLOW, 13596, 0}, - {SFX_CAR_REV_6, 6, SFX_CAR_HORN_BUS2, 11652, SFX_CAR_HORN_JEEP, 10554, 3}, - {SFX_CAR_REV_6, 6, SFX_CAR_HORN_TRUCK, 29711, SFX_CAR_HORN_JEEP, 8000, 2}, - {SFX_CAR_REV_6, 6, SFX_CAR_HORN_TRUCK, 28043, SFX_CAR_HORN_JEEP, 9935, 2}, - {SFX_CAR_REV_1, 0, SFX_CAR_HORN_TRUCK, 29711, SFX_CAR_HORN_JEEP, 9935, 3}, - {SFX_CAR_REV_1, 0, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CESNA_IDLE, 0, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_6, 6, SFX_CAR_HORN_BUS, 16291, SFX_CAR_HORN_JEEP, 7500, 3}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_56CHEV, 10842, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_56CHEV, 10233, SFX_CAR_HORN_JEEP, 8935, 0}, - {SFX_CAR_REV_4, 4, SFX_CAR_HORN_PICKUP, 8670, SFX_CAR_HORN_JEEP, 8935, 0}, - {SFX_CAR_REV_1, 0, SFX_CAR_HORN_PICKUP, 2000, SFX_CAR_HORN_JEEP, 17000, 0}, - {SFX_CAR_REV_4, 4, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_4, 4, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_5, 5, SFX_CAR_HORN_BMW328, 9003, SFX_CAR_HORN_JEEP, 9935, 1}, - {SFX_CAR_REV_2, 2, SFX_CAR_HORN_PORSCHE, 12375, SFX_CAR_HORN_JEEP, 9935, 1}, - {SFX_CAR_REV_5, 5, SFX_CAR_HORN_BUS2, 15554, SFX_CAR_HORN_JEEP, 9935, 1}, - {SFX_CAR_REV_7, 7, SFX_CAR_HORN_BUS2, 13857, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_7, 7, SFX_CAR_HORN_PICKUP, 10924, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_4, 4, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 2}, - {SFX_CAR_REV_1, 0, SFX_CAR_HORN_JEEP, 20143, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 0, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_4, 4, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9000, 0}, - {SFX_CAR_REV_6, 6, SFX_CAR_HORN_TRUCK, 28043, SFX_CAR_HORN_JEEP, 9935, 2}, - {SFX_CAR_REV_4, 4, SFX_CAR_HORN_BUS, 18286, SFX_CAR_HORN_JEEP, 9935, 2}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_56CHEV, 10842, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_4, 4, SFX_CAR_HORN_BUS2, 18000, SFX_CAR_HORN_JEEP, 13400, 1}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9935, 0} }; +const tVehicleSampleData aVehicleSettings[110] = { {SFX_CAR_REV_10, 13, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_HORN_JEEP, 9935, 0}, + {SFX_CAR_REV_11, 14, SFX_CAR_HORN_56CHEV, 11487, SFX_CAR_HORN_JEEP, 9900, 0}, + {SFX_CAR_REV_2, 5, SFX_CAR_HORN_PORSCHE, 11025, SFX_CAR_HORN_JEEP, 9890, 1}, + {SFX_CAR_REV_5, 8, SFX_CAR_HORN_TRUCK, 29711, SFX_CAR_HORN_JEEP, 9960, 2}, + {SFX_CAR_REV_11, 14, SFX_CAR_HORN_56CHEV, 12893, SFX_CAR_HORN_JEEP, 9500, 0}, + {SFX_CAR_REV_4, 7, SFX_CAR_HORN_BMW328, 10706, SFX_CAR_HORN_JEEP, 9600, 1}, + {SFX_CAR_REV_1, 0, SFX_CAR_HORN_TRUCK, 29711, SFX_CAR_HORN_JEEP, 9700, 1}, + {SFX_CAR_REV_5, 8, SFX_CAR_HORN_TRUCK, 29711, SFX_POLICE_SIREN_SLOW, 10588, 2}, + {SFX_CAR_REV_5, 8, SFX_CAR_HORN_TRUCK, 31478, SFX_CAR_HORN_JEEP, 9800, 2}, + {SFX_CAR_REV_11, 14, SFX_CAR_HORN_BMW328, 9538, SFX_CAR_HORN_JEEP, 9900, 1}, + {SFX_CAR_REV_11, 14, SFX_CAR_HORN_56CHEV, 10842, SFX_CAR_HORN_JEEP, 10000, 0}, + {SFX_CAR_REV_7, 10, SFX_CAR_HORN_BMW328, 12017, SFX_CAR_HORN_JEEP, 9900, 1}, + {SFX_CAR_REV_9, 12, SFX_CAR_HORN_JEEP, 22293, SFX_CAR_HORN_JEEP, 9800, 1}, + {SFX_CAR_REV_3, 6, SFX_CAR_HORN_BUS2, 18000, SFX_CAR_HORN_JEEP, 9700, 0}, + {SFX_CAR_REV_3, 6, SFX_CAR_HORN_BUS, 18286, SFX_CAR_HORN_JEEP, 9600, 0}, + {SFX_CAR_REV_2, 5, SFX_CAR_HORN_PORSCHE, 11025, SFX_CAR_HORN_JEEP, 9500, 1}, + {SFX_CAR_REV_3, 6, SFX_CAR_HORN_JEEP, 22295, SFX_AMBULANCE_SIREN_SLOW, 12688, 0}, + {SFX_CAR_REV_4, 7, SFX_CAR_HORN_PORSCHE, 9271, SFX_POLICE_SIREN_SLOW, 11471, 1}, + {SFX_CAR_REV_11, 14, SFX_CAR_HORN_56CHEV, 12170, SFX_CAR_HORN_JEEP, 9400, 0}, + {SFX_CAR_REV_11, 14, SFX_CAR_HORN_BMW328, 11000, SFX_CAR_HORN_JEEP, 9300, 0}, + {SFX_CAR_REV_10, 13, SFX_CAR_HORN_BMW328, 10796, SFX_CAR_HORN_JEEP, 9200, 1}, + {SFX_CAR_REV_4, 7, SFX_CAR_HORN_BMW328, 10500, SFX_CAR_HORN_JEEP, 9100, 1}, + {SFX_CAR_REV_10, 13, SFX_CAR_HORN_PICKUP, 10924, SFX_CAR_HORN_JEEP, 9000, 0}, + {SFX_CAR_REV_3, 6, SFX_CAR_HORN_PICKUP, 11025, SFX_ICE_CREAM_TUNE, 11025, 0}, + {SFX_CAR_REV_6, 9, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_HORN_JEEP, 9100, 0}, + {SFX_HELI_APACHE_1, 30, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_HORN_JEEP, 9200, 1}, + {SFX_CAR_REV_4, 7, SFX_CAR_HORN_BMW328, 10706, SFX_POLICE_SIREN_SLOW, 10511, 1}, + {SFX_CAR_REV_3, 6, SFX_CAR_HORN_BUS, 17260, SFX_POLICE_SIREN_SLOW, 11029, 0}, + {SFX_CAR_REV_3, 6, SFX_CAR_HORN_PICKUP, 8670, SFX_CAR_HORN_JEEP, 9300, 0}, + {SFX_CAR_REV_7, 10, SFX_CAR_HORN_PORSCHE, 10400, SFX_CAR_HORN_JEEP, 9400, 1}, + {SFX_CAR_REV_1, 0, SFX_CAR_HORN_JEEP, 26513, SFX_POLICE_SIREN_SLOW, 11912, 1}, + {SFX_CAR_REV_5, 8, SFX_CAR_HORN_BUS2, 11652, SFX_CAR_HORN_JEEP, 9500, 3}, + {SFX_CAR_REV_5, 8, SFX_CAR_HORN_TRUCK, 29711, SFX_CAR_HORN_JEEP, 9600, 2}, + {SFX_CAR_REV_5, 8, SFX_CAR_HORN_TRUCK, 28043, SFX_CAR_HORN_JEEP, 9700, 2}, + {SFX_CAR_REV_6, 9, SFX_CAR_HORN_JEEP, 25400, SFX_CAR_HORN_JEEP, 9800, 0}, + {SFX_CAR_REV_1, 0, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_HORN_JEEP, 9900, 1}, + {SFX_CAR_REV_17, 20, SFX_CAR_HORN_JEEP, 26313, SFX_CAR_HORN_JEEP, 10000, 1}, + {SFX_CAR_REV_5, 8, SFX_CAR_HORN_BUS, 16291, SFX_CAR_HORN_JEEP, 10100, 3}, + {SFX_CAR_REV_11, 14, SFX_CAR_HORN_56CHEV, 10842, SFX_CAR_HORN_JEEP, 9900, 0}, + {SFX_CAR_REV_11, 14, SFX_CAR_HORN_56CHEV, 10233, SFX_CAR_HORN_JEEP, 9800, 1}, + {SFX_CAR_REV_3, 6, SFX_CAR_HORN_PICKUP, 8670, SFX_CAR_HORN_JEEP, 9700, 0}, + {SFX_RC_REV, 17, SFX_CAR_HORN_PICKUP, 20000, SFX_CAR_HORN_JEEP, 9600, 1}, + {SFX_CAR_REV_11, 14, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9500, 1}, + {SFX_CAR_REV_5, 8, SFX_CAR_HORN_TRUCK, 29000, SFX_CAR_HORN_JEEP, 9400, 2}, + {SFX_CAR_REV_1, 4, SFX_CAR_HORN_BMW328, 9003, SFX_CAR_HORN_JEEP, 9300, 1}, + {SFX_CAR_REV_4, 7, SFX_CAR_HORN_PORSCHE, 12375, SFX_CAR_HORN_JEEP, 9200, 1}, + {SFX_CAR_REV_1, 0, SFX_CAR_HORN_BUS2, 15554, SFX_CAR_HORN_JEEP, 9100, 1}, + {SFX_CAR_REV_1, 0, SFX_CAR_HORN_BUS2, 13857, SFX_CAR_HORN_JEEP, 9000, 2}, + {SFX_MOPED_REV, 21, SFX_CAR_HORN_JEEP, 30000, SFX_CAR_HORN_JEEP, 9100, 1}, + {SFX_CAR_REV_7, 10, SFX_CAR_HORN_JEEP, 22043, SFX_CAR_HORN_JEEP, 9200, 0}, + {SFX_CAR_REV_1, 0, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9300, 1}, + {SFX_CAR_REV_1, 0, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9400, 1}, + {SFX_CAR_REV_1, 0, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9500, 1}, + {SFX_CAR_REV_1, 0, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9600, 1}, + {SFX_CAR_REV_1, 0, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_HORN_JEEP, 9700, 1}, + {SFX_CAR_REV_5, 8, SFX_CAR_HORN_TRUCK, 28043, SFX_CAR_HORN_JEEP, 9800, 2}, + {SFX_CAR_REV_3, 6, SFX_CAR_HORN_BUS, 18286, SFX_CAR_HORN_JEEP, 9900, 0}, + {SFX_CAR_REV_12, 15, SFX_CAR_HORN_JEEP, 28500, SFX_CAR_HORN_JEEP, 9800, 1}, + {SFX_CAR_REV_1, 4, SFX_CAR_HORN_56CHEV, 10842, SFX_CAR_HORN_JEEP, 9700, 0}, + {SFX_CAR_REV_8, 11, SFX_CAR_HORN_BUS2, 18000, SFX_CAR_HORN_JEEP, 9700, 0}, + {SFX_SEAPLANE_PRO1, 35, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_HORN_JEEP, 9700, 1}, + {SFX_CAR_REV_20, 23, SFX_CAR_HORN_JEEP, 27000, SFX_CAR_HORN_JEEP, 9600, 1}, + {SFX_MOPED_REV, 21, SFX_CAR_HORN_JEEP, 31000, SFX_CAR_HORN_JEEP, 9500, 1}, + {SFX_CAR_REV_17, 20, SFX_CAR_HORN_PICKUP, 11000, SFX_CAR_HORN_JEEP, 9400, 1}, + {SFX_RC_REV, 17, SFX_CAR_HORN_JEEP, 30000, SFX_CAR_HORN_JEEP, 15000, 1}, + {SFX_CAR_RC_HELI, 18, SFX_CAR_HORN_JEEP, 30000, SFX_CAR_HORN_JEEP, 15000, 1}, + {SFX_CAR_REV_9, 12, SFX_CAR_HORN_56CHEV, 10300, SFX_CAR_HORN_JEEP, 9100, 0}, + {SFX_CAR_REV_9, 12, SFX_CAR_HORN_56CHEV, 10500, SFX_CAR_HORN_JEEP, 9000, 0}, + {SFX_CAR_REV_19, 22, SFX_CAR_HORN_JEEP, 30000, SFX_CAR_HORN_JEEP, 9000, 1}, + {SFX_CAR_REV_1, 0, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_HORN_JEEP, 9100, 2}, + {SFX_CAR_REV_3, 6, SFX_CAR_HORN_TRUCK, 28000, SFX_CAR_HORN_JEEP, 9200, 2}, + {SFX_CAR_REV_7, 10, SFX_CAR_HORN_PICKUP, 11200, SFX_CAR_HORN_JEEP, 9300, 1}, + {SFX_CAR_REV_1, 0, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_HORN_JEEP, 9400, 1}, + {SFX_CAR_REV_1, 0, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_HORN_JEEP, 9500, 1}, + {SFX_CAR_REV_9, 12, SFX_CAR_HORN_56CHEV, 10700, SFX_CAR_HORN_JEEP, 9600, 0}, + {SFX_CAR_REV_1, 4, SFX_CAR_HORN_BMW328, 9000, SFX_CAR_HORN_JEEP, 9700, 0}, + {SFX_CAR_REV_6, 9, SFX_CAR_HORN_BMW328, 9200, SFX_CAR_HORN_JEEP, 9800, 0}, + {SFX_CAR_REV_7, 10, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_HORN_JEEP, 9900, 1}, + {SFX_CAR_REV_11, 14, SFX_CAR_HORN_56CHEV, 10540, SFX_CAR_HORN_JEEP, 9935, 2}, + {SFX_CAR_REV_8, 11, SFX_CAR_HORN_PICKUP, 11000, SFX_CAR_HORN_JEEP, 9700, 1}, + {SFX_CAR_REV_2, 5, SFX_CAR_HORN_BMW328, 9500, SFX_CAR_HORN_JEEP, 9800, 1}, + {SFX_CAR_REV_7, 10, SFX_CAR_HORN_BMW328, 9700, SFX_CAR_HORN_JEEP, 9700, 1}, + {SFX_CAR_REV_8, 11, SFX_CAR_HORN_BUS2, 18000, SFX_CAR_HORN_JEEP, 9600, 0}, + {SFX_CAR_REV_3, 6, SFX_CAR_HORN_BUS, 18000, SFX_CAR_HORN_JEEP, 9500, 2}, + {SFX_CAR_REV_1, 0, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_HORN_JEEP, 9400, 1}, + {SFX_CAR_REV_8, 11, SFX_CAR_HORN_JEEP, 27513, SFX_CAR_HORN_JEEP, 9300, 1}, + {SFX_CAR_REV_8, 11, SFX_CAR_HORN_56CHEV, 10700, SFX_CAR_HORN_JEEP, 9200, 0}, + {SFX_CAR_REV_1, 0, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_HORN_JEEP, 9100, 2}, + {SFX_CAR_REV_1, 0, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_HORN_JEEP, 9000, 2}, + {SFX_CAR_REV_10, 13, SFX_CAR_HORN_BUS2, 18000, SFX_CAR_HORN_JEEP, 9100, 2}, + {SFX_CAR_REV_1, 4, SFX_CAR_HORN_BUS2, 17900, SFX_POLICE_SIREN_SLOW, 10511, 2}, + {SFX_CAR_REV_4, 7, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_HORN_JEEP, 9200, 1}, + {SFX_CAR_REV_8, 11, SFX_CAR_HORN_BMW328, 9600, SFX_CAR_HORN_JEEP, 9300, 1}, + {SFX_CAR_REV_4, 0, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_HORN_JEEP, 9400, 1}, + {SFX_CAR_REV_7, 10, SFX_CAR_HORN_PORSCHE, 10000, SFX_CAR_HORN_JEEP, 9500, 0}, + {SFX_CAR_REV_6, 9, SFX_CAR_HORN_PORSCHE, 10500, SFX_CAR_HORN_JEEP, 9600, 0}, + {SFX_CAR_REV_10, 13, SFX_CAR_HORN_JEEP, 25513, SFX_CAR_HORN_JEEP, 9700, 1}, + {SFX_CAR_REV_1, 0, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_HORN_JEEP, 9800, 1}, + {SFX_CAR_REV_3, 6, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_HORN_JEEP, 9900, 1}, + {SFX_CAR_REV_10, 13, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_HORN_JEEP, 9800, 1}, + {SFX_CAR_REV_1, 4, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_HORN_JEEP, 9700, 1}, + {SFX_CAR_RC_HELI, 18, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_HORN_JEEP, 9600, 1}, + {SFX_CAR_REV_6, 9, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_HORN_JEEP, 9700, 1}, + {SFX_CAR_REV_7, 10, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_HORN_JEEP, 9600, 1}, + {SFX_CAR_REV_1, 4, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_HORN_JEEP, 9500, 1}, + {SFX_CAR_REV_9, 12, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_HORN_JEEP, 9400, 1}, + {SFX_CAR_REV_2, 5, SFX_CAR_HORN_PORSCHE, 11025, SFX_POLICE_SIREN_SLOW, 11000, 1}, + {SFX_CAR_REV_1, 4, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_HORN_JEEP, 9200, 1}, + {SFX_CAR_REV_1, 4, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_HORN_JEEP, 9300, 1}, + {SFX_CAR_REV_1, 4, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_HORN_JEEP, 9400, 1} }; bool bPlayerJustEnteredCar; @@ -692,6 +693,10 @@ cAudioManager::ProcessVehicle(CVehicle *veh) cVehicleParams params; m_sQueueSample.m_vecPos = veh->GetPosition(); + float gas; + float gasPedalAudio; + float tmp; + params.m_bDistanceCalculated = false; params.m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos); params.m_pVehicle = veh; @@ -717,6 +722,7 @@ cAudioManager::ProcessVehicle(CVehicle *veh) ((CAutomobile *)veh)->m_fVelocityChangeForAudio = params.m_fVelocityChange; break; } + if (params.m_nIndex == DODO) { if (!ProcessVehicleRoadNoise(¶ms)) { ProcessVehicleOneShots(¶ms); @@ -770,6 +776,34 @@ cAudioManager::ProcessVehicle(CVehicle *veh) ProcessPlane(¶ms); ProcessVehicleOneShots(¶ms); break; + case VEHICLE_TYPE_BIKE: + gas = fabs(params.m_pVehicle->m_fGasPedal); + gasPedalAudio = ((CBike*)params.m_pVehicle)->m_fGasPedalAudio; + if (gas <= gasPedalAudio) { + tmp = gasPedalAudio = 0.07f; + if (tmp <= gas) + tmp = gas; + } else { + tmp = gasPedalAudio + 0.09f; + if (tmp < gas) + tmp = gas; + } + ((CBike*)params.m_pVehicle)->m_fGasPedalAudio = tmp; + + if (ProcessVehicleRoadNoise(¶ms)) { + if (CWeather::WetRoads > 0.0f) + ProcessWetRoadNoise(¶ms); + ProcessVehicleSkidding(¶ms); + ProcessVehicleHorn(¶ms); + ProcessVehicleSirenOrAlarm(¶ms); + ProcessCarBombTick(¶ms); + ProcessEngineDamage(¶ms); + ProcessVehicleEngine(¶ms); + //ProcessVehicleFlatTyre(); + } + ProcessVehicleOneShots(¶ms); + ((CBike*)veh)->m_fVelocityChangeForAudio = params.m_fVelocityChange; + break; default: break; } @@ -1048,6 +1082,16 @@ cAudioManager::ProcessVehicleEngine(cVehicleParams *params) SampleManager.StopChannel(m_nActiveSamples); return; } + if (!params->m_bDistanceCalculated) { + if (params->m_fDistance <= 0.0) + m_sQueueSample.m_fDistance = 0.0; + else + m_sQueueSample.m_fDistance = sqrt(params->m_fDistance); + } + //if (playerVeh == veh /*&& veh->m_modelIndex != DODO(187)*/) { + // ProcessPlayersVehicleEngine(params, params->m_pVehicle); + // return; + //} if (veh->bEngineOn) { CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); automobile = (CAutomobile *)params->m_pVehicle; @@ -1293,6 +1337,123 @@ cAudioManager::ProcessCesna(cVehicleParams *params) } } +void +cAudioManager::ProcessPlayersVehicleEngine1(cVehicleParams* params, CVehicle* veh) +{ + int accelerateState; + int brakeState; + float velocityChange; + bool isAccelerate; + + bool isPizzaOrFaggio; + + CBike* bikeVehicle; + CAutomobile* automobileVehicle; + uint8 wheelsOnGround; + uint8 wheelsOnGroundPrev; + float* gasPedalAudio; + tWheelState* wheelsState; + float velocityChangeForAudio; + + cTransmission* transmission; + bool lostTraction; + int wheelInUseCounter; + float time; + int freqModifier; + + if (bPlayerJustEnteredCar) { + + } + if (CReplay::IsPlayingBack()) { + accelerateState = accelerateState = 255.f * clamp(veh->m_fGasPedal, 0.0f, 1.0f); + brakeState = 255.f * clamp(veh->m_fGasPedal, 0.0f, 1.0f); + } else { + accelerateState = Pads[0].GetAccelerate(); + brakeState = Pads[0].GetBrake(); + } + velocityChange = params->m_fVelocityChange; + isAccelerate = velocityChange >= -0.001; + isPizzaOrFaggio = veh->m_modelIndex == MI_PIZZABOY || veh->m_modelIndex == MI_FAGGIO; + + + switch (params->m_VehicleType) + { + case VEHICLE_TYPE_CAR: + automobileVehicle = (CAutomobile*)params->m_pVehicle; + wheelsOnGround = automobileVehicle->m_nDriveWheelsOnGround; + wheelsOnGroundPrev = automobileVehicle->m_nDriveWheelsOnGroundPrev; + gasPedalAudio = &automobileVehicle->m_fGasPedalAudio; + wheelsState = automobileVehicle->m_aWheelState; + velocityChangeForAudio = automobileVehicle->m_fVelocityChangeForAudio; + break; + case VEHICLE_TYPE_BIKE: + bikeVehicle = (CBike*)params->m_pVehicle; + wheelsOnGround = bikeVehicle->m_nDriveWheelsOnGround; + wheelsOnGroundPrev = bikeVehicle->m_nDriveWheelsOnGroundPrev; + gasPedalAudio = &bikeVehicle->m_fGasPedalAudio; + wheelsState = bikeVehicle->m_aWheelState; + velocityChangeForAudio = bikeVehicle->m_fVelocityChangeForAudio; + break; + default: + break; + } + + transmission = params->m_pTransmission; + switch (transmission->nDriveType) + { + case '4': + if (params->m_VehicleType != VEHICLE_TYPE_BIKE) { + wheelInUseCounter = 0; + for (uint8 i = 0; i < ARRAY_SIZE(wheelsState); i++) { + if (wheelsState[i] != WHEEL_STATE_NORMAL) + ++wheelInUseCounter; + } + if (wheelInUseCounter > 2) + lostTraction = true; + } + break; + case 'F': + if (params->m_VehicleType == VEHICLE_TYPE_BIKE) { + if (wheelsState[BIKEWHEEL_FRONT] != WHEEL_STATE_NORMAL) + lostTraction = true; + } else { + if ((wheelsState[CARWHEEL_FRONT_LEFT] != WHEEL_STATE_NORMAL || wheelsState[CARWHEEL_FRONT_RIGHT] != WHEEL_STATE_NORMAL) && + (wheelsState[CARWHEEL_REAR_LEFT] != WHEEL_STATE_NORMAL || wheelsState[CARWHEEL_REAR_RIGHT] != WHEEL_STATE_NORMAL)) + lostTraction = true; + } + break; + case 'R': + if (params->m_VehicleType == VEHICLE_TYPE_BIKE) { + if (wheelsState[BIKEWHEEL_REAR] != WHEEL_STATE_NORMAL) + lostTraction = true; + } + else { + if (wheelsState[CARWHEEL_REAR_LEFT] != WHEEL_STATE_NORMAL || wheelsState[CARWHEEL_REAR_RIGHT] != WHEEL_STATE_NORMAL) + lostTraction = true; + } + break; + default: + break; + } + + if (velocityChange != 0.0f) { + time = params->m_pVehicle->m_vecMoveSpeed.z / velocityChange; + if (time > 0.0f) + freqModifier = -(Min(0.2f, time) * 3000.0f * 5.0f); + else + freqModifier = -(Max(-0.2f, time) * 3000.0f * 5.0f); + if (params->m_fVelocityChange < -0.001f) + freqModifier = -freqModifier; + } + else + freqModifier = 0; + + if (params->m_VehicleType == VEHICLE_TYPE_BIKE && bikeVehicle->bIsStanding) + freqModifier += 1400; + + +} + void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile *automobile) { diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index b34dbed0..2f76144b 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -143,6 +143,7 @@ public: class cVehicleParams { public: + int32 m_VehicleType; bool m_bDistanceCalculated; float m_fDistance; CVehicle *m_pVehicle; @@ -319,6 +320,7 @@ public: #endif bool ProcessCarBombTick(cVehicleParams *params); void ProcessCesna(cVehicleParams *params); + void ProcessPlayersVehicleEngine1(cVehicleParams* params, CVehicle* veh); //void ProcessCrane(); bool ProcessEngineDamage(cVehicleParams *params); void ProcessEntity(int32 sound); diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index cdecb8b4..9c33d48a 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -1121,15 +1121,19 @@ CMenuManager::DrawStandardMenus(bool drawCurrScreen) rightText = TheText.Get("FEA_ADP"); else { char* provider = DMAudio.Get3DProviderName(m_nPrefsAudio3DProviderIndex); - - if (!strcmp(strupr(provider), "DIRECTSOUND3D HARDWARE SUPPORT")) { - strcpy(provider, "DSOUND3D HARDWARE SUPPORT"); + if (provider != NULL) { + if (!strcmp(strupr(provider), "DIRECTSOUND3D HARDWARE SUPPORT")) { + strcpy(provider, "DSOUND3D HARDWARE SUPPORT"); + } + else if (!strcmp(strupr(provider), "DIRECTSOUND3D SOFTWARE EMULATION")) { + strcpy(provider, "DSOUND3D SOFTWARE EMULATION"); + } + AsciiToUnicode(provider, unicodeTemp); + rightText = unicodeTemp; } - else if (!strcmp(strupr(provider), "DIRECTSOUND3D SOFTWARE EMULATION")) { - strcpy(provider, "DSOUND3D SOFTWARE EMULATION"); + else { + rightText = TheText.Get("not defined"); } - AsciiToUnicode(provider, unicodeTemp); - rightText = unicodeTemp; } break; case MENUACTION_SPEAKERCONF: { diff --git a/src/vehicles/Bike.cpp b/src/vehicles/Bike.cpp index 62aeface..b5bc9480 100644 --- a/src/vehicles/Bike.cpp +++ b/src/vehicles/Bike.cpp @@ -129,7 +129,7 @@ CBike::CBike(int32 id, uint8 CreatedBy) m_fTireTemperature = 1.0f; m_fBrakeDestabilization = 0.0f; - field_490 = 0; + m_fVelocityChangeForAudio = 0; for(i = 0; i < 2; i++){ m_aWheelRotation[i] = 0.0f; diff --git a/src/vehicles/Bike.h b/src/vehicles/Bike.h index 669e236e..cee670a3 100644 --- a/src/vehicles/Bike.h +++ b/src/vehicles/Bike.h @@ -77,7 +77,7 @@ public: int16 m_doingBurnout; float m_fTireTemperature; float m_fBrakeDestabilization; - uint32 field_490; + float m_fVelocityChangeForAudio; float m_fFireBlowUpTimer; CPhysical *m_aGroundPhysical[4]; CVector m_aGroundOffset[4]; From 16dab00bec01be021eb0728beff6dd5d20e6f268 Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Mon, 14 Sep 2020 21:47:00 +0300 Subject: [PATCH 02/10] finish work on ProcessPlayerVehicleEngine and cleanup --- src/audio/AudioLogic.cpp | 614 +++++++++++++++++++++++---------------- src/audio/AudioManager.h | 3 +- 2 files changed, 359 insertions(+), 258 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 2b9e622e..ab7c1835 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -39,6 +39,7 @@ #include "sampman.h" #include + const int channels = ARRAY_SIZE(cAudioManager::m_asActiveSamples); const int policeChannel = channels + 1; const int allChannels = channels + 2; @@ -725,6 +726,7 @@ cAudioManager::ProcessVehicle(CVehicle *veh) else velChange = DotProduct(params.m_pVehicle->m_vecMoveSpeed, params.m_pVehicle->GetForward()); params.m_fVelocityChange = velChange; + params.m_VehicleType = params.m_pVehicle->m_vehType; switch (params.m_pVehicle->m_vehType) { case VEHICLE_TYPE_CAR: UpdateGasPedalAudio((CAutomobile *)veh); @@ -1112,7 +1114,7 @@ cAudioManager::ProcessVehicleEngine(cVehicleParams *params) return; } if (FindPlayerVehicle() == veh) { - ProcessPlayersVehicleEngine(params, automobile); + ProcessPlayersVehicleEngine(params, params->m_pVehicle); return; } transmission = params->m_pTransmission; @@ -1349,208 +1351,164 @@ cAudioManager::ProcessCesna(cVehicleParams *params) } } -void -cAudioManager::ProcessPlayersVehicleEngine1(cVehicleParams* params, CVehicle* veh) +void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle* veh) { - int accelerateState; - int brakeState; - float velocityChange; - bool isAccelerate; - - bool isPizzaOrFaggio; - - CBike* bikeVehicle; - CAutomobile* automobileVehicle; - uint8 wheelsOnGround; - uint8 wheelsOnGroundPrev; - float* gasPedalAudio; - tWheelState* wheelsState; - float velocityChangeForAudio; - - cTransmission* transmission; - bool lostTraction; - int wheelInUseCounter; - float time; - int freqModifier; - - if (bPlayerJustEnteredCar) { - - } - if (CReplay::IsPlayingBack()) { - accelerateState = accelerateState = 255.f * clamp(veh->m_fGasPedal, 0.0f, 1.0f); - brakeState = 255.f * clamp(veh->m_fGasPedal, 0.0f, 1.0f); - } else { - accelerateState = Pads[0].GetAccelerate(); - brakeState = Pads[0].GetBrake(); - } - velocityChange = params->m_fVelocityChange; - isAccelerate = velocityChange >= -0.001; - isPizzaOrFaggio = veh->m_modelIndex == MI_PIZZABOY || veh->m_modelIndex == MI_FAGGIO; - - - switch (params->m_VehicleType) - { - case VEHICLE_TYPE_CAR: - automobileVehicle = (CAutomobile*)params->m_pVehicle; - wheelsOnGround = automobileVehicle->m_nDriveWheelsOnGround; - wheelsOnGroundPrev = automobileVehicle->m_nDriveWheelsOnGroundPrev; - gasPedalAudio = &automobileVehicle->m_fGasPedalAudio; - wheelsState = automobileVehicle->m_aWheelState; - velocityChangeForAudio = automobileVehicle->m_fVelocityChangeForAudio; - break; - case VEHICLE_TYPE_BIKE: - bikeVehicle = (CBike*)params->m_pVehicle; - wheelsOnGround = bikeVehicle->m_nDriveWheelsOnGround; - wheelsOnGroundPrev = bikeVehicle->m_nDriveWheelsOnGroundPrev; - gasPedalAudio = &bikeVehicle->m_fGasPedalAudio; - wheelsState = bikeVehicle->m_aWheelState; - velocityChangeForAudio = bikeVehicle->m_fVelocityChangeForAudio; - break; - default: - break; - } - - transmission = params->m_pTransmission; - switch (transmission->nDriveType) - { - case '4': - if (params->m_VehicleType != VEHICLE_TYPE_BIKE) { - wheelInUseCounter = 0; - for (uint8 i = 0; i < ARRAY_SIZE(wheelsState); i++) { - if (wheelsState[i] != WHEEL_STATE_NORMAL) - ++wheelInUseCounter; - } - if (wheelInUseCounter > 2) - lostTraction = true; - } - break; - case 'F': - if (params->m_VehicleType == VEHICLE_TYPE_BIKE) { - if (wheelsState[BIKEWHEEL_FRONT] != WHEEL_STATE_NORMAL) - lostTraction = true; - } else { - if ((wheelsState[CARWHEEL_FRONT_LEFT] != WHEEL_STATE_NORMAL || wheelsState[CARWHEEL_FRONT_RIGHT] != WHEEL_STATE_NORMAL) && - (wheelsState[CARWHEEL_REAR_LEFT] != WHEEL_STATE_NORMAL || wheelsState[CARWHEEL_REAR_RIGHT] != WHEEL_STATE_NORMAL)) - lostTraction = true; - } - break; - case 'R': - if (params->m_VehicleType == VEHICLE_TYPE_BIKE) { - if (wheelsState[BIKEWHEEL_REAR] != WHEEL_STATE_NORMAL) - lostTraction = true; - } - else { - if (wheelsState[CARWHEEL_REAR_LEFT] != WHEEL_STATE_NORMAL || wheelsState[CARWHEEL_REAR_RIGHT] != WHEEL_STATE_NORMAL) - lostTraction = true; - } - break; - default: - break; - } - - if (velocityChange != 0.0f) { - time = params->m_pVehicle->m_vecMoveSpeed.z / velocityChange; - if (time > 0.0f) - freqModifier = -(Min(0.2f, time) * 3000.0f * 5.0f); - else - freqModifier = -(Max(-0.2f, time) * 3000.0f * 5.0f); - if (params->m_fVelocityChange < -0.001f) - freqModifier = -freqModifier; - } - else - freqModifier = 0; - - if (params->m_VehicleType == VEHICLE_TYPE_BIKE && bikeVehicle->bIsStanding) - freqModifier += 1400; - - -} - -void -cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile *automobile) -{ - static int32 GearFreqAdj[] = {6000, 6000, 3400, 1200, 0, -1000}; - - cTransmission *transmission; - float velocityChange; - float relativeVelocityChange; - float accelerationMultipler; - uint8 wheelInUseCounter; - float time; - int baseFreq; - uint8 vol; - int gearNr; - int32 freq; - - int freqModifier; - int soundOffset; - uint8 engineSoundType; - int16 accelerateState; - bool channelUsed; - bool lostTraction; - bool processedAccelSampleStopped; - uint8 currentGear; + static int32 GearFreqAdj[] = { 6000, 6000, 3400, 1200, 0, -1000 }; + double gasPedal; // st6 + tWheelState* wheelState; + CAutomobile* automobile; // ebp + CBike* bike; // edx + float* gasPedalAudioPtr; // edi + uint8 wheelInUseCounter; // cl + int freqModifier; // [esp+Ch] [ebp-74h] + signed int accelerateState; // [esp+20h] [ebp-60h] + bool channelUsed; // [esp+2Ch] [ebp-54h] + bool lostTraction; // [esp+30h] [ebp-50h] + int engineSoundType; // [esp+1Ch] [ebp-64h] + signed int brakeState; // [esp+24h] [ebp-5Ch] + uint8 wheelsOnGround; // [esp+3Ch] [ebp-44h] float gasPedalAudio; - CVector pos; + double relativeVelocityChange; // st6 + float accelerationMultipler; // [esp+50h] [ebp-30h] + float velocityChangeForAudio; + int baseFreq; // ebp + uint8 vol; // bl + double time; // st7 + + double timeClip; // st4 + int tmp; // edx + int soundOffset; // ebx + char err; // al + + unsigned int freq_2; // edi + bool stuckInSand; // cl + + + unsigned int freq; // edi + + bool speedBool; // [esp+28h] [ebp-58h] + + unsigned __int8 currentGear; // [esp+34h] [ebp-4Ch] + char processedAccelSampleStopped; // [esp+38h] [ebp-48h] + char wheelsOnGroundPrev; // [esp+40h] [ebp-40h] + bool PizzaFaggBool; // [esp+44h] [ebp-3Ch] + + CVector pos; // [esp+64h] [ebp-1Ch] + + //67-105 static int16 LastAccel = 0; - static int16 LastBrake = 0; static uint8 CurrentPretendGear = 1; static bool bLostTractionLastFrame = false; static bool bHandbrakeOnLastFrame = false; static int32 nCruising = 0; static bool bAccelSampleStopped = true; + static uint32 curTime = CTimer::GetTimeInMilliseconds(); - lostTraction = false; - processedAccelSampleStopped = false; + lostTraction = 0; + PizzaFaggBool = 0; + processedAccelSampleStopped = 0; if (bPlayerJustEnteredCar) { - bAccelSampleStopped = true; - bPlayerJustEnteredCar = false; + bAccelSampleStopped = 1; + bPlayerJustEnteredCar = 0; nCruising = 0; LastAccel = 0; - bLostTractionLastFrame = false; - LastBrake = 0; - bHandbrakeOnLastFrame = false; + bLostTractionLastFrame = 0; CurrentPretendGear = 1; + bHandbrakeOnLastFrame = 0; } - if (CReplay::IsPlayingBack()) - accelerateState = 255.f * clamp(automobile->m_fGasPedal, 0.0f, 1.0f); - else + //106-157 + if (CReplay::IsPlayingBack()) { + accelerateState = (signed int)(255.0 * clamp(params->m_pVehicle->m_fGasPedal, 0.0, 1.0)); + brakeState = (signed int)(255.0 * clamp(params->m_pVehicle->m_fBrakePedal, 0.0, 1.0)); + } else { accelerateState = Pads[0].GetAccelerate(); - + brakeState = Pads[0].GetBrake(); + } + //158-162 + speedBool = params->m_fVelocityChange >= -0.001; channelUsed = SampleManager.GetChannelUsedFlag(m_nActiveSamples); - transmission = params->m_pTransmission; - velocityChange = params->m_fVelocityChange; - relativeVelocityChange = 2.0f * velocityChange / transmission->fMaxVelocity; - - accelerationMultipler = clamp(relativeVelocityChange, 0.0f, 1.0f); - gasPedalAudio = accelerationMultipler; - currentGear = params->m_pVehicle->m_nCurrentGear; - - switch (transmission->nDriveType) - { - case '4': - wheelInUseCounter = 0; - for (uint8 i = 0; i < ARRAY_SIZE(automobile->m_aWheelState); i++) { - if (automobile->m_aWheelState[i] != WHEEL_STATE_NORMAL) - ++wheelInUseCounter; + //163-184 + if (params->m_pVehicle->m_modelIndex != MI_PIZZABOY + && params->m_pVehicle->m_modelIndex != MI_FAGGIO) { + currentGear = params->m_pVehicle->m_nCurrentGear; + } else { + CurrentPretendGear = params->m_pTransmission->nNumberOfGears; + currentGear = CurrentPretendGear; + if (params->m_pVehicle->bIsHandbrakeOn) { + brakeState = 0; + nCruising = 0; + LastAccel = 0; + accelerateState = 0; + } else { + nCruising = 1; } - if (wheelInUseCounter > 2) - lostTraction = true; - break; - case 'F': - if ((automobile->m_aWheelState[CARWHEEL_FRONT_LEFT] != WHEEL_STATE_NORMAL || automobile->m_aWheelState[CARWHEEL_FRONT_RIGHT] != WHEEL_STATE_NORMAL) && - (automobile->m_aWheelState[CARWHEEL_REAR_LEFT] != WHEEL_STATE_NORMAL || automobile->m_aWheelState[CARWHEEL_REAR_RIGHT] != WHEEL_STATE_NORMAL)) - lostTraction = true; - break; - case 'R': - if ((automobile->m_aWheelState[CARWHEEL_REAR_LEFT] != WHEEL_STATE_NORMAL) || (automobile->m_aWheelState[CARWHEEL_REAR_RIGHT] != WHEEL_STATE_NORMAL)) - lostTraction = true; - break; + PizzaFaggBool = true; } - if (velocityChange != 0.0f) { - time = params->m_pVehicle->m_vecMoveSpeed.z / velocityChange; + //185-205 + switch (params->m_VehicleType) { + case VEHICLE_TYPE_CAR: + automobile = (CAutomobile*)params->m_pVehicle; + wheelsOnGround = automobile->m_nDriveWheelsOnGround; + wheelsOnGroundPrev = automobile->m_nDriveWheelsOnGroundPrev; + gasPedalAudioPtr = (float*)&automobile->m_fGasPedalAudio; + wheelState = automobile->m_aWheelState; + velocityChangeForAudio = automobile->m_fVelocityChangeForAudio; + break; + case VEHICLE_TYPE_BIKE: + bike = (CBike*)params->m_pVehicle; + wheelsOnGround = bike->m_nDriveWheelsOnGround; + wheelsOnGroundPrev = bike->m_nDriveWheelsOnGroundPrev; + gasPedalAudioPtr = &bike->m_fGasPedalAudio; + wheelState = bike->m_aWheelState; + velocityChangeForAudio = bike->m_fVelocityChangeForAudio; + break; + //641-644 + default: + //dbgprint(" ** AUDIOLOG: Unrecognised vehicle type %d in ProcessVehicleEngine() * \n", vehType); + return; + } + if (!PizzaFaggBool) { + //208-253 + switch (params->m_pTransmission->nDriveType) { + case '4': + if (params->m_VehicleType != VEHICLE_TYPE_BIKE) { + wheelInUseCounter = 0; + for (uint8 i = 0; i < ARRAY_SIZE(wheelState); i++) { + if (wheelState[i] != WHEEL_STATE_NORMAL) + ++wheelInUseCounter; + } + if (wheelInUseCounter > 2) + lostTraction = true; + } + break; + case 'F': + if (params->m_VehicleType == VEHICLE_TYPE_BIKE) { + if (wheelState[BIKEWHEEL_FRONT] != WHEEL_STATE_NORMAL) + lostTraction = true; + } else { + if ((wheelState[CARWHEEL_FRONT_LEFT] != WHEEL_STATE_NORMAL || wheelState[CARWHEEL_FRONT_RIGHT] != WHEEL_STATE_NORMAL) && + (wheelState[CARWHEEL_REAR_LEFT] != WHEEL_STATE_NORMAL || wheelState[CARWHEEL_REAR_RIGHT] != WHEEL_STATE_NORMAL)) + lostTraction = true; + } + break; + case 'R': + if (params->m_VehicleType == VEHICLE_TYPE_BIKE) { + if (wheelState[BIKEWHEEL_REAR] != WHEEL_STATE_NORMAL) + lostTraction = true; + } else { + if (wheelState[CARWHEEL_REAR_LEFT] != WHEEL_STATE_NORMAL || wheelState[CARWHEEL_REAR_RIGHT] != WHEEL_STATE_NORMAL) + lostTraction = true; + } + break; + default: + break; + } + } + //254-281 + if (params->m_fVelocityChange != 0.0f) { + time = params->m_pVehicle->m_vecMoveSpeed.z / params->m_fVelocityChange; if (time > 0.0f) freqModifier = -(Min(0.2f, time) * 3000.0f * 5.0f); else @@ -1559,138 +1517,282 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile * freqModifier = -freqModifier; } else freqModifier = 0; - + //282-283 + if (params->m_VehicleType == VEHICLE_TYPE_BIKE && bike->bExtraSpeed) + freqModifier += 1400; + //TODO rewtire this part + //284-349 + tmp = 0; engineSoundType = aVehicleSettings[params->m_nIndex].m_nBank; - soundOffset = 3 * (engineSoundType - CAR_SAMPLEBANKS_OFFSET); + soundOffset = 3 * (engineSoundType - 4); + err = 0; + switch (soundOffset) { + case 0: + tmp = 2526; + break; + case 3: + tmp = 3587; + break; + case 6: + tmp = 4898; + break; + case 9: + tmp = 4003; + break; + case 12: + tmp = 6289; + break; + case 15: + tmp = 2766; + break; + case 18: + tmp = 3523; + break; + case 21: + tmp = 2773; + break; + case 24: + tmp = 2560; + break; + case 27: + tmp = 4228; + break; + case 30: + tmp = 4648; + break; + case 48: + tmp = 3480; + break; + case 54: + tmp = 2380; + break; + case 57: + tmp = 2410; + break; + default: + err = 1; + break; + } + if (!channelUsed || nCruising || err) { + curTime = CTimer::GetTimeInMilliseconds(); + } else { + tmp -= 1000; + if (CTimer::GetTimeInMilliseconds() - curTime > tmp) { + channelUsed = 0; + curTime = CTimer::GetTimeInMilliseconds(); + } + } + //349-366 + relativeVelocityChange = 2.0 * params->m_fVelocityChange / params->m_pTransmission->fMaxVelocity; + accelerationMultipler = clamp(relativeVelocityChange, 0.0, 1.0); + gasPedalAudio = accelerationMultipler; + //367-380 + switch (engineSoundType) { + case 21: + ++soundOffset; + break; + case 22: + soundOffset += 2; + break; + case 23: + soundOffset += 3; + break; + default: + break; + } + //381-476 if (accelerateState <= 0) { if (params->m_fVelocityChange < -0.001f) { if (channelUsed) { SampleManager.StopChannel(m_nActiveSamples); bAccelSampleStopped = true; } - if (automobile->m_nWheelsOnGround == 0 || automobile->bIsHandbrakeOn || lostTraction) - gasPedalAudio = automobile->m_fGasPedalAudio; + if (wheelsOnGround == 0 || params->m_pVehicle->bIsHandbrakeOn || lostTraction) + gasPedalAudio = *gasPedalAudioPtr; + else if (params->m_VehicleType == VEHICLE_TYPE_BIKE) + gasPedalAudio = 0.0; else gasPedalAudio = Min(1.0f, params->m_fVelocityChange / params->m_pTransmission->fMaxReverseVelocity); - - gasPedalAudio = Max(0.0f, gasPedalAudio); - automobile->m_fGasPedalAudio = gasPedalAudio; + *gasPedalAudioPtr = Max(0.0f, gasPedalAudio); } else if (LastAccel > 0) { if (channelUsed) { SampleManager.StopChannel(m_nActiveSamples); bAccelSampleStopped = true; } nCruising = 0; - if (automobile->m_nWheelsOnGround == 0 || automobile->bIsHandbrakeOn || lostTraction || - params->m_fVelocityChange < 0.01f && automobile->m_fGasPedalAudio > 0.2f) { - automobile->m_fGasPedalAudio *= 0.6f; - gasPedalAudio = automobile->m_fGasPedalAudio; + if (wheelsOnGround == 0 + || params->m_pVehicle->bIsHandbrakeOn + || lostTraction + || params->m_fVelocityChange < 0.01f && *gasPedalAudioPtr > 0.2f) { + if (!PizzaFaggBool) { + *gasPedalAudioPtr *= 0.6f; + gasPedalAudio = *gasPedalAudioPtr; + } else + gasPedalAudio = 0.0f; } if (gasPedalAudio > 0.05f) { freq = (5000.f * (gasPedalAudio - 0.05f) * 20.f / 19) + 19000; - if (engineSoundType == SAMPLEBANK_CAR_MACKTRUCK) + vol = (25.0 * (gasPedalAudio - 0.05f) * 20.f / 19) + 40; + if (params->m_pVehicle->bIsDrowning) + vol /= 4; + if (engineSoundType == SAMPLEBANK_CAR_COBRA) freq /= 2; - AddPlayerCarSample((25.f * (gasPedalAudio - 0.05f) * 20.f / 19) + 40, freq, (soundOffset + SFX_CAR_FINGER_OFF_ACCEL_1), engineSoundType, 63, - false); + AddPlayerCarSample(vol, freq, soundOffset + SFX_CAR_FINGER_OFF_ACCEL_1, engineSoundType, 63, false); } } freq = (10000.f * gasPedalAudio) + 22050; - if (engineSoundType == SAMPLEBANK_CAR_MACKTRUCK) + vol = 110 - (40.0 * gasPedalAudio); + if (engineSoundType == SAMPLEBANK_CAR_COBRA) freq /= 2; - AddPlayerCarSample(110 - (40.f * gasPedalAudio), freq, (engineSoundType - CAR_SAMPLEBANKS_OFFSET + SFX_CAR_IDLE_1), SAMPLEBANK_MAIN, 52, true); + if (params->m_pVehicle->bIsDrowning) + vol /= 4; + AddPlayerCarSample(vol, freq, engineSoundType + SFX_CAR_IDLE_1 - 4, SAMPLEBANK_MAIN, 52, true); CurrentPretendGear = Max(1, currentGear); - } else { - while (nCruising == 0) { - if (accelerateState < 150 || automobile->m_nWheelsOnGround == 0 || automobile->bIsHandbrakeOn || lostTraction || - currentGear < 2 && velocityChange - automobile->m_fVelocityChangeForAudio < 0.01f) { // here could be used abs - if (automobile->m_nWheelsOnGround == 0 || automobile->bIsHandbrakeOn || lostTraction) { - if (automobile->m_nWheelsOnGround == 0 && automobile->m_nDriveWheelsOnGround != 0 || - (automobile->bIsHandbrakeOn && !bHandbrakeOnLastFrame || lostTraction && !bLostTractionLastFrame) && automobile->m_nWheelsOnGround != 0) { - automobile->m_fGasPedalAudio *= 0.6f; + } + //477-515 + else { + if (nCruising == 0){ + stuckInSand = params->m_VehicleType == VEHICLE_TYPE_CAR && ((CAutomobile*)params->m_pVehicle)->bStuckInSand; + if (accelerateState < 150 || wheelsOnGround == 0 || params->m_pVehicle->bIsHandbrakeOn || lostTraction + || currentGear < 2 && params->m_fVelocityChange - velocityChangeForAudio >= 0.01f || brakeState > 0) { + if ((wheelsOnGround && !params->m_pVehicle->bIsHandbrakeOn && !lostTraction || !stuckInSand) + && brakeState <= 0) { + baseFreq = (8000.0f * accelerationMultipler) + 16000; + vol = (25.0f * accelerationMultipler) + 60; + *gasPedalAudioPtr = accelerationMultipler; + } else { + if (wheelsOnGround == 0 && wheelsOnGroundPrev != 0 + || (params->m_pVehicle->bIsHandbrakeOn && !bHandbrakeOnLastFrame || lostTraction && !bLostTractionLastFrame) + && wheelsOnGround != 0) { + *gasPedalAudioPtr *= 0.6f; } freqModifier = 0; - baseFreq = (15000.f * automobile->m_fGasPedalAudio) + 14000; - vol = (25.0f * automobile->m_fGasPedalAudio) + 60; - } else { - baseFreq = (8000.f * accelerationMultipler) + 16000; - vol = (25.0f * accelerationMultipler) + 60; - automobile->m_fGasPedalAudio = accelerationMultipler; + if (engineSoundType != 15 && engineSoundType != 16) + baseFreq = (25000.0f * *gasPedalAudioPtr) + 14000; + else + baseFreq = (15000.0f * *gasPedalAudioPtr) + 14000; + vol = (25.0f * *gasPedalAudioPtr) + 60; } + //516-535 freq = freqModifier + baseFreq; - if (engineSoundType == SAMPLEBANK_CAR_MACKTRUCK) + if (engineSoundType == SAMPLEBANK_CAR_COBRA) freq /= 2; if (channelUsed) { SampleManager.StopChannel(m_nActiveSamples); bAccelSampleStopped = true; } - AddPlayerCarSample(vol, freq, (engineSoundType - CAR_SAMPLEBANKS_OFFSET + SFX_CAR_REV_1), SAMPLEBANK_MAIN, 2, true); + if (params->m_pVehicle->bIsDrowning) + vol /= 4; + AddPlayerCarSample(vol, freq, engineSoundType + SFX_CAR_REV_1 - 4, SAMPLEBANK_MAIN, 2, true); } else { - TranslateEntity(&m_sQueueSample.m_vecPos, &pos); + //536-548 + cAudioManager::TranslateEntity(&m_sQueueSample.m_vecPos, &pos); if (bAccelSampleStopped) { - if (CurrentPretendGear != 1 || currentGear != 2) { - gearNr = currentGear - 1; - if (gearNr < 1) - gearNr = 1; - CurrentPretendGear = gearNr; - } + if (CurrentPretendGear != 1 || currentGear != 2) + CurrentPretendGear = Max(1, currentGear - 1); processedAccelSampleStopped = true; bAccelSampleStopped = false; } - - if (!channelUsed) { - if (!processedAccelSampleStopped) { - if (CurrentPretendGear < params->m_pTransmission->nNumberOfGears - 1) - ++CurrentPretendGear; - else { - nCruising = 1; - break; // while was used just for this fucking place - } + //549- + if (channelUsed) { + SampleManager.SetChannelEmittingVolume(m_nActiveSamples, 120); + SampleManager.SetChannel3DPosition(m_nActiveSamples, pos.x, pos.y, pos.z); + SampleManager.SetChannel3DDistances(m_nActiveSamples, 50.0f, 12.5f); + freq = (GearFreqAdj[CurrentPretendGear] + freqModifier + 22050) ; + if (engineSoundType == 8) + freq /= 2; + SampleManager.SetChannelFrequency(m_nActiveSamples, freq); + if (!channelUsed) { + SampleManager.SetChannelReverbFlag(m_nActiveSamples, m_bDynamicAcousticModelingStatus != false); + SampleManager.StartChannel(m_nActiveSamples); } - + } else if (processedAccelSampleStopped) { + curTime = CTimer::GetTimeInMilliseconds(); + params->m_pVehicle->bAudioChangingGear = true; if (!SampleManager.InitialiseChannel(m_nActiveSamples, soundOffset + SFX_CAR_ACCEL_1, SAMPLEBANK_MAIN)) return; SampleManager.SetChannelLoopCount(m_nActiveSamples, 1); SampleManager.SetChannelLoopPoints(m_nActiveSamples, 0, -1); - } - SampleManager.SetChannelEmittingVolume(m_nActiveSamples, 85); - SampleManager.SetChannel3DPosition(m_nActiveSamples, pos.x, pos.y, pos.z); - SampleManager.SetChannel3DDistances(m_nActiveSamples, 50.f, 12.5f); - freq = GearFreqAdj[CurrentPretendGear] + freqModifier + 22050; - if (engineSoundType == SAMPLEBANK_CAR_MACKTRUCK) - freq /= 2; - SampleManager.SetChannelFrequency(m_nActiveSamples, freq); - if (!channelUsed) { - SampleManager.SetChannelReverbFlag(m_nActiveSamples, m_bDynamicAcousticModelingStatus != false); - SampleManager.StartChannel(m_nActiveSamples); + SampleManager.SetChannelEmittingVolume(m_nActiveSamples, 120); + SampleManager.SetChannel3DPosition(m_nActiveSamples, pos.x, pos.y, pos.z); + SampleManager.SetChannel3DDistances(m_nActiveSamples, 50.0f, 12.5f); + freq = (GearFreqAdj[CurrentPretendGear] + freqModifier + 22050); + if (engineSoundType == 8) + freq /= 2; + SampleManager.SetChannelFrequency(m_nActiveSamples, freq); + if (!channelUsed) { + SampleManager.SetChannelReverbFlag(m_nActiveSamples, m_bDynamicAcousticModelingStatus != false); + SampleManager.StartChannel(m_nActiveSamples); + } + } else if (CurrentPretendGear < params->m_pTransmission->nNumberOfGears - 1) { + ++CurrentPretendGear; + curTime = CTimer::GetTimeInMilliseconds(); + params->m_pVehicle->bAudioChangingGear = true; + if (!SampleManager.InitialiseChannel(m_nActiveSamples, soundOffset + SFX_CAR_ACCEL_1, SAMPLEBANK_MAIN)) + return; + SampleManager.SetChannelLoopCount(m_nActiveSamples, 1); + SampleManager.SetChannelLoopPoints(m_nActiveSamples, 0, -1); + + SampleManager.SetChannelEmittingVolume(m_nActiveSamples, 120); + SampleManager.SetChannel3DPosition(m_nActiveSamples, pos.x, pos.y, pos.z); + SampleManager.SetChannel3DDistances(m_nActiveSamples, 50.0f, 12.5f); + freq = (GearFreqAdj[CurrentPretendGear] + freqModifier + 22050); + if (engineSoundType == 8) + freq /= 2; + SampleManager.SetChannelFrequency(m_nActiveSamples, freq); + if (!channelUsed) { + SampleManager.SetChannelReverbFlag(m_nActiveSamples, m_bDynamicAcousticModelingStatus != false); + SampleManager.StartChannel(m_nActiveSamples); + } + } else { + nCruising = 1; + params->m_pVehicle->bAudioChangingGear = true; + bAccelSampleStopped = 1; + SampleManager.StopChannel(m_nActiveSamples); + if (PizzaFaggBool || accelerateState >= 150 && wheelsOnGround && brakeState <= 0 && !params->m_pVehicle->bIsHandbrakeOn + && !lostTraction && currentGear >= params->m_pTransmission->nNumberOfGears - 1) { + if (accelerateState >= 220 && params->m_fVelocityChange + 0.001 < velocityChangeForAudio) { + if (nCruising < 800) + ++nCruising; + } else if (nCruising > 3) { + --nCruising; + } + freq = 27 * nCruising + freqModifier + 22050; + if (engineSoundType == 8) + freq /= 2; + AudioManager.AddPlayerCarSample(120, freq, soundOffset + SFX_CAR_AFTER_ACCEL_1, engineSoundType, 64, true); + } else { + nCruising = 0; + } } } - break; - } - if (nCruising != 0) { - bAccelSampleStopped = true; - if (accelerateState < 150 || automobile->m_nWheelsOnGround == 0 || automobile->bIsHandbrakeOn || lostTraction || - currentGear < params->m_pTransmission->nNumberOfGears - 1) { - nCruising = 0; - } else { - if (accelerateState >= 220 && params->m_fVelocityChange + 0.001f < automobile->m_fVelocityChangeForAudio) { + } else { + params->m_pVehicle->bAudioChangingGear = true; + bAccelSampleStopped = 1; + SampleManager.StopChannel(m_nActiveSamples); + if (PizzaFaggBool || accelerateState >= 150 && wheelsOnGround && brakeState <= 0 && !params->m_pVehicle->bIsHandbrakeOn + && !lostTraction && currentGear >= params->m_pTransmission->nNumberOfGears - 1) { + if (accelerateState >= 220 && params->m_fVelocityChange + 0.001 < velocityChangeForAudio) { if (nCruising < 800) ++nCruising; } else if (nCruising > 3) { --nCruising; } freq = 27 * nCruising + freqModifier + 22050; - if (engineSoundType == SAMPLEBANK_CAR_MACKTRUCK) + if (engineSoundType == 8) freq /= 2; - AddPlayerCarSample(85, freq, (soundOffset + SFX_CAR_AFTER_ACCEL_1), engineSoundType, 64, true); + AudioManager.AddPlayerCarSample(120, freq, soundOffset + SFX_CAR_AFTER_ACCEL_1, engineSoundType, 64, true); + } else { + nCruising = 0; } } } LastAccel = accelerateState; - - bHandbrakeOnLastFrame = !!automobile->bIsHandbrakeOn; + bHandbrakeOnLastFrame = params->m_pVehicle->bIsHandbrakeOn; bLostTractionLastFrame = lostTraction; + return; } bool diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index 2578e418..c502cad1 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -321,7 +321,6 @@ public: #endif bool ProcessCarBombTick(cVehicleParams *params); void ProcessCesna(cVehicleParams *params); - void ProcessPlayersVehicleEngine1(cVehicleParams* params, CVehicle* veh); //void ProcessCrane(); bool ProcessEngineDamage(cVehicleParams *params); void ProcessEntity(int32 sound); @@ -347,7 +346,7 @@ public: void ProcessPedOneShots(cPedParams *params); void ProcessPhysical(int32 id); void ProcessPlane(cVehicleParams *params); - void ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile *automobile); + void ProcessPlayersVehicleEngine(cVehicleParams *params, CVehicle* veh); void ProcessProjectiles(); void ProcessRainOnVehicle(cVehicleParams *params); void ProcessReverb() const; From 2d3d5d67eee6e3606a5d89ff233eabe92e1f058d Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Tue, 15 Sep 2020 22:06:18 +0300 Subject: [PATCH 03/10] revisit processVehicle --- src/audio/AudioLogic.cpp | 269 +++++++++++++++++++++------------------ src/audio/AudioManager.h | 2 +- 2 files changed, 144 insertions(+), 127 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index ab7c1835..a0d67d03 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -697,131 +697,148 @@ const bool hornPatternsArray[8][44] = { false, false, false, false, true, true, true, true, true, true, true, true, true, true, true, true, true, false, false, false, false, false}, }; - -void -cAudioManager::ProcessVehicle(CVehicle *veh) +void cAudioManager::ProcessVehicle(CVehicle* veh) { - tHandlingData *handling = veh->pHandling; - float velChange; + CPlayerPed* player; + CVehicle* playerVeh; + CEntity* attachedTo; cVehicleParams params; - m_sQueueSample.m_vecPos = veh->GetPosition(); + CBike* bike; + CAutomobile* automobile; + float gasPedal; - float gas; - float gasPedalAudio; - float tmp; - - params.m_bDistanceCalculated = false; - params.m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos); - params.m_pVehicle = veh; - params.m_pTransmission = nil; - params.m_nIndex = 0; - params.m_fVelocityChange = 0.0f; - - if (handling != nil) - params.m_pTransmission = &handling->Transmission; - - params.m_nIndex = veh->GetModelIndex() - MI_FIRST_VEHICLE; - if (params.m_pVehicle->GetStatus() == STATUS_SIMPLE) - velChange = params.m_pVehicle->AutoPilot.m_fMaxTrafficSpeed * 0.02f; - else - velChange = DotProduct(params.m_pVehicle->m_vecMoveSpeed, params.m_pVehicle->GetForward()); - params.m_fVelocityChange = velChange; - params.m_VehicleType = params.m_pVehicle->m_vehType; - switch (params.m_pVehicle->m_vehType) { - case VEHICLE_TYPE_CAR: - UpdateGasPedalAudio((CAutomobile *)veh); - if (params.m_nIndex == RCBANDIT) { - ProcessModelCarEngine(¶ms); + //44-58 + player = FindPlayerPed(); + playerVeh = FindPlayerVehicle(); + if (playerVeh == NULL && player != NULL) { + attachedTo = player->m_attachedTo; + if (attachedTo != NULL && attachedTo->GetType() == ENTITY_TYPE_VEHICLE) + playerVeh = (CVehicle*)attachedTo; + } + if (playerVeh == veh + || CGame::currArea == AREA_OVALRING + || CGame::currArea == AREA_BLOOD + || CGame::currArea == AREA_DIRT + || CGame::currArea == AREA_EVERYWHERE + || CGame::currArea == AREA_MALL + || CGame::currArea == AREA_MAIN_MAP) { + //62-84 + m_sQueueSample.m_vecPos = veh->GetPosition(); + params.m_bDistanceCalculated = false; + params.m_pVehicle = veh; + params.m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos); + params.m_pTransmission = veh->pHandling != NULL ? &veh->pHandling->Transmission : NULL; + params.m_nIndex = veh->m_modelIndex - MI_FIRST_VEHICLE; + if (veh->GetStatus() == STATUS_SIMPLE) + params.m_fVelocityChange = veh->AutoPilot.m_fMaxTrafficSpeed * 0.02f; + else + params.m_fVelocityChange = DotProduct(veh->m_vecMoveSpeed, veh->GetForward()); + params.m_VehicleType = veh->m_vehType; + + if (CGame::currArea == AREA_MALL && playerVeh != veh) { ProcessVehicleOneShots(¶ms); - ((CAutomobile *)veh)->m_fVelocityChangeForAudio = params.m_fVelocityChange; + ProcessVehicleSirenOrAlarm(¶ms); + ProcessEngineDamage(¶ms); + return; + } + //104- + switch (params.m_VehicleType) { + case VEHICLE_TYPE_CAR://done + automobile = (CAutomobile*)veh; + UpdateGasPedalAudio(&automobile->m_fGasPedalAudio, automobile->m_fGasPedal); + if (veh->m_modelIndex == MI_RCBANDIT || veh->m_modelIndex == MI_RCBARON) { + ProcessModelCarEngine(¶ms);//recheck + ProcessEngineDamage(¶ms); + } else if (veh->m_modelIndex == MI_RCRAIDER || veh->m_modelIndex == MI_RCGOBLIN) { + //ProcessModelHeliVehicle(this, ¶ms); + ProcessEngineDamage(¶ms); + } else { + switch (veh->GetVehicleAppearance()) { + case VEHICLE_APPEARANCE_HELI: + ProcessHelicopter(¶ms); + //ProcessVehicleFlatTyre(¶ms); + ProcessEngineDamage(¶ms); + break; + case VEHICLE_APPEARANCE_BOAT: + case VEHICLE_APPEARANCE_PLANE: + break; + default: + if (ProcessVehicleRoadNoise(¶ms)) { + ProcessReverseGear(¶ms); + if (CWeather::WetRoads > 0.0) + ProcessWetRoadNoise(¶ms); + ProcessVehicleSkidding(¶ms); + //ProcessVehicleFlatTyre(params); + ProcessVehicleHorn(¶ms); + ProcessVehicleSirenOrAlarm(¶ms); + if (UsesReverseWarning(params.m_nIndex)) + ProcessVehicleReverseWarning(¶ms); + if(HasAirBrakes(params.m_nIndex)) + ProcessAirBrakes(¶ms); + ProcessCarBombTick(¶ms); + ProcessVehicleEngine(¶ms); + ProcessEngineDamage(¶ms); + ProcessVehicleDoors(¶ms); + } + break; + } + } + ProcessVehicleOneShots(¶ms); + automobile->m_fVelocityChangeForAudio = params.m_fVelocityChange; + break; + case VEHICLE_TYPE_BOAT://done + if (veh->m_modelIndex == MI_SKIMMER) + ProcessHelicopter(¶ms); + else + ProcessBoatEngine(¶ms); + ProcessBoatMovingOverWater(¶ms); + ProcessVehicleOneShots(¶ms); + break; + case VEHICLE_TYPE_HELI: //done + ProcessHelicopter(¶ms); //TODO recheck + ProcessVehicleOneShots(¶ms); + break; + case VEHICLE_TYPE_PLANE://done + switch (params.m_nIndex) { + case AIRTRAIN: + ProcessJumbo(¶ms);//recheck + break; + case DEADDODO: + ProcessCesna(¶ms);//recheck + break; + default: + break; + } + ProcessVehicleOneShots(¶ms); + //ProcessVehicleFlatType(¶ms); + break; + case VEHICLE_TYPE_BIKE: //done + bike = (CBike*)veh; + //gasPedal = fabs(veh->m_fGasPedal); + //if (gasPedal <= bike->m_fGasPedalAudio) + // bike->m_fGasPedalAudio = Max(bike->m_fGasPedalAudio - 0.07f, gasPedal); + //else + // bike->m_fGasPedalAudio = Min(bike->m_fGasPedalAudio + 0.09f, gasPedal); + UpdateGasPedalAudio(&bike->m_fGasPedalAudio, bike->m_fGasPedal); + if (ProcessVehicleRoadNoise(¶ms)) { + if (CWeather::WetRoads > 0.0f) + ProcessWetRoadNoise(¶ms); + ProcessVehicleSkidding(¶ms); + ProcessVehicleHorn(¶ms); + ProcessVehicleSirenOrAlarm(¶ms); + ProcessCarBombTick(¶ms); + ProcessEngineDamage(¶ms); + ProcessVehicleEngine(¶ms); + //ProcessVehicleFlatTyre(); + } + ProcessVehicleOneShots(¶ms); + bike->m_fVelocityChangeForAudio = params.m_fVelocityChange; + break; + default: break; } - - if (params.m_nIndex == DODO) { - if (!ProcessVehicleRoadNoise(¶ms)) { - ProcessVehicleOneShots(¶ms); - ((CAutomobile *)veh)->m_fVelocityChangeForAudio = params.m_fVelocityChange; - break; - } - if (CWeather::WetRoads > 0.f) - ProcessWetRoadNoise(¶ms); - ProcessVehicleSkidding(¶ms); - } else { - if (!ProcessVehicleRoadNoise(¶ms)) { - ProcessVehicleOneShots(¶ms); - ((CAutomobile *)veh)->m_fVelocityChangeForAudio = params.m_fVelocityChange; - break; - } - ProcessReverseGear(¶ms); - if (CWeather::WetRoads > 0.f) - ProcessWetRoadNoise(¶ms); - ProcessVehicleSkidding(¶ms); - ProcessVehicleHorn(¶ms); - ProcessVehicleSirenOrAlarm(¶ms); - if (UsesReverseWarning(params.m_nIndex)) - ProcessVehicleReverseWarning(¶ms); - if (HasAirBrakes(params.m_nIndex)) - ProcessAirBrakes(¶ms); - } - ProcessCarBombTick(¶ms); - ProcessVehicleEngine(¶ms); - ProcessEngineDamage(¶ms); - ProcessVehicleDoors(¶ms); - - ProcessVehicleOneShots(¶ms); - ((CAutomobile *)veh)->m_fVelocityChangeForAudio = params.m_fVelocityChange; - break; - case VEHICLE_TYPE_BOAT: - ProcessBoatEngine(¶ms); - ProcessBoatMovingOverWater(¶ms); - ProcessVehicleOneShots(¶ms); - break; -#ifdef GTA_TRAIN - case VEHICLE_TYPE_TRAIN: - ProcessTrainNoise(¶ms); - ProcessVehicleOneShots(¶ms); - break; -#endif - case VEHICLE_TYPE_HELI: - ProcessHelicopter(¶ms); - ProcessVehicleOneShots(¶ms); - break; - case VEHICLE_TYPE_PLANE: - ProcessPlane(¶ms); - ProcessVehicleOneShots(¶ms); - break; - case VEHICLE_TYPE_BIKE: - gas = fabs(params.m_pVehicle->m_fGasPedal); - gasPedalAudio = ((CBike*)params.m_pVehicle)->m_fGasPedalAudio; - if (gas <= gasPedalAudio) { - tmp = gasPedalAudio = 0.07f; - if (tmp <= gas) - tmp = gas; - } else { - tmp = gasPedalAudio + 0.09f; - if (tmp < gas) - tmp = gas; - } - ((CBike*)params.m_pVehicle)->m_fGasPedalAudio = tmp; - - if (ProcessVehicleRoadNoise(¶ms)) { - if (CWeather::WetRoads > 0.0f) - ProcessWetRoadNoise(¶ms); - ProcessVehicleSkidding(¶ms); - ProcessVehicleHorn(¶ms); - ProcessVehicleSirenOrAlarm(¶ms); - ProcessCarBombTick(¶ms); - ProcessEngineDamage(¶ms); - ProcessVehicleEngine(¶ms); - //ProcessVehicleFlatTyre(); - } - ProcessVehicleOneShots(¶ms); - ((CBike*)veh)->m_fVelocityChangeForAudio = params.m_fVelocityChange; - break; - default: - break; + ProcessRainOnVehicle(¶ms); } - ProcessRainOnVehicle(¶ms); } void @@ -1227,15 +1244,14 @@ cAudioManager::ProcessVehicleEngine(cVehicleParams *params) } void -cAudioManager::UpdateGasPedalAudio(CAutomobile *automobile) +cAudioManager::UpdateGasPedalAudio(float* gasPedalAudio, float vehGasPedal) { - float gasPedal = Abs(automobile->m_fGasPedal); - float gasPedalAudio = automobile->m_fGasPedalAudio; + float gasPedal = Abs(vehGasPedal); - if (gasPedalAudio < gasPedal) - automobile->m_fGasPedalAudio = Min(gasPedalAudio + 0.09f, gasPedal); + if (*gasPedalAudio < gasPedal) + *gasPedalAudio = Min(*gasPedalAudio + 0.09f, gasPedal); else - automobile->m_fGasPedalAudio = Max(gasPedalAudio - 0.07f, gasPedal); + *gasPedalAudio = Max(*gasPedalAudio - 0.07f, gasPedal); } void @@ -2072,7 +2088,7 @@ cAudioManager::ProcessVehicleSirenOrAlarm(cVehicleParams *params) bool cAudioManager::UsesReverseWarning(int32 model) const { - return model == LINERUN || model == FIRETRUK || model == TRASH || model == BUS || model == COACH; + return model == LINERUN || model == FIRETRUK || model == BUS || model == COACH || model == PACKER || model == FLATBED; } bool @@ -2204,7 +2220,8 @@ cAudioManager::ProcessAirBrakes(cVehicleParams *params) bool cAudioManager::HasAirBrakes(int32 model) const { - return model == LINERUN || model == FIRETRUK || model == TRASH || model == BUS || model == COACH; + return model == LINERUN || model == FIRETRUK || model == TRASH || model == BUS || model == BARRACKS + || model == COACH || model == PACKER || model == FLATBED; } bool diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index c502cad1..945dee3c 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -359,6 +359,7 @@ public: void ProcessVehicle(CVehicle *vehicle); bool ProcessVehicleDoors(cVehicleParams *params); void ProcessVehicleEngine(cVehicleParams *params); + void UpdateGasPedalAudio(float* gasPedalAudio, float vehGasPedal); void ProcessVehicleHorn(cVehicleParams *params); void ProcessVehicleOneShots(cVehicleParams *params); bool ProcessVehicleReverseWarning(cVehicleParams *params); @@ -411,7 +412,6 @@ public: void Terminate(); void TranslateEntity(Const CVector *v1, CVector *v2) const; - void UpdateGasPedalAudio(CAutomobile *automobile); void UpdateReflections(); bool UsesReverseWarning(int32 model) const; bool UsesSiren(int32 model) const; From 3ab01fa6a39af1e6aca2a218ae009dd8e7a7606b Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Fri, 18 Sep 2020 18:11:49 +0300 Subject: [PATCH 04/10] fix conditions for processPlayerVehicleEngine --- src/audio/AudioLogic.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index a0d67d03..effc13b0 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -1648,7 +1648,7 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle } if (gasPedalAudio > 0.05f) { freq = (5000.f * (gasPedalAudio - 0.05f) * 20.f / 19) + 19000; - vol = (25.0 * (gasPedalAudio - 0.05f) * 20.f / 19) + 40; + vol = (25.0f * (gasPedalAudio - 0.05f) * 20.f / 19) + 40; if (params->m_pVehicle->bIsDrowning) vol /= 4; if (engineSoundType == SAMPLEBANK_CAR_COBRA) @@ -1671,15 +1671,14 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle if (nCruising == 0){ stuckInSand = params->m_VehicleType == VEHICLE_TYPE_CAR && ((CAutomobile*)params->m_pVehicle)->bStuckInSand; if (accelerateState < 150 || wheelsOnGround == 0 || params->m_pVehicle->bIsHandbrakeOn || lostTraction - || currentGear < 2 && params->m_fVelocityChange - velocityChangeForAudio >= 0.01f || brakeState > 0) { - if ((wheelsOnGround && !params->m_pVehicle->bIsHandbrakeOn && !lostTraction || !stuckInSand) - && brakeState <= 0) { + || (currentGear < 2 && params->m_fVelocityChange - velocityChangeForAudio < 0.01f) || brakeState > 0) { + + if (((wheelsOnGround && !params->m_pVehicle->bIsHandbrakeOn && !lostTraction ) || stuckInSand) && brakeState <= 0) { baseFreq = (8000.0f * accelerationMultipler) + 16000; vol = (25.0f * accelerationMultipler) + 60; *gasPedalAudioPtr = accelerationMultipler; } else { - if (wheelsOnGround == 0 && wheelsOnGroundPrev != 0 - || (params->m_pVehicle->bIsHandbrakeOn && !bHandbrakeOnLastFrame || lostTraction && !bLostTractionLastFrame) + if (wheelsOnGround == 0 && wheelsOnGroundPrev != 0 || (params->m_pVehicle->bIsHandbrakeOn && !bHandbrakeOnLastFrame || lostTraction && !bLostTractionLastFrame) && wheelsOnGround != 0) { *gasPedalAudioPtr *= 0.6f; } @@ -1769,7 +1768,7 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle SampleManager.StopChannel(m_nActiveSamples); if (PizzaFaggBool || accelerateState >= 150 && wheelsOnGround && brakeState <= 0 && !params->m_pVehicle->bIsHandbrakeOn && !lostTraction && currentGear >= params->m_pTransmission->nNumberOfGears - 1) { - if (accelerateState >= 220 && params->m_fVelocityChange + 0.001 < velocityChangeForAudio) { + if (accelerateState >= 220 && params->m_fVelocityChange + 0.001 >= velocityChangeForAudio) { if (nCruising < 800) ++nCruising; } else if (nCruising > 3) { @@ -1790,7 +1789,7 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle SampleManager.StopChannel(m_nActiveSamples); if (PizzaFaggBool || accelerateState >= 150 && wheelsOnGround && brakeState <= 0 && !params->m_pVehicle->bIsHandbrakeOn && !lostTraction && currentGear >= params->m_pTransmission->nNumberOfGears - 1) { - if (accelerateState >= 220 && params->m_fVelocityChange + 0.001 < velocityChangeForAudio) { + if (accelerateState >= 220 && params->m_fVelocityChange + 0.001 >= velocityChangeForAudio) { if (nCruising < 800) ++nCruising; } else if (nCruising > 3) { From 7f77e8a441be5f5a2892375a5e3abb23c328c5cd Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Fri, 18 Sep 2020 19:11:28 +0300 Subject: [PATCH 05/10] cleanup processPlayerVehicleEngine --- src/audio/AudioLogic.cpp | 120 +++++++++++++++------------------------ 1 file changed, 46 insertions(+), 74 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index effc13b0..e333c87c 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -1370,60 +1370,51 @@ cAudioManager::ProcessCesna(cVehicleParams *params) void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle* veh) { static int32 GearFreqAdj[] = { 6000, 6000, 3400, 1200, 0, -1000 }; - double gasPedal; // st6 + tWheelState* wheelState; - CAutomobile* automobile; // ebp - CBike* bike; // edx - float* gasPedalAudioPtr; // edi - uint8 wheelInUseCounter; // cl - int freqModifier; // [esp+Ch] [ebp-74h] - signed int accelerateState; // [esp+20h] [ebp-60h] - bool channelUsed; // [esp+2Ch] [ebp-54h] - bool lostTraction; // [esp+30h] [ebp-50h] - int engineSoundType; // [esp+1Ch] [ebp-64h] - signed int brakeState; // [esp+24h] [ebp-5Ch] - uint8 wheelsOnGround; // [esp+3Ch] [ebp-44h] + CAutomobile* automobile; + CBike* bike; + CVector pos; + float* gasPedalAudioPtr; + + int32 accelerateState; + int32 brakeState; + int32 freq; + int32 baseFreq; + int32 freqModifier; + uint32 tmp; + uint32 soundOffset; + uint8 engineSoundType; + uint8 wheelInUseCounter; + uint8 wheelsOnGround; + uint8 vol; + uint8 currentGear; + uint8 wheelsOnGroundPrev; + + float accelerationMultipler; float gasPedalAudio; - double relativeVelocityChange; // st6 - float accelerationMultipler; // [esp+50h] [ebp-30h] float velocityChangeForAudio; - int baseFreq; // ebp - uint8 vol; // bl - - double time; // st7 - - double timeClip; // st4 - int tmp; // edx - int soundOffset; // ebx - char err; // al - - unsigned int freq_2; // edi - bool stuckInSand; // cl + float relativeVelocityChange; + float time; + bool channelUsed; + bool lostTraction; + bool err; + bool stuckInSand; + bool processedAccelSampleStopped; + bool PizzaFaggBool; - unsigned int freq; // edi - - bool speedBool; // [esp+28h] [ebp-58h] - - unsigned __int8 currentGear; // [esp+34h] [ebp-4Ch] - char processedAccelSampleStopped; // [esp+38h] [ebp-48h] - char wheelsOnGroundPrev; // [esp+40h] [ebp-40h] - bool PizzaFaggBool; // [esp+44h] [ebp-3Ch] - - CVector pos; // [esp+64h] [ebp-1Ch] - - //67-105 + static uint32 curTime = CTimer::GetTimeInMilliseconds(); + static int32 nCruising = 0; static int16 LastAccel = 0; static uint8 CurrentPretendGear = 1; static bool bLostTractionLastFrame = false; static bool bHandbrakeOnLastFrame = false; - static int32 nCruising = 0; static bool bAccelSampleStopped = true; - static uint32 curTime = CTimer::GetTimeInMilliseconds(); - lostTraction = 0; - PizzaFaggBool = 0; - processedAccelSampleStopped = 0; + lostTraction = false; + PizzaFaggBool = params->m_pVehicle->m_modelIndex == MI_PIZZABOY || params->m_pVehicle->m_modelIndex == MI_FAGGIO; + processedAccelSampleStopped = false; if (bPlayerJustEnteredCar) { bAccelSampleStopped = 1; bPlayerJustEnteredCar = 0; @@ -1433,7 +1424,6 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle CurrentPretendGear = 1; bHandbrakeOnLastFrame = 0; } - //106-157 if (CReplay::IsPlayingBack()) { accelerateState = (signed int)(255.0 * clamp(params->m_pVehicle->m_fGasPedal, 0.0, 1.0)); brakeState = (signed int)(255.0 * clamp(params->m_pVehicle->m_fBrakePedal, 0.0, 1.0)); @@ -1441,14 +1431,8 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle accelerateState = Pads[0].GetAccelerate(); brakeState = Pads[0].GetBrake(); } - //158-162 - speedBool = params->m_fVelocityChange >= -0.001; channelUsed = SampleManager.GetChannelUsedFlag(m_nActiveSamples); - //163-184 - if (params->m_pVehicle->m_modelIndex != MI_PIZZABOY - && params->m_pVehicle->m_modelIndex != MI_FAGGIO) { - currentGear = params->m_pVehicle->m_nCurrentGear; - } else { + if (PizzaFaggBool) { CurrentPretendGear = params->m_pTransmission->nNumberOfGears; currentGear = CurrentPretendGear; if (params->m_pVehicle->bIsHandbrakeOn) { @@ -1459,16 +1443,16 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle } else { nCruising = 1; } - PizzaFaggBool = true; + } else { + currentGear = params->m_pVehicle->m_nCurrentGear; } - //185-205 switch (params->m_VehicleType) { case VEHICLE_TYPE_CAR: automobile = (CAutomobile*)params->m_pVehicle; wheelsOnGround = automobile->m_nDriveWheelsOnGround; wheelsOnGroundPrev = automobile->m_nDriveWheelsOnGroundPrev; - gasPedalAudioPtr = (float*)&automobile->m_fGasPedalAudio; + gasPedalAudioPtr = &automobile->m_fGasPedalAudio; wheelState = automobile->m_aWheelState; velocityChangeForAudio = automobile->m_fVelocityChangeForAudio; break; @@ -1480,13 +1464,11 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle wheelState = bike->m_aWheelState; velocityChangeForAudio = bike->m_fVelocityChangeForAudio; break; - //641-644 default: - //dbgprint(" ** AUDIOLOG: Unrecognised vehicle type %d in ProcessVehicleEngine() * \n", vehType); + debug(" ** AUDIOLOG: Unrecognised vehicle type %d in ProcessVehicleEngine() * \n", params->m_VehicleType); return; } if (!PizzaFaggBool) { - //208-253 switch (params->m_pTransmission->nDriveType) { case '4': if (params->m_VehicleType != VEHICLE_TYPE_BIKE) { @@ -1522,7 +1504,6 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle break; } } - //254-281 if (params->m_fVelocityChange != 0.0f) { time = params->m_pVehicle->m_vecMoveSpeed.z / params->m_fVelocityChange; if (time > 0.0f) @@ -1533,15 +1514,12 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle freqModifier = -freqModifier; } else freqModifier = 0; - //282-283 if (params->m_VehicleType == VEHICLE_TYPE_BIKE && bike->bExtraSpeed) freqModifier += 1400; - //TODO rewtire this part - //284-349 tmp = 0; engineSoundType = aVehicleSettings[params->m_nIndex].m_nBank; soundOffset = 3 * (engineSoundType - 4); - err = 0; + err = false; switch (soundOffset) { case 0: tmp = 2526; @@ -1586,7 +1564,7 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle tmp = 2410; break; default: - err = 1; + err = true; break; } if (!channelUsed || nCruising || err) { @@ -1594,15 +1572,13 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle } else { tmp -= 1000; if (CTimer::GetTimeInMilliseconds() - curTime > tmp) { - channelUsed = 0; + channelUsed = false; curTime = CTimer::GetTimeInMilliseconds(); } } - //349-366 relativeVelocityChange = 2.0 * params->m_fVelocityChange / params->m_pTransmission->fMaxVelocity; accelerationMultipler = clamp(relativeVelocityChange, 0.0, 1.0); gasPedalAudio = accelerationMultipler; - //367-380 switch (engineSoundType) { case 21: ++soundOffset; @@ -1616,7 +1592,6 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle default: break; } - //381-476 if (accelerateState <= 0) { if (params->m_fVelocityChange < -0.001f) { if (channelUsed) { @@ -1640,11 +1615,12 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle || params->m_pVehicle->bIsHandbrakeOn || lostTraction || params->m_fVelocityChange < 0.01f && *gasPedalAudioPtr > 0.2f) { - if (!PizzaFaggBool) { + if (PizzaFaggBool) { + gasPedalAudio = 0.0f; + } else { *gasPedalAudioPtr *= 0.6f; gasPedalAudio = *gasPedalAudioPtr; - } else - gasPedalAudio = 0.0f; + } } if (gasPedalAudio > 0.05f) { freq = (5000.f * (gasPedalAudio - 0.05f) * 20.f / 19) + 19000; @@ -1666,7 +1642,6 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle CurrentPretendGear = Max(1, currentGear); } - //477-515 else { if (nCruising == 0){ stuckInSand = params->m_VehicleType == VEHICLE_TYPE_CAR && ((CAutomobile*)params->m_pVehicle)->bStuckInSand; @@ -1689,7 +1664,6 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle baseFreq = (15000.0f * *gasPedalAudioPtr) + 14000; vol = (25.0f * *gasPedalAudioPtr) + 60; } - //516-535 freq = freqModifier + baseFreq; if (engineSoundType == SAMPLEBANK_CAR_COBRA) freq /= 2; @@ -1701,7 +1675,6 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle vol /= 4; AddPlayerCarSample(vol, freq, engineSoundType + SFX_CAR_REV_1 - 4, SAMPLEBANK_MAIN, 2, true); } else { - //536-548 cAudioManager::TranslateEntity(&m_sQueueSample.m_vecPos, &pos); if (bAccelSampleStopped) { if (CurrentPretendGear != 1 || currentGear != 2) @@ -1709,7 +1682,6 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle processedAccelSampleStopped = true; bAccelSampleStopped = false; } - //549- if (channelUsed) { SampleManager.SetChannelEmittingVolume(m_nActiveSamples, 120); SampleManager.SetChannel3DPosition(m_nActiveSamples, pos.x, pos.y, pos.z); From 5f810ff21c4c9a9d0f1cfa72cbf16cfe375948e1 Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Fri, 18 Sep 2020 19:14:36 +0300 Subject: [PATCH 06/10] cleanup processVehicle --- src/audio/AudioLogic.cpp | 20 ++++++-------------- src/audio/AudioManager.h | 2 +- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index e333c87c..3aa50c7b 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -707,7 +707,6 @@ void cAudioManager::ProcessVehicle(CVehicle* veh) CAutomobile* automobile; float gasPedal; - //44-58 player = FindPlayerPed(); playerVeh = FindPlayerVehicle(); if (playerVeh == NULL && player != NULL) { @@ -722,7 +721,6 @@ void cAudioManager::ProcessVehicle(CVehicle* veh) || CGame::currArea == AREA_EVERYWHERE || CGame::currArea == AREA_MALL || CGame::currArea == AREA_MAIN_MAP) { - //62-84 m_sQueueSample.m_vecPos = veh->GetPosition(); params.m_bDistanceCalculated = false; params.m_pVehicle = veh; @@ -741,9 +739,8 @@ void cAudioManager::ProcessVehicle(CVehicle* veh) ProcessEngineDamage(¶ms); return; } - //104- switch (params.m_VehicleType) { - case VEHICLE_TYPE_CAR://done + case VEHICLE_TYPE_CAR: automobile = (CAutomobile*)veh; UpdateGasPedalAudio(&automobile->m_fGasPedalAudio, automobile->m_fGasPedal); if (veh->m_modelIndex == MI_RCBANDIT || veh->m_modelIndex == MI_RCBARON) { @@ -786,7 +783,7 @@ void cAudioManager::ProcessVehicle(CVehicle* veh) ProcessVehicleOneShots(¶ms); automobile->m_fVelocityChangeForAudio = params.m_fVelocityChange; break; - case VEHICLE_TYPE_BOAT://done + case VEHICLE_TYPE_BOAT: if (veh->m_modelIndex == MI_SKIMMER) ProcessHelicopter(¶ms); else @@ -794,11 +791,11 @@ void cAudioManager::ProcessVehicle(CVehicle* veh) ProcessBoatMovingOverWater(¶ms); ProcessVehicleOneShots(¶ms); break; - case VEHICLE_TYPE_HELI: //done - ProcessHelicopter(¶ms); //TODO recheck + case VEHICLE_TYPE_HELI: + ProcessHelicopter(¶ms); //recheck ProcessVehicleOneShots(¶ms); break; - case VEHICLE_TYPE_PLANE://done + case VEHICLE_TYPE_PLANE: switch (params.m_nIndex) { case AIRTRAIN: ProcessJumbo(¶ms);//recheck @@ -812,13 +809,8 @@ void cAudioManager::ProcessVehicle(CVehicle* veh) ProcessVehicleOneShots(¶ms); //ProcessVehicleFlatType(¶ms); break; - case VEHICLE_TYPE_BIKE: //done + case VEHICLE_TYPE_BIKE: bike = (CBike*)veh; - //gasPedal = fabs(veh->m_fGasPedal); - //if (gasPedal <= bike->m_fGasPedalAudio) - // bike->m_fGasPedalAudio = Max(bike->m_fGasPedalAudio - 0.07f, gasPedal); - //else - // bike->m_fGasPedalAudio = Min(bike->m_fGasPedalAudio + 0.09f, gasPedal); UpdateGasPedalAudio(&bike->m_fGasPedalAudio, bike->m_fGasPedal); if (ProcessVehicleRoadNoise(¶ms)) { if (CWeather::WetRoads > 0.0f) diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index 945dee3c..dcf6ce2d 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -143,7 +143,7 @@ public: class cVehicleParams { public: - int32 m_VehicleType; + eVehicleType m_VehicleType; bool m_bDistanceCalculated; float m_fDistance; CVehicle *m_pVehicle; From 223cd118355322e5b70180bf6d7a404b17e65ae0 Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Fri, 18 Sep 2020 20:32:25 +0300 Subject: [PATCH 07/10] just more cleanup... --- src/audio/AudioLogic.cpp | 106 +++++++++++++++---------------- src/audio/AudioManager.h | 1 + src/modelinfo/VehicleModelInfo.h | 2 +- 3 files changed, 53 insertions(+), 56 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 3aa50c7b..5d889838 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -37,7 +37,7 @@ #include "Weather.h" #include "ZoneCull.h" #include "sampman.h" -#include +#include "Bike.h" const int channels = ARRAY_SIZE(cAudioManager::m_asActiveSamples); @@ -709,9 +709,9 @@ void cAudioManager::ProcessVehicle(CVehicle* veh) player = FindPlayerPed(); playerVeh = FindPlayerVehicle(); - if (playerVeh == NULL && player != NULL) { + if (playerVeh == nil && player != nil) { attachedTo = player->m_attachedTo; - if (attachedTo != NULL && attachedTo->GetType() == ENTITY_TYPE_VEHICLE) + if (attachedTo != nil && attachedTo->GetType() == ENTITY_TYPE_VEHICLE) playerVeh = (CVehicle*)attachedTo; } if (playerVeh == veh @@ -725,7 +725,7 @@ void cAudioManager::ProcessVehicle(CVehicle* veh) params.m_bDistanceCalculated = false; params.m_pVehicle = veh; params.m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos); - params.m_pTransmission = veh->pHandling != NULL ? &veh->pHandling->Transmission : NULL; + params.m_pTransmission = veh->pHandling != nil ? &veh->pHandling->Transmission : nil; params.m_nIndex = veh->m_modelIndex - MI_FIRST_VEHICLE; if (veh->GetStatus() == STATUS_SIMPLE) params.m_fVelocityChange = veh->AutoPilot.m_fMaxTrafficSpeed * 0.02f; @@ -744,7 +744,7 @@ void cAudioManager::ProcessVehicle(CVehicle* veh) automobile = (CAutomobile*)veh; UpdateGasPedalAudio(&automobile->m_fGasPedalAudio, automobile->m_fGasPedal); if (veh->m_modelIndex == MI_RCBANDIT || veh->m_modelIndex == MI_RCBARON) { - ProcessModelCarEngine(¶ms);//recheck + ProcessModelCarEngine(¶ms); ProcessEngineDamage(¶ms); } else if (veh->m_modelIndex == MI_RCRAIDER || veh->m_modelIndex == MI_RCGOBLIN) { //ProcessModelHeliVehicle(this, ¶ms); @@ -792,16 +792,16 @@ void cAudioManager::ProcessVehicle(CVehicle* veh) ProcessVehicleOneShots(¶ms); break; case VEHICLE_TYPE_HELI: - ProcessHelicopter(¶ms); //recheck + ProcessHelicopter(¶ms); ProcessVehicleOneShots(¶ms); break; case VEHICLE_TYPE_PLANE: switch (params.m_nIndex) { case AIRTRAIN: - ProcessJumbo(¶ms);//recheck + ProcessJumbo(¶ms); break; case DEADDODO: - ProcessCesna(¶ms);//recheck + ProcessCesna(¶ms); break; default: break; @@ -1091,7 +1091,7 @@ cAudioManager::ProcessVehicleEngine(cVehicleParams *params) float relativeGearChange; float relativeChange; uint8 volume; - int32 freq = 0; // uninitialized variable + int32 freq = 0; uint8 emittingVol; cTransmission *transmission; uint8 currentGear; @@ -1106,15 +1106,12 @@ cAudioManager::ProcessVehicleEngine(cVehicleParams *params) return; } if (!params->m_bDistanceCalculated) { - if (params->m_fDistance <= 0.0) - m_sQueueSample.m_fDistance = 0.0; + if (params->m_fDistance <= 0.0f) + m_sQueueSample.m_fDistance = 0.0f; else - m_sQueueSample.m_fDistance = sqrt(params->m_fDistance); + m_sQueueSample.m_fDistance = Sqrt(params->m_fDistance); } - //if (playerVeh == veh /*&& veh->m_modelIndex != DODO(187)*/) { - // ProcessPlayersVehicleEngine(params, params->m_pVehicle); - // return; - //} + if (veh->bEngineOn) { CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); automobile = (CAutomobile *)params->m_pVehicle; @@ -1374,7 +1371,7 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle int32 freq; int32 baseFreq; int32 freqModifier; - uint32 tmp; + uint32 gearSoundLength; uint32 soundOffset; uint8 engineSoundType; uint8 wheelInUseCounter; @@ -1395,8 +1392,7 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle bool processedAccelSampleStopped; bool PizzaFaggBool; - - static uint32 curTime = CTimer::GetTimeInMilliseconds(); + static uint32 gearSoundStartTime = CTimer::GetTimeInMilliseconds(); static int32 nCruising = 0; static int16 LastAccel = 0; static uint8 CurrentPretendGear = 1; @@ -1408,17 +1404,17 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle PizzaFaggBool = params->m_pVehicle->m_modelIndex == MI_PIZZABOY || params->m_pVehicle->m_modelIndex == MI_FAGGIO; processedAccelSampleStopped = false; if (bPlayerJustEnteredCar) { - bAccelSampleStopped = 1; - bPlayerJustEnteredCar = 0; + bAccelSampleStopped = true; + bPlayerJustEnteredCar = false; nCruising = 0; LastAccel = 0; - bLostTractionLastFrame = 0; + bLostTractionLastFrame = false; CurrentPretendGear = 1; - bHandbrakeOnLastFrame = 0; + bHandbrakeOnLastFrame = false; } if (CReplay::IsPlayingBack()) { - accelerateState = (signed int)(255.0 * clamp(params->m_pVehicle->m_fGasPedal, 0.0, 1.0)); - brakeState = (signed int)(255.0 * clamp(params->m_pVehicle->m_fBrakePedal, 0.0, 1.0)); + accelerateState = (255.0f * clamp(params->m_pVehicle->m_fGasPedal, 0.0f, 1.0f)); + brakeState = (255.0f * clamp(params->m_pVehicle->m_fBrakePedal, 0.0f, 1.0f)); } else { accelerateState = Pads[0].GetAccelerate(); brakeState = Pads[0].GetBrake(); @@ -1508,68 +1504,68 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle freqModifier = 0; if (params->m_VehicleType == VEHICLE_TYPE_BIKE && bike->bExtraSpeed) freqModifier += 1400; - tmp = 0; + gearSoundLength = 0; engineSoundType = aVehicleSettings[params->m_nIndex].m_nBank; soundOffset = 3 * (engineSoundType - 4); err = false; switch (soundOffset) { case 0: - tmp = 2526; + gearSoundLength = 2526; break; case 3: - tmp = 3587; + gearSoundLength = 3587; break; case 6: - tmp = 4898; + gearSoundLength = 4898; break; case 9: - tmp = 4003; + gearSoundLength = 4003; break; case 12: - tmp = 6289; + gearSoundLength = 6289; break; case 15: - tmp = 2766; + gearSoundLength = 2766; break; case 18: - tmp = 3523; + gearSoundLength = 3523; break; case 21: - tmp = 2773; + gearSoundLength = 2773; break; case 24: - tmp = 2560; + gearSoundLength = 2560; break; case 27: - tmp = 4228; + gearSoundLength = 4228; break; case 30: - tmp = 4648; + gearSoundLength = 4648; break; case 48: - tmp = 3480; + gearSoundLength = 3480; break; case 54: - tmp = 2380; + gearSoundLength = 2380; break; case 57: - tmp = 2410; + gearSoundLength = 2410; break; default: err = true; break; } if (!channelUsed || nCruising || err) { - curTime = CTimer::GetTimeInMilliseconds(); + gearSoundStartTime = CTimer::GetTimeInMilliseconds(); } else { - tmp -= 1000; - if (CTimer::GetTimeInMilliseconds() - curTime > tmp) { + gearSoundLength -= 1000; + if (CTimer::GetTimeInMilliseconds() - gearSoundStartTime > gearSoundLength) { channelUsed = false; - curTime = CTimer::GetTimeInMilliseconds(); + gearSoundStartTime = CTimer::GetTimeInMilliseconds(); } } - relativeVelocityChange = 2.0 * params->m_fVelocityChange / params->m_pTransmission->fMaxVelocity; - accelerationMultipler = clamp(relativeVelocityChange, 0.0, 1.0); + relativeVelocityChange = 2.0f * params->m_fVelocityChange / params->m_pTransmission->fMaxVelocity; + accelerationMultipler = clamp(relativeVelocityChange, 0.0f, 1.0f); gasPedalAudio = accelerationMultipler; switch (engineSoundType) { case 21: @@ -1593,7 +1589,7 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle if (wheelsOnGround == 0 || params->m_pVehicle->bIsHandbrakeOn || lostTraction) gasPedalAudio = *gasPedalAudioPtr; else if (params->m_VehicleType == VEHICLE_TYPE_BIKE) - gasPedalAudio = 0.0; + gasPedalAudio = 0.0f; else gasPedalAudio = Min(1.0f, params->m_fVelocityChange / params->m_pTransmission->fMaxReverseVelocity); *gasPedalAudioPtr = Max(0.0f, gasPedalAudio); @@ -1625,7 +1621,7 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle } } freq = (10000.f * gasPedalAudio) + 22050; - vol = 110 - (40.0 * gasPedalAudio); + vol = 110 - (40.0f * gasPedalAudio); if (engineSoundType == SAMPLEBANK_CAR_COBRA) freq /= 2; if (params->m_pVehicle->bIsDrowning) @@ -1667,7 +1663,7 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle vol /= 4; AddPlayerCarSample(vol, freq, engineSoundType + SFX_CAR_REV_1 - 4, SAMPLEBANK_MAIN, 2, true); } else { - cAudioManager::TranslateEntity(&m_sQueueSample.m_vecPos, &pos); + TranslateEntity(&m_sQueueSample.m_vecPos, &pos); if (bAccelSampleStopped) { if (CurrentPretendGear != 1 || currentGear != 2) CurrentPretendGear = Max(1, currentGear - 1); @@ -1687,7 +1683,7 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle SampleManager.StartChannel(m_nActiveSamples); } } else if (processedAccelSampleStopped) { - curTime = CTimer::GetTimeInMilliseconds(); + gearSoundStartTime = CTimer::GetTimeInMilliseconds(); params->m_pVehicle->bAudioChangingGear = true; if (!SampleManager.InitialiseChannel(m_nActiveSamples, soundOffset + SFX_CAR_ACCEL_1, SAMPLEBANK_MAIN)) return; @@ -1707,7 +1703,7 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle } } else if (CurrentPretendGear < params->m_pTransmission->nNumberOfGears - 1) { ++CurrentPretendGear; - curTime = CTimer::GetTimeInMilliseconds(); + gearSoundStartTime = CTimer::GetTimeInMilliseconds(); params->m_pVehicle->bAudioChangingGear = true; if (!SampleManager.InitialiseChannel(m_nActiveSamples, soundOffset + SFX_CAR_ACCEL_1, SAMPLEBANK_MAIN)) return; @@ -1728,11 +1724,11 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle } else { nCruising = 1; params->m_pVehicle->bAudioChangingGear = true; - bAccelSampleStopped = 1; + bAccelSampleStopped = true; SampleManager.StopChannel(m_nActiveSamples); if (PizzaFaggBool || accelerateState >= 150 && wheelsOnGround && brakeState <= 0 && !params->m_pVehicle->bIsHandbrakeOn && !lostTraction && currentGear >= params->m_pTransmission->nNumberOfGears - 1) { - if (accelerateState >= 220 && params->m_fVelocityChange + 0.001 >= velocityChangeForAudio) { + if (accelerateState >= 220 && params->m_fVelocityChange + 0.001f >= velocityChangeForAudio) { if (nCruising < 800) ++nCruising; } else if (nCruising > 3) { @@ -1749,11 +1745,11 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle } } else { params->m_pVehicle->bAudioChangingGear = true; - bAccelSampleStopped = 1; + bAccelSampleStopped = true; SampleManager.StopChannel(m_nActiveSamples); if (PizzaFaggBool || accelerateState >= 150 && wheelsOnGround && brakeState <= 0 && !params->m_pVehicle->bIsHandbrakeOn && !lostTraction && currentGear >= params->m_pTransmission->nNumberOfGears - 1) { - if (accelerateState >= 220 && params->m_fVelocityChange + 0.001 >= velocityChangeForAudio) { + if (accelerateState >= 220 && params->m_fVelocityChange + 0.001f >= velocityChangeForAudio) { if (nCruising < 800) ++nCruising; } else if (nCruising > 3) { diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index dcf6ce2d..64b5c625 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -3,6 +3,7 @@ #include "audio_enums.h" #include "AudioCollision.h" #include "PoliceRadio.h" +#include "VehicleModelInfo.h" class tSound { diff --git a/src/modelinfo/VehicleModelInfo.h b/src/modelinfo/VehicleModelInfo.h index 945bdd92..d9a3f59a 100644 --- a/src/modelinfo/VehicleModelInfo.h +++ b/src/modelinfo/VehicleModelInfo.h @@ -24,7 +24,7 @@ enum { ATOMIC_FLAG_NOCULL = 0x800, }; -enum eVehicleType { +enum eVehicleType : uint8{ VEHICLE_TYPE_CAR, VEHICLE_TYPE_BOAT, VEHICLE_TYPE_TRAIN, From 5b9e4c47802058da5b3841aed2ae175d51487b8b Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Mon, 21 Sep 2020 01:55:22 +0300 Subject: [PATCH 08/10] some style and bug fixes, updated sfx enum, and implemented processVehicleEngine --- src/audio/AudioCollision.cpp | 4 +- src/audio/AudioLogic.cpp | 588 ++++++++++++++++++++++++----------- src/audio/AudioManager.cpp | 4 +- src/audio/AudioManager.h | 2 + src/audio/PoliceRadio.cpp | 2 +- src/audio/sampman.h | 154 +++++---- src/audio/sampman_miles.cpp | 58 ++-- src/audio/sampman_oal.cpp | 26 +- 8 files changed, 541 insertions(+), 297 deletions(-) diff --git a/src/audio/AudioCollision.cpp b/src/audio/AudioCollision.cpp index 55d64714..6ce7bbac 100644 --- a/src/audio/AudioCollision.cpp +++ b/src/audio/AudioCollision.cpp @@ -165,7 +165,7 @@ cAudioManager::SetUpLoopingCollisionSound(const cAudioCollision &col, uint8 coun if(m_sQueueSample.m_nVolume) { m_sQueueSample.m_nCounter = counter; m_sQueueSample.m_vecPos = col.m_vecPosition; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 7; m_sQueueSample.m_nLoopCount = 0; @@ -306,7 +306,7 @@ cAudioManager::SetUpOneShotCollisionSound(const cAudioCollision &col) m_sQueueSample.m_nCounter = counter++; if(counter >= 255) counter = 28; m_sQueueSample.m_vecPos = col.m_vecPosition; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 11; m_sQueueSample.m_nLoopCount = 1; diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 5d889838..10978fb2 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -60,7 +60,7 @@ enum LOADING_STATUS : uint8 { LOADING_STATUS_NOT_LOADED = 0, LOADING_STATUS_LOAD void cAudioManager::PreInitialiseGameSpecificSetup() const { - BankStartOffset[SAMPLEBANK_MAIN] = SAMPLEBANK_START; + BankStartOffset[SFX_BANK_0] = SAMPLEBANK_START; #ifdef GTA_PS2 BankStartOffset[SAMPLEBANK_CAR_PACARD] = SFX_CAR_ACCEL_1; BankStartOffset[SAMPLEBANK_CAR_PATHFINDER] = SFX_CAR_ACCEL_2; @@ -122,7 +122,7 @@ cAudioManager::PreInitialiseGameSpecificSetup() const BankStartOffset[SAMPLEBANK_BUILDING_47] = SFX_CLUB_1_9; BankStartOffset[SAMPLEBANK_EXTRAS] = SFX_EXPLOSION_1; #endif // GTA_PS2 - BankStartOffset[SAMPLEBANK_PED] = SAMPLEBANK_PED_START; + BankStartOffset[SFX_BANK_PED_COMMENTS] = SAMPLEBANK_PED_START; } void @@ -290,7 +290,10 @@ void cAudioManager::CalculateDistance(bool &distCalculated, float dist) { if (!distCalculated) { - m_sQueueSample.m_fDistance = Sqrt(dist); + if (dist <= 0.0) + m_sQueueSample.m_fDistance = 0.0; + else + m_sQueueSample.m_fDistance = Sqrt(dist); distCalculated = true; } } @@ -699,21 +702,12 @@ const bool hornPatternsArray[8][44] = { void cAudioManager::ProcessVehicle(CVehicle* veh) { - CPlayerPed* player; CVehicle* playerVeh; - CEntity* attachedTo; cVehicleParams params; CBike* bike; CAutomobile* automobile; - float gasPedal; - player = FindPlayerPed(); - playerVeh = FindPlayerVehicle(); - if (playerVeh == nil && player != nil) { - attachedTo = player->m_attachedTo; - if (attachedTo != nil && attachedTo->GetType() == ENTITY_TYPE_VEHICLE) - playerVeh = (CVehicle*)attachedTo; - } + playerVeh = FindVehicleOfPlayer(); if (playerVeh == veh || CGame::currArea == AREA_OVALRING || CGame::currArea == AREA_BLOOD @@ -850,7 +844,7 @@ cAudioManager::ProcessRainOnVehicle(cVehicleParams *params) if (veh->m_bRainSamplesCounter > 4) veh->m_bRainSamplesCounter = 68; m_sQueueSample.m_nSampleIndex = (m_anRandomTable[1] & 3) + SFX_CAR_RAIN_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 9; m_sQueueSample.m_nFrequency = m_anRandomTable[1] % 4000 + 28000; @@ -903,7 +897,7 @@ cAudioManager::ProcessReverseGear(cVehicleParams *params) m_sQueueSample.m_nCounter = 61; m_sQueueSample.m_nSampleIndex = SFX_REVERSE_GEAR; } - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_nFrequency = (6000.f * modificator) + 7000; @@ -955,7 +949,7 @@ cAudioManager::ProcessModelCarEngine(cVehicleParams *params) if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 2; m_sQueueSample.m_nSampleIndex = SFX_REMOTE_CONTROLLED_CAR; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nFrequency = (11025.f * velocityChange / params->m_pTransmission->fMaxVelocity + 11025.f); @@ -1001,7 +995,7 @@ cAudioManager::ProcessVehicleRoadNoise(cVehicleParams *params) m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 0; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 3; if (params->m_pVehicle->m_nSurfaceTouched == SURFACE_WATER) { @@ -1056,7 +1050,7 @@ cAudioManager::ProcessWetRoadNoise(cVehicleParams *params) if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 1; m_sQueueSample.m_nSampleIndex = SFX_ROAD_NOISE; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 3; modificator = m_sQueueSample.m_fDistance / 6.f; @@ -1080,6 +1074,237 @@ cAudioManager::ProcessWetRoadNoise(cVehicleParams *params) return true; } +void +cAudioManager::ProcessVehicleEngine1(cVehicleParams* params) +{ + const float SOUND_INTENSITY = 50.0f; + + CVehicle* playerVeh; + CVehicle* veh; + CAutomobile* automobile; + float relativeGearChange; + float relativeChange; + uint8 volume; + int32 freq = 0; + uint8 emittingVol; + cTransmission* transmission; + uint8 currentGear; + float modificator; + float traction = 0.f; + + bool bPizzaFaggio; + bool bCaddy; + CBike* bike; + int8 wheelsOnGround; + int8 wheelsOnGroundPrev; + tWheelState* wheelState; + float* gasPedalAudioPtr; + + float someValue; + + bPizzaFaggio = false; + bCaddy = false; + traction = 0.0f; + if (params->m_fDistance >= SQR(SOUND_INTENSITY)) + return; + playerVeh = FindPlayerVehicle(); + veh = params->m_pVehicle; + if (playerVeh == veh && veh->GetStatus() == STATUS_WRECKED) { + SampleManager.StopChannel(m_nActiveSamples); + return; + } + if (!veh->bEngineOn) + return; + CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); + if (playerVeh == veh && veh->m_modelIndex != MI_CADDY) { + ProcessPlayersVehicleEngine(params, params->m_pVehicle); + return; + } + transmission = params->m_pTransmission; + if (transmission != nil) { + switch (veh->m_modelIndex) { + case MI_PIZZABOY: + case MI_FAGGIO: + bPizzaFaggio = true; + currentGear = transmission->nNumberOfGears; + break; + case MI_CADDY: + currentGear = transmission->nNumberOfGears; + bCaddy = true; + break; + default: + currentGear = veh->m_nCurrentGear; + break; + } + switch (params->m_VehicleType) { + case VEHICLE_TYPE_CAR: + automobile = (CAutomobile*)veh; + wheelsOnGround = automobile->m_nDriveWheelsOnGround; + wheelsOnGroundPrev = automobile->m_nDriveWheelsOnGroundPrev; + wheelState = automobile->m_aWheelState; + gasPedalAudioPtr = &automobile->m_fGasPedalAudio; + break; + case VEHICLE_TYPE_BIKE: + bike = (CBike*)veh; + wheelsOnGround = bike->m_nDriveWheelsOnGround; + wheelsOnGroundPrev = bike->m_nDriveWheelsOnGroundPrev; + wheelState = bike->m_aWheelState; + gasPedalAudioPtr = &bike->m_fGasPedalAudio; + break; + default: + debug(" ** AUDIOLOG: Unrecognised vehicle type %d in ProcessVehicleEngine() * \n", params->m_VehicleType); + return; + } + + if (wheelsOnGround != 0) { + if (!veh->bIsHandbrakeOn || bPizzaFaggio && bCaddy) { //mb bug, bcs it's can't be true together + if (veh->GetStatus() == STATUS_SIMPLE || bPizzaFaggio || bCaddy) { + traction = 0.0f; + } else { + switch (transmission->nDriveType) { + case '4': + if (params->m_VehicleType == VEHICLE_TYPE_BIKE) { + for (int i = 0; i < 2; i++) + if (wheelState[i] == WHEEL_STATE_SPINNING) + traction += 0.1f; + } else { + for (int i = 0; i < 4; i++) + if (wheelState[i] == WHEEL_STATE_SPINNING) + traction += 0.05f; + } + break; + case 'F': + if (params->m_VehicleType == VEHICLE_TYPE_BIKE) { + if (wheelState[BIKEWHEEL_FRONT] == WHEEL_STATE_SPINNING) + traction += 0.2f; + } else { + if (wheelState[CARWHEEL_FRONT_LEFT] == WHEEL_STATE_SPINNING) + traction += 0.1f; + if (wheelState[CARWHEEL_FRONT_RIGHT] == WHEEL_STATE_SPINNING) + traction += 0.1f; + } + break; + case 'R': + if (params->m_VehicleType == VEHICLE_TYPE_BIKE) { + if (wheelState[BIKEWHEEL_REAR] == WHEEL_STATE_SPINNING) + traction += 0.2f; + } else { + if (wheelState[CARWHEEL_REAR_LEFT] == WHEEL_STATE_SPINNING) + traction += 0.1f; + if (wheelState[CARWHEEL_REAR_RIGHT] == WHEEL_STATE_SPINNING) + traction += 0.1f; + } + break; + default: + break; + } + } + } else if (0.0f != params->m_fVelocityChange) { + traction = 0.9f; + } + if (transmission->fMaxVelocity <= 0.0) { + relativeChange = 0.0f; + //var = 0.0f; + //goto lab86; + } + + //201-243 + if (!bPizzaFaggio && !bCaddy) { + if (currentGear != 0) { + relativeGearChange = Min(1.0f, + params->m_fVelocityChange - transmission->Gears[currentGear].fShiftDownVelocity) / transmission->fMaxVelocity * 2.5f; + if (traction != 0.0f && veh->GetStatus() != STATUS_SIMPLE && params->m_fVelocityChange >= transmission->Gears[1].fShiftUpVelocity) + traction = 0.7f; + relativeChange = traction * *gasPedalAudioPtr * 0.95f + (1.0f - traction) * relativeGearChange; + } else { + relativeChange = Min(1.0f, + 1.0f - Abs((params->m_fVelocityChange - transmission->Gears[0].fShiftDownVelocity) / transmission->fMaxReverseVelocity)); + } + //goto lab85 + } + + //244-254 + modificator = Min(1.0, Abs(params->m_fVelocityChange / transmission->fMaxVelocity > 1.0f)); + } else { + if (wheelsOnGroundPrev != 0) + *gasPedalAudioPtr *= 0.4f; + relativeChange = *gasPedalAudioPtr; + modificator = relativeChange; + } + //256-272 + if (currentGear != 0 || wheelsOnGround == 0) + freq = 1200 * currentGear + 18000.0f * modificator + 14000; + else if (params->m_VehicleType == VEHICLE_TYPE_BIKE) + freq = 22050; + else + freq = 13000.0f * modificator + 14000; + if (modificator < 0.75f) + emittingVol = 90; + else + emittingVol = modificator * (4.0f / 3.0f) * 15.0f + 75; + } else { + modificator = 0.0f; + emittingVol = 75; + } + //273- + if (veh->bIsDrowning) + emittingVol /= 4; + if (bCaddy) { + emittingVol = 100.0f * modificator; + freq = 2130.0f * modificator + 4270; + m_sQueueSample.m_nCounter = 2; + } + m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume != 0) { + if (!bCaddy) { + if (veh->GetStatus() == STATUS_SIMPLE) { + if (modificator >= 0.02f) { + m_sQueueSample.m_nSampleIndex = aVehicleSettings[params->m_nIndex].m_nBank - CAR_SFX_BANKS_OFFSET + SFX_CAR_IDLE_1; + m_sQueueSample.m_nCounter = 52; + freq = 10000.0f * modificator + 22050; + } else { + m_sQueueSample.m_nSampleIndex = aVehicleSettings[params->m_nIndex].m_nAccelerationSampleIndex; + m_sQueueSample.m_nCounter = 2; + } + } else { + if (veh->m_fGasPedal >= 0.02f) { + m_sQueueSample.m_nSampleIndex = aVehicleSettings[params->m_nIndex].m_nBank - CAR_SFX_BANKS_OFFSET + SFX_CAR_IDLE_1; + m_sQueueSample.m_nCounter = 52; + freq = 10000.0f * modificator + 22050; + } else { + m_sQueueSample.m_nSampleIndex = aVehicleSettings[params->m_nIndex].m_nAccelerationSampleIndex; + m_sQueueSample.m_nCounter = 2; + } + } + m_sQueueSample.m_nFrequency = freq + 100 * m_sQueueSample.m_nBankIndex % 1000; + } else { + if (FindVehicleOfPlayer() == params->m_pVehicle) + m_sQueueSample.m_nSampleIndex = SFX_CAR_AFTER_ACCEL_12; + else + m_sQueueSample.m_nSampleIndex = SFX_CAR_REV_12; + m_sQueueSample.m_nFrequency = freq + 20 * m_sQueueSample.m_nBankIndex % 100; + } + m_sQueueSample.m_nBankIndex = SFX_BANK_0; + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_nReleasingVolumeModificator = 3; + if (m_sQueueSample.m_nSampleIndex == SFX_CAR_IDLE_5 || m_sQueueSample.m_nSampleIndex == SFX_CAR_REV_5) + m_sQueueSample.m_nFrequency /= 2; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nEmittingVolume = emittingVol; + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_fSpeedMultiplier = 6.0f; + m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; + m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_nReleasingVolumeDivider = 8; + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bRequireReflection = false; + AddSampleToRequestedQueue(); + } + + +} + void cAudioManager::ProcessVehicleEngine(cVehicleParams *params) { @@ -1193,7 +1418,7 @@ cAudioManager::ProcessVehicleEngine(cVehicleParams *params) if (m_sQueueSample.m_nVolume != 0) { if (automobile->GetStatus() == STATUS_SIMPLE) { if (modificator < 0.02f) { - m_sQueueSample.m_nSampleIndex = aVehicleSettings[params->m_nIndex].m_nBank - CAR_SAMPLEBANKS_OFFSET + SFX_CAR_IDLE_1; + m_sQueueSample.m_nSampleIndex = aVehicleSettings[params->m_nIndex].m_nBank - CAR_SFX_BANKS_OFFSET + SFX_CAR_IDLE_1; freq = modificator * 10000 + 22050; m_sQueueSample.m_nCounter = 52; } else { @@ -1202,7 +1427,7 @@ cAudioManager::ProcessVehicleEngine(cVehicleParams *params) } } else { if (automobile->m_fGasPedal < 0.05f) { - m_sQueueSample.m_nSampleIndex = aVehicleSettings[params->m_nIndex].m_nBank - CAR_SAMPLEBANKS_OFFSET + SFX_CAR_IDLE_1; + m_sQueueSample.m_nSampleIndex = aVehicleSettings[params->m_nIndex].m_nBank - CAR_SFX_BANKS_OFFSET + SFX_CAR_IDLE_1; freq = modificator * 10000 + 22050; m_sQueueSample.m_nCounter = 52; } else { @@ -1210,7 +1435,7 @@ cAudioManager::ProcessVehicleEngine(cVehicleParams *params) m_sQueueSample.m_nCounter = 2; } } - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_nFrequency = freq + 100 * m_sQueueSample.m_nEntityIndex % 1000; @@ -1266,7 +1491,7 @@ cAudioManager::AddPlayerCarSample(uint8 emittingVolume, int32 freq, uint32 sampl #ifdef GTA_PS2 m_sQueueSample.m_nBankIndex = bank; #else - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; #endif // GTA_PS2 m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 0; @@ -1304,18 +1529,18 @@ cAudioManager::ProcessCesna(cVehicleParams *params) } else if (nAccel < 60) { ++nAccel; } - AddPlayerCarSample(85 * (60 - nAccel) / 60 + 20, 8500 * nAccel / 60 + 17000, SFX_CESNA_IDLE, SAMPLEBANK_MAIN, 52, true); - AddPlayerCarSample(85 * nAccel / 60 + 20, 8500 * nAccel / 60 + 17000, SFX_CESNA_REV, SAMPLEBANK_MAIN, 2, true); + AddPlayerCarSample(85 * (60 - nAccel) / 60 + 20, 8500 * nAccel / 60 + 17000, SFX_CESNA_IDLE, SFX_BANK_0, 52, true); + AddPlayerCarSample(85 * nAccel / 60 + 20, 8500 * nAccel / 60 + 17000, SFX_CESNA_REV, SFX_BANK_0, 2, true); } } else if (params->m_nIndex == DODO) { - AddPlayerCarSample(105, 17000, SFX_CESNA_IDLE, SAMPLEBANK_MAIN, 52, true); + AddPlayerCarSample(105, 17000, SFX_CESNA_IDLE, SFX_BANK_0, 52, true); } else if (params->m_fDistance < SQR(200)) { CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); m_sQueueSample.m_nVolume = ComputeVolume(80, 200.f, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 52; m_sQueueSample.m_nSampleIndex = SFX_CESNA_IDLE; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 0; m_sQueueSample.m_nFrequency = 12500; @@ -1336,7 +1561,7 @@ cAudioManager::ProcessCesna(cVehicleParams *params) if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 2; m_sQueueSample.m_nSampleIndex = SFX_CESNA_REV; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 0; m_sQueueSample.m_nFrequency = 25000; @@ -1356,7 +1581,8 @@ cAudioManager::ProcessCesna(cVehicleParams *params) } } -void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle* veh) +void +cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle* veh) { static int32 GearFreqAdj[] = { 6000, 6000, 3400, 1200, 0, -1000 }; @@ -1387,7 +1613,7 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle float time; bool channelUsed; bool lostTraction; - bool err; + bool noGearBox; bool stuckInSand; bool processedAccelSampleStopped; bool PizzaFaggBool; @@ -1461,7 +1687,7 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle case '4': if (params->m_VehicleType != VEHICLE_TYPE_BIKE) { wheelInUseCounter = 0; - for (uint8 i = 0; i < ARRAY_SIZE(wheelState); i++) { + for (uint8 i = 0; i < 4; i++) { if (wheelState[i] != WHEEL_STATE_NORMAL) ++wheelInUseCounter; } @@ -1506,56 +1732,56 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle freqModifier += 1400; gearSoundLength = 0; engineSoundType = aVehicleSettings[params->m_nIndex].m_nBank; - soundOffset = 3 * (engineSoundType - 4); - err = false; - switch (soundOffset) { - case 0: + soundOffset = 3 * (engineSoundType - CAR_SFX_BANKS_OFFSET); + noGearBox = false; + switch (engineSoundType) { + case SFX_BANK_PONTIAC: gearSoundLength = 2526; break; - case 3: + case SFX_BANK_PORSCHE: gearSoundLength = 3587; break; - case 6: + case SFX_BANK_SPIDER: gearSoundLength = 4898; break; - case 9: + case SFX_BANK_MERC: gearSoundLength = 4003; break; - case 12: + case SFX_BANK_TRUCK: gearSoundLength = 6289; break; - case 15: + case SFX_BANK_HOTROD: gearSoundLength = 2766; break; - case 18: + case SFX_BANK_COBRA: gearSoundLength = 3523; break; - case 21: + case SFX_BANK_PONTIAC_SLOW: gearSoundLength = 2773; break; - case 24: + case SFX_BANK_CADILLAC: gearSoundLength = 2560; break; - case 27: + case SFX_BANK_PATHFINDER: gearSoundLength = 4228; break; - case 30: + case SFX_BANK_PACARD: gearSoundLength = 4648; break; - case 48: + case SFX_BANK_VTWIN: gearSoundLength = 3480; break; - case 54: + case SFX_BANK_HONDA250: gearSoundLength = 2380; break; - case 57: + case SFX_BANK_SPORTS_BIKE: gearSoundLength = 2410; break; default: - err = true; + noGearBox = true; break; } - if (!channelUsed || nCruising || err) { + if (!channelUsed || nCruising || noGearBox) { gearSoundStartTime = CTimer::GetTimeInMilliseconds(); } else { gearSoundLength -= 1000; @@ -1568,13 +1794,13 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle accelerationMultipler = clamp(relativeVelocityChange, 0.0f, 1.0f); gasPedalAudio = accelerationMultipler; switch (engineSoundType) { - case 21: + case SFX_BANK_MOPED: ++soundOffset; break; - case 22: + case SFX_BANK_HONDA250: soundOffset += 2; break; - case 23: + case SFX_BANK_SPORTS_BIKE: soundOffset += 3; break; default: @@ -1615,18 +1841,18 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle vol = (25.0f * (gasPedalAudio - 0.05f) * 20.f / 19) + 40; if (params->m_pVehicle->bIsDrowning) vol /= 4; - if (engineSoundType == SAMPLEBANK_CAR_COBRA) + if (engineSoundType == SFX_BANK_TRUCK) freq /= 2; AddPlayerCarSample(vol, freq, soundOffset + SFX_CAR_FINGER_OFF_ACCEL_1, engineSoundType, 63, false); } } freq = (10000.f * gasPedalAudio) + 22050; vol = 110 - (40.0f * gasPedalAudio); - if (engineSoundType == SAMPLEBANK_CAR_COBRA) + if (engineSoundType == SFX_BANK_TRUCK) freq /= 2; if (params->m_pVehicle->bIsDrowning) vol /= 4; - AddPlayerCarSample(vol, freq, engineSoundType + SFX_CAR_IDLE_1 - 4, SAMPLEBANK_MAIN, 52, true); + AddPlayerCarSample(vol, freq, engineSoundType - CAR_SFX_BANKS_OFFSET + SFX_CAR_IDLE_1, SFX_BANK_0, 52, true); CurrentPretendGear = Max(1, currentGear); } @@ -1646,14 +1872,14 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle *gasPedalAudioPtr *= 0.6f; } freqModifier = 0; - if (engineSoundType != 15 && engineSoundType != 16) + if (engineSoundType != SFX_BANK_GOLF_CART && engineSoundType != SFX_BANK_CAR_CHAINSAW) baseFreq = (25000.0f * *gasPedalAudioPtr) + 14000; else baseFreq = (15000.0f * *gasPedalAudioPtr) + 14000; vol = (25.0f * *gasPedalAudioPtr) + 60; } freq = freqModifier + baseFreq; - if (engineSoundType == SAMPLEBANK_CAR_COBRA) + if (engineSoundType == SFX_BANK_TRUCK) freq /= 2; if (channelUsed) { SampleManager.StopChannel(m_nActiveSamples); @@ -1661,7 +1887,7 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle } if (params->m_pVehicle->bIsDrowning) vol /= 4; - AddPlayerCarSample(vol, freq, engineSoundType + SFX_CAR_REV_1 - 4, SAMPLEBANK_MAIN, 2, true); + AddPlayerCarSample(vol, freq, engineSoundType - CAR_SFX_BANKS_OFFSET + SFX_CAR_REV_1, SFX_BANK_0, 2, true); } else { TranslateEntity(&m_sQueueSample.m_vecPos, &pos); if (bAccelSampleStopped) { @@ -1675,7 +1901,7 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle SampleManager.SetChannel3DPosition(m_nActiveSamples, pos.x, pos.y, pos.z); SampleManager.SetChannel3DDistances(m_nActiveSamples, 50.0f, 12.5f); freq = (GearFreqAdj[CurrentPretendGear] + freqModifier + 22050) ; - if (engineSoundType == 8) + if (engineSoundType == SFX_BANK_TRUCK) freq /= 2; SampleManager.SetChannelFrequency(m_nActiveSamples, freq); if (!channelUsed) { @@ -1685,7 +1911,7 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle } else if (processedAccelSampleStopped) { gearSoundStartTime = CTimer::GetTimeInMilliseconds(); params->m_pVehicle->bAudioChangingGear = true; - if (!SampleManager.InitialiseChannel(m_nActiveSamples, soundOffset + SFX_CAR_ACCEL_1, SAMPLEBANK_MAIN)) + if (!SampleManager.InitialiseChannel(m_nActiveSamples, soundOffset + SFX_CAR_ACCEL_1, SFX_BANK_0)) return; SampleManager.SetChannelLoopCount(m_nActiveSamples, 1); SampleManager.SetChannelLoopPoints(m_nActiveSamples, 0, -1); @@ -1694,7 +1920,7 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle SampleManager.SetChannel3DPosition(m_nActiveSamples, pos.x, pos.y, pos.z); SampleManager.SetChannel3DDistances(m_nActiveSamples, 50.0f, 12.5f); freq = (GearFreqAdj[CurrentPretendGear] + freqModifier + 22050); - if (engineSoundType == 8) + if (engineSoundType == SFX_BANK_TRUCK) freq /= 2; SampleManager.SetChannelFrequency(m_nActiveSamples, freq); if (!channelUsed) { @@ -1705,7 +1931,7 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle ++CurrentPretendGear; gearSoundStartTime = CTimer::GetTimeInMilliseconds(); params->m_pVehicle->bAudioChangingGear = true; - if (!SampleManager.InitialiseChannel(m_nActiveSamples, soundOffset + SFX_CAR_ACCEL_1, SAMPLEBANK_MAIN)) + if (!SampleManager.InitialiseChannel(m_nActiveSamples, soundOffset + SFX_CAR_ACCEL_1, SFX_BANK_0)) return; SampleManager.SetChannelLoopCount(m_nActiveSamples, 1); SampleManager.SetChannelLoopPoints(m_nActiveSamples, 0, -1); @@ -1714,7 +1940,7 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle SampleManager.SetChannel3DPosition(m_nActiveSamples, pos.x, pos.y, pos.z); SampleManager.SetChannel3DDistances(m_nActiveSamples, 50.0f, 12.5f); freq = (GearFreqAdj[CurrentPretendGear] + freqModifier + 22050); - if (engineSoundType == 8) + if (engineSoundType == SFX_BANK_TRUCK) freq /= 2; SampleManager.SetChannelFrequency(m_nActiveSamples, freq); if (!channelUsed) { @@ -1735,7 +1961,7 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle --nCruising; } freq = 27 * nCruising + freqModifier + 22050; - if (engineSoundType == 8) + if (engineSoundType == SFX_BANK_TRUCK) freq /= 2; AudioManager.AddPlayerCarSample(120, freq, soundOffset + SFX_CAR_AFTER_ACCEL_1, engineSoundType, 64, true); } else { @@ -1756,7 +1982,7 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle --nCruising; } freq = 27 * nCruising + freqModifier + 22050; - if (engineSoundType == 8) + if (engineSoundType == SFX_BANK_TRUCK) freq /= 2; AudioManager.AddPlayerCarSample(120, freq, soundOffset + SFX_CAR_AFTER_ACCEL_1, engineSoundType, 64, true); } else { @@ -1842,7 +2068,7 @@ cAudioManager::ProcessVehicleSkidding(cVehicleParams *params) break; } - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 8; m_sQueueSample.m_nLoopCount = 0; @@ -1932,7 +2158,7 @@ cAudioManager::ProcessVehicleHorn(cVehicleParams *params) if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 4; m_sQueueSample.m_nSampleIndex = aVehicleSettings[params->m_nIndex].m_nHornSample; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 2; m_sQueueSample.m_nFrequency = aVehicleSettings[params->m_nIndex].m_nHornFrequency; @@ -2023,7 +2249,7 @@ cAudioManager::ProcessVehicleSirenOrAlarm(cVehicleParams *params) m_sQueueSample.m_nSampleIndex = aVehicleSettings[params->m_nIndex].m_nSirenOrAlarmSample; m_sQueueSample.m_nFrequency = aVehicleSettings[params->m_nIndex].m_nSirenOrAlarmFrequency; } - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nLoopCount = 0; @@ -2066,7 +2292,7 @@ cAudioManager::ProcessVehicleReverseWarning(cVehicleParams *params) if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 12; m_sQueueSample.m_nSampleIndex = SFX_REVERSE_WARNING; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 2; m_sQueueSample.m_nFrequency = (100 * m_sQueueSample.m_nEntityIndex & 1023) + SampleManager.GetSampleBaseFrequency(SFX_REVERSE_WARNING); @@ -2113,7 +2339,7 @@ cAudioManager::ProcessVehicleDoors(cVehicleParams *params) m_sQueueSample.m_nCounter = i + 6; m_sQueueSample.m_nSampleIndex = m_anRandomTable[1] % 6 + SFX_COL_CAR_PANEL_1; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex) + RandomDisplacement(1000); - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 10; m_sQueueSample.m_nLoopCount = 1; @@ -2158,7 +2384,7 @@ cAudioManager::ProcessAirBrakes(cVehicleParams *params) m_sQueueSample.m_nSampleIndex = SFX_AIR_BRAKES; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_AIR_BRAKES); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16); - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 10; m_sQueueSample.m_nLoopCount = 1; @@ -2214,7 +2440,7 @@ cAudioManager::ProcessEngineDamage(cVehicleParams *params) m_sQueueSample.m_nVolume = ComputeVolume(emittingVolume, engineDamageIntensity, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 28; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nEmittingVolume = emittingVolume; @@ -2246,7 +2472,7 @@ cAudioManager::ProcessCarBombTick(cVehicleParams *params) if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 35; m_sQueueSample.m_nSampleIndex = SFX_COUNTDOWN; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 0; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_COUNTDOWN); @@ -2311,7 +2537,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) m_sQueueSample.m_nSampleIndex = SFX_AIR_BRAKES; break; } - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[i] + 22; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 32); @@ -2345,7 +2571,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) m_sQueueSample.m_nSampleIndex = SFX_AIR_BRAKES; break; } - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[i] + 10; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 32); @@ -2359,7 +2585,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) const float SOUND_INTENSITY = 30.0f; maxDist = SQR(SOUND_INTENSITY); m_sQueueSample.m_nSampleIndex = SFX_GLASS_CRACK; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = 68; emittingVol = m_anRandomTable[1] % 30 + 60; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_GLASS_CRACK); @@ -2372,7 +2598,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) emittingVol = Max(80.f, 2 * (100.f * m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_afVolume[i])); maxDist = SQR(SOUND_INTENSITY); m_sQueueSample.m_nSampleIndex = SFX_TYRE_BUMP; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iWheelIndex++; if (iWheelIndex > 85) iWheelIndex = 82; @@ -2392,7 +2618,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) emittingVol = 60; maxDist = SQR(SOUND_INTENSITY); m_sQueueSample.m_nSampleIndex = SFX_CAR_STARTER; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = 33; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CAR_STARTER); m_sQueueSample.m_nReleasingVolumeModificator = 1; @@ -2404,7 +2630,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) case SOUND_CAR_LIGHT_BREAK: { const float SOUND_INTENSITY = 30.0f; m_sQueueSample.m_nSampleIndex = SFX_GLASS_SHARD_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = 37; m_sQueueSample.m_nFrequency = 9 * SampleManager.GetSampleBaseFrequency(SFX_GLASS_SHARD_1) / 10; m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 8); @@ -2423,7 +2649,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) else m_sQueueSample.m_nFrequency = 13118; m_sQueueSample.m_nSampleIndex = SFX_SUSPENSION_FAST_MOVE; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = 51; m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 8); m_sQueueSample.m_nReleasingVolumeModificator = 5; @@ -2436,7 +2662,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) case SOUND_CAR_HYDRAULIC_3: { const float SOUND_INTENSITY = 35.0f; m_sQueueSample.m_nSampleIndex = SFX_SUSPENSION_SLOW_MOVE_LOOP; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = 86; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_SUSPENSION_SLOW_MOVE_LOOP); m_sQueueSample.m_nReleasingVolumeModificator = 5; @@ -2451,7 +2677,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) case SOUND_CAR_JERK: { const float SOUND_INTENSITY = 35.0f; m_sQueueSample.m_nSampleIndex = SFX_SHAG_SUSPENSION; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = 87; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_SHAG_SUSPENSION); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 8); @@ -2471,7 +2697,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_afVolume[i] = 1200.0f; relVol = (m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_afVolume[i] - 300.f) / 900.f; m_sQueueSample.m_nSampleIndex = (m_anRandomTable[0] & 1) + SFX_BOAT_SPLASH_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = WaveIndex++; if (WaveIndex > 46) WaveIndex = 41; @@ -2486,7 +2712,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) /*case SOUND_17: { const float SOUND_INTENSITY = 50.0f; m_sQueueSample.m_nSampleIndex = SFX_POLICE_BOAT_THUMB_OFF; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = 47; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_POLICE_BOAT_THUMB_OFF) + RandomDisplacement(600); m_sQueueSample.m_nReleasingVolumeModificator = 2; @@ -2500,7 +2726,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) case SOUND_TRAIN_DOOR_OPEN: { const float SOUND_INTENSITY = 35.0f; m_sQueueSample.m_nSampleIndex = SFX_AIR_BRAKES; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = 59; m_sQueueSample.m_nFrequency = RandomDisplacement(1000) + 11025; m_sQueueSample.m_nReleasingVolumeModificator = 5; @@ -2516,7 +2742,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) if (vol > 96.0f / 2500.0f) vol = 96.0f / 2500.0f; m_sQueueSample.m_nSampleIndex = SFX_TANK_TURRET; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = 79; m_sQueueSample.m_nFrequency = (3000.f * vol * 2500.0f / 96.0f) + 9000; m_sQueueSample.m_nReleasingVolumeModificator = 2; @@ -2531,7 +2757,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) case SOUND_CAR_BOMB_TICK: { const float SOUND_INTENSITY = 30.0f; m_sQueueSample.m_nSampleIndex = SFX_BOMB_BEEP; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = 80; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_BOMB_BEEP); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -2545,7 +2771,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) case SOUND_PLANE_ON_GROUND: { const float SOUND_INTENSITY = 180.0f; m_sQueueSample.m_nSampleIndex = SFX_JUMBO_LAND_WHEELS; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = 81; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_JUMBO_LAND_WHEELS); m_sQueueSample.m_nReleasingVolumeModificator = 2; @@ -2560,7 +2786,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) emittingVol = m_anRandomTable[2]; maxDist = SQR(SOUND_INTENSITY); m_sQueueSample.m_nSampleIndex = SFX_UZI_LEFT; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = GunIndex++; emittingVol = emittingVol % 15 + 65; if (GunIndex > 58) @@ -2575,7 +2801,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) case SOUND_WEAPON_HIT_VEHICLE: { const float SOUND_INTENSITY = 40.0f; m_sQueueSample.m_nSampleIndex = m_anRandomTable[m_sQueueSample.m_nEntityIndex % ARRAY_SIZE(m_anRandomTable)] % 6 + SFX_BULLET_CAR_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = 34; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 32); @@ -2592,7 +2818,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) case SOUND_BOMB_TICK: { const float SOUND_INTENSITY = 50.0f; m_sQueueSample.m_nSampleIndex = SFX_ARM_BOMB; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = 36; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_ARM_BOMB); m_sQueueSample.m_nReleasingVolumeModificator = 0; @@ -2622,7 +2848,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) case SOUND_WATER_FALL: { const float SOUND_INTENSITY = 40.0f; m_sQueueSample.m_nSampleIndex = SFX_SPLASH_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = 15; m_sQueueSample.m_nFrequency = RandomDisplacement(1000) + 16000; m_sQueueSample.m_nReleasingVolumeModificator = 1; @@ -2636,7 +2862,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) case SOUND_SPLATTER: { const float SOUND_INTENSITY = 40.0f; m_sQueueSample.m_nSampleIndex = CrunchOffset + SFX_PED_CRUNCH_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = 48; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_PED_CRUNCH_1) + RandomDisplacement(600); m_sQueueSample.m_nReleasingVolumeModificator = 1; @@ -2657,7 +2883,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) continue; m_sQueueSample.m_nSampleIndex = (m_anRandomTable[2] & 3) + SFX_FIGHT_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = 50; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex) / 2; m_sQueueSample.m_nReleasingVolumeModificator = 1; @@ -2713,7 +2939,7 @@ cAudioManager::ProcessTrainNoise(cVehicleParams *params) if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 32; m_sQueueSample.m_nSampleIndex = SFX_TRAIN_FAR; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 2; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_TRAIN_FAR); @@ -2736,7 +2962,7 @@ cAudioManager::ProcessTrainNoise(cVehicleParams *params) if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 33; m_sQueueSample.m_nSampleIndex = SFX_TRAIN_NEAR; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 5; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_TRAIN_NEAR) + 100 * m_sQueueSample.m_nEntityIndex % 987; @@ -2782,7 +3008,7 @@ cAudioManager::ProcessBoatEngine(cVehicleParams *params) m_sQueueSample.m_nSampleIndex = SFX_FISHING_BOAT_IDLE; m_sQueueSample.m_nFrequency = 10386; m_sQueueSample.m_nFrequency += (m_sQueueSample.m_nEntityIndex * 65536) % 1000; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_nLoopCount = 0; @@ -2822,7 +3048,7 @@ cAudioManager::ProcessBoatEngine(cVehicleParams *params) m_sQueueSample.m_nCounter = 40; m_sQueueSample.m_nSampleIndex = SFX_FISHING_BOAT_IDLE; m_sQueueSample.m_nFrequency += (m_sQueueSample.m_nEntityIndex * 65536) % 1000; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_nLoopCount = 0; @@ -2878,7 +3104,7 @@ cAudioManager::ProcessBoatEngine(cVehicleParams *params) if (!m_sQueueSample.m_nVolume) return true; m_sQueueSample.m_nFrequency += (m_sQueueSample.m_nEntityIndex * 65536) % 1000; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_nLoopCount = 0; @@ -2920,7 +3146,7 @@ cAudioManager::ProcessBoatMovingOverWater(cVehicleParams *params) if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 38; m_sQueueSample.m_nSampleIndex = SFX_BOAT_WATER_LOOP; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_nFrequency = (6050.f * multiplier) + 16000; @@ -2976,7 +3202,7 @@ cAudioManager::ProcessHelicopter(cVehicleParams *params) if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = i + 65; m_sQueueSample.m_nSampleIndex = i + SFX_HELI_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 0; m_sQueueSample.m_nFrequency = 1200 * heli->m_nHeliId + SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); @@ -3150,7 +3376,7 @@ cAudioManager::SetupJumboTaxiSound(uint8 vol) if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 1; m_sQueueSample.m_nSampleIndex = SFX_JUMBO_TAXI; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nFrequency = GetJumboTaxiFreq(); @@ -3182,7 +3408,7 @@ cAudioManager::SetupJumboWhineSound(uint8 emittingVol, int32 freq) if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 2; m_sQueueSample.m_nSampleIndex = SFX_JUMBO_WHINE; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nFrequency = freq; @@ -3213,7 +3439,7 @@ cAudioManager::SetupJumboEngineSound(uint8 vol, int32 freq) if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 3; m_sQueueSample.m_nSampleIndex = SFX_JUMBO_ENGINE; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nFrequency = freq; @@ -3244,7 +3470,7 @@ cAudioManager::SetupJumboFlySound(uint8 emittingVol) if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nSampleIndex = SFX_JUMBO_DIST_FLY; m_sQueueSample.m_nCounter = 0; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nEmittingVolume = emittingVol; @@ -3274,7 +3500,7 @@ cAudioManager::SetupJumboRumbleSound(uint8 emittingVol) if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 5; m_sQueueSample.m_nSampleIndex = SFX_JUMBO_RUMBLE; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = true; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_JUMBO_RUMBLE); @@ -3397,7 +3623,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) break; } m_sQueueSample.m_nSampleIndex = sampleIndex; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[i] - 28; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 17); @@ -3440,7 +3666,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) } else { m_sQueueSample.m_nSampleIndex = SFX_BODY_LAND_AND_FALL; } - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = 1; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 17); @@ -3459,7 +3685,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) case SOUND_FIGHT_37: m_sQueueSample.m_nSampleIndex = SFX_FIGHT_1; m_sQueueSample.m_nFrequency = 18000; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound; stereo = true; ++iSound; @@ -3479,7 +3705,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) case SOUND_FIGHT_38: m_sQueueSample.m_nSampleIndex = SFX_FIGHT_1; m_sQueueSample.m_nFrequency = 16500; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound; stereo = true; ++iSound; @@ -3499,7 +3725,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) case SOUND_FIGHT_39: m_sQueueSample.m_nSampleIndex = SFX_FIGHT_1; m_sQueueSample.m_nFrequency = 20000; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound; stereo = true; ++iSound; @@ -3519,7 +3745,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) case SOUND_FIGHT_40: m_sQueueSample.m_nSampleIndex = SFX_FIGHT_2; m_sQueueSample.m_nFrequency = 18000; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound; stereo = true; ++iSound; @@ -3539,7 +3765,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) case SOUND_FIGHT_41: m_sQueueSample.m_nSampleIndex = SFX_FIGHT_2; m_sQueueSample.m_nFrequency = 16500; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound; stereo = true; ++iSound; @@ -3559,7 +3785,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) case SOUND_FIGHT_42: m_sQueueSample.m_nSampleIndex = SFX_FIGHT_2; m_sQueueSample.m_nFrequency = 20000; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound; stereo = true; ++iSound; @@ -3579,7 +3805,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) case SOUND_FIGHT_43: m_sQueueSample.m_nSampleIndex = SFX_FIGHT_4; m_sQueueSample.m_nFrequency = 18000; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound; stereo = true; ++iSound; @@ -3599,7 +3825,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) case SOUND_FIGHT_44: m_sQueueSample.m_nSampleIndex = SFX_FIGHT_4; m_sQueueSample.m_nFrequency = 16500; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound; stereo = true; ++iSound; @@ -3619,7 +3845,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) case SOUND_FIGHT_45: m_sQueueSample.m_nSampleIndex = SFX_FIGHT_4; m_sQueueSample.m_nFrequency = 20000; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound; stereo = true; ++iSound; @@ -3639,7 +3865,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) case SOUND_FIGHT_46: m_sQueueSample.m_nSampleIndex = SFX_FIGHT_5; m_sQueueSample.m_nFrequency = 18000; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound; stereo = true; ++iSound; @@ -3659,7 +3885,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) case SOUND_FIGHT_47: m_sQueueSample.m_nSampleIndex = SFX_FIGHT_5; m_sQueueSample.m_nFrequency = 16500; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound; stereo = true; ++iSound; @@ -3679,7 +3905,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) case SOUND_FIGHT_48: m_sQueueSample.m_nSampleIndex = SFX_FIGHT_5; m_sQueueSample.m_nFrequency = 20000; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound; stereo = true; ++iSound; @@ -3698,7 +3924,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) break; case SOUND_WEAPON_BAT_ATTACK: m_sQueueSample.m_nSampleIndex = SFX_BAT_HIT_LEFT; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound++; stereo = true; m_sQueueSample.m_nFrequency = RandomDisplacement(2000) + 22000; @@ -3723,7 +3949,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) switch (weapon->m_eWeaponType) { case WEAPONTYPE_COLT45: m_sQueueSample.m_nSampleIndex = SFX_COLT45_LEFT; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound++; stereo = true; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_COLT45_LEFT); @@ -3746,7 +3972,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) break; case WEAPONTYPE_UZI: m_sQueueSample.m_nSampleIndex = SFX_UZI_LEFT; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound++; stereo = true; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_UZI_LEFT); @@ -3765,7 +3991,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) break; case WEAPONTYPE_SHOTGUN: m_sQueueSample.m_nSampleIndex = SFX_SHOTGUN_LEFT; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound++; stereo = true; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_SHOTGUN_LEFT); @@ -3788,7 +4014,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) break; case WEAPONTYPE_RUGER: m_sQueueSample.m_nSampleIndex = SFX_AK47_LEFT; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound++; stereo = true; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_AK47_LEFT); @@ -3807,7 +4033,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) break; case WEAPONTYPE_M4: m_sQueueSample.m_nSampleIndex = SFX_M60_LEFT; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound++; stereo = true; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_M60_LEFT); @@ -3826,7 +4052,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) break; case WEAPONTYPE_SNIPERRIFLE: m_sQueueSample.m_nSampleIndex = SFX_SNIPER_LEFT; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound++; stereo = true; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_SNIPER_LEFT); @@ -3849,7 +4075,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) break; case WEAPONTYPE_ROCKETLAUNCHER: m_sQueueSample.m_nSampleIndex = SFX_ROCKET_LEFT; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound++; stereo = true; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_ROCKET_LEFT); @@ -3872,7 +4098,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) break; case WEAPONTYPE_FLAMETHROWER: m_sQueueSample.m_nSampleIndex = SFX_FLAMETHROWER_LEFT; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = 9; emittingVol = 90; m_sQueueSample.m_nFrequency = (10 * m_sQueueSample.m_nEntityIndex & 2047) + SampleManager.GetSampleBaseFrequency(SFX_FLAMETHROWER_LEFT); @@ -3935,7 +4161,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) m_sQueueSample.m_nCounter = iSound++; stereo = true; m_sQueueSample.m_nFrequency += RandomDisplacement(300); - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nReleasingVolumeModificator = 5; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_fSoundIntensity = 30.0f; @@ -3950,7 +4176,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) break; case SOUND_WEAPON_AK47_BULLET_ECHO: m_sQueueSample.m_nSampleIndex = SFX_UZI_END_LEFT; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound++; stereo = true; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_UZI_END_LEFT); @@ -3973,7 +4199,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) break; case SOUND_WEAPON_FLAMETHROWER_FIRE: m_sQueueSample.m_nSampleIndex = SFX_FLAMETHROWER_START_LEFT; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound++; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_FLAMETHROWER_START_LEFT); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16); @@ -3991,7 +4217,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) break; case SOUND_WEAPON_HIT_PED: m_sQueueSample.m_nSampleIndex = SFX_BULLET_PED; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound++; stereo = true; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_BULLET_PED); @@ -4010,7 +4236,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) break; case SOUND_SPLASH: m_sQueueSample.m_nSampleIndex = SFX_SPLASH_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nCounter = iSound++; stereo = true; m_sQueueSample.m_nFrequency = RandomDisplacement(1400) + 20000; @@ -4240,7 +4466,7 @@ cPedComments::Process() AudioManager.m_sQueueSample.m_nEntityIndex = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nEntityIndex; AudioManager.m_sQueueSample.m_nCounter = 0; AudioManager.m_sQueueSample.m_nSampleIndex = sampleIndex; - AudioManager.m_sQueueSample.m_nBankIndex = SAMPLEBANK_PED; + AudioManager.m_sQueueSample.m_nBankIndex = SFX_BANK_PED_COMMENTS; AudioManager.m_sQueueSample.m_nReleasingVolumeModificator = 3; AudioManager.m_sQueueSample.m_nVolume = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_bVolume; AudioManager.m_sQueueSample.m_fDistance = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_fDistance; @@ -4281,11 +4507,11 @@ cPedComments::Process() // Switch bank if (m_nActiveBank) { - actualUsedBank = SAMPLEBANK_PED; - m_nActiveBank = SAMPLEBANK_MAIN; + actualUsedBank = SFX_BANK_PED_COMMENTS; + m_nActiveBank = SFX_BANK_0; } else { - actualUsedBank = SAMPLEBANK_MAIN; - m_nActiveBank = SAMPLEBANK_PED; + actualUsedBank = SFX_BANK_0; + m_nActiveBank = SFX_BANK_PED_COMMENTS; } comment = m_asPedComments[actualUsedBank]; for (uint32 i = 0; i < m_nCommentsInBank[actualUsedBank]; i++) { @@ -4325,14 +4551,14 @@ cAudioManager::ProcessExplosions(int32 explosion) m_sQueueSample.m_nSampleIndex = SFX_EXPLOSION_2; m_sQueueSample.m_nFrequency = RandomDisplacement(2000) + 38000; m_sQueueSample.m_nReleasingVolumeModificator = 0; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; break; case EXPLOSION_MOLOTOV: m_sQueueSample.m_fSoundIntensity = 200.0f; m_sQueueSample.m_nSampleIndex = SFX_EXPLOSION_3; m_sQueueSample.m_nFrequency = RandomDisplacement(1000) + 19000; m_sQueueSample.m_nReleasingVolumeModificator = 0; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; break; case EXPLOSION_MINE: case EXPLOSION_HELI_BOMB: @@ -4340,7 +4566,7 @@ cAudioManager::ProcessExplosions(int32 explosion) m_sQueueSample.m_nSampleIndex = SFX_ROCKET_LEFT; m_sQueueSample.m_nFrequency = RandomDisplacement(1000) + 12347; m_sQueueSample.m_nReleasingVolumeModificator = 0; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; break; default: m_sQueueSample.m_fSoundIntensity = 400.0f; @@ -4349,7 +4575,7 @@ cAudioManager::ProcessExplosions(int32 explosion) if (type == EXPLOSION_HELI) m_sQueueSample.m_nFrequency = 8 * m_sQueueSample.m_nFrequency / 10; m_sQueueSample.m_nReleasingVolumeModificator = 0; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_EXTRAS; + m_sQueueSample.m_nBankIndex = SFX_BANK_GENERIC_EXTRA; break; } pos = CExplosion::GetExplosionPosition(i); @@ -4428,7 +4654,7 @@ cAudioManager::ProcessFires(int32) m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = i; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_nReleasingVolumeDivider = 10; m_sQueueSample.m_bIs2D = false; @@ -4461,7 +4687,7 @@ cAudioManager::ProcessWaterCannon(int32) if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; m_sQueueSample.m_nSampleIndex = SFX_JUMBO_TAXI; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nFrequency = 15591; m_sQueueSample.m_nReleasingVolumeModificator = 5; m_sQueueSample.m_nCounter = i; @@ -4530,7 +4756,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) case SCRIPT_SOUND_GATE_STOP_CLUNK: m_sQueueSample.m_fSoundIntensity = 40.0f; m_sQueueSample.m_nSampleIndex = SFX_COL_GATE; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; if (sound == SCRIPT_SOUND_GATE_START_CLUNK) m_sQueueSample.m_nFrequency = 10600; else @@ -4546,7 +4772,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) case SCRIPT_SOUND_BULLET_HIT_GROUND_3: m_sQueueSample.m_fSoundIntensity = 50.0f; m_sQueueSample.m_nSampleIndex = m_anRandomTable[iSound % 5] % 3 + SFX_BULLET_WALL_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 32); m_sQueueSample.m_nReleasingVolumeModificator = 9; @@ -4571,7 +4797,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) case SCRIPT_SOUND_PAYPHONE_RINGING: m_sQueueSample.m_fSoundIntensity = 80.0f; m_sQueueSample.m_nSampleIndex = SFX_PHONE_RING; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; emittingVolume = 80; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_PHONE_RING); m_sQueueSample.m_nReleasingVolumeModificator = 1; @@ -4582,7 +4808,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) case SCRIPT_SOUND_GLASS_BREAK_L: m_sQueueSample.m_fSoundIntensity = 60.0f; m_sQueueSample.m_nSampleIndex = SFX_GLASS_SMASH; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; emittingVolume = 70; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_GLASS_SMASH); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -4592,7 +4818,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) case SCRIPT_SOUND_GLASS_BREAK_S: m_sQueueSample.m_fSoundIntensity = 60.0f; m_sQueueSample.m_nSampleIndex = SFX_GLASS_SMASH; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; emittingVolume = 60; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_GLASS_SMASH); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -4602,7 +4828,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) case SCRIPT_SOUND_GLASS_CRACK: m_sQueueSample.m_fSoundIntensity = 60.0f; m_sQueueSample.m_nSampleIndex = SFX_GLASS_CRACK; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; emittingVolume = 70; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_GLASS_CRACK); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -4613,7 +4839,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) case SCRIPT_SOUND_GLASS_LIGHT_BREAK: m_sQueueSample.m_fSoundIntensity = 55.0f; m_sQueueSample.m_nSampleIndex = (m_anRandomTable[4] & 3) + SFX_GLASS_SHARD_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nFrequency = RandomDisplacement(2000) + 19000; m_sQueueSample.m_nReleasingVolumeModificator = 9; m_sQueueSample.m_fSpeedMultiplier = 0.0f; @@ -4623,7 +4849,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) case SCRIPT_SOUND_BOX_DESTROYED_1: m_sQueueSample.m_fSoundIntensity = 60.0f; m_sQueueSample.m_nSampleIndex = SFX_WOODEN_BOX_SMASH; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nFrequency = RandomDisplacement(1500) + 18600; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; @@ -4634,7 +4860,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) case SCRIPT_SOUND_BOX_DESTROYED_2: m_sQueueSample.m_fSoundIntensity = 60.0f; m_sQueueSample.m_nSampleIndex = SFX_CARDBOARD_BOX_SMASH; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nFrequency = RandomDisplacement(1500) + 18600; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; @@ -4645,7 +4871,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) case SCRIPT_SOUND_METAL_COLLISION: m_sQueueSample.m_fSoundIntensity = 60.0f; m_sQueueSample.m_nSampleIndex = m_anRandomTable[3] % 5 + SFX_COL_CAR_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -4657,7 +4883,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) case SCRIPT_SOUND_TIRE_COLLISION: m_sQueueSample.m_fSoundIntensity = 60.0f; m_sQueueSample.m_nSampleIndex = SFX_TYRE_BUMP; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -4682,7 +4908,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) m_sQueueSample.m_nFrequency = RandomDisplacement(500) + 11000; m_sQueueSample.m_nReleasingVolumeModificator = 18; m_sQueueSample.m_fSoundIntensity = 20.0f; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_bIs2D = false; emittingVolume = m_anRandomTable[2] % 20 + 30; @@ -4712,7 +4938,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) m_sQueueSample.m_nFrequency = RandomDisplacement(750) + 18000; m_sQueueSample.m_nReleasingVolumeModificator = 15; m_sQueueSample.m_fSoundIntensity = 20.0f; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_bIs2D = false; emittingVolume = m_anRandomTable[2] % 20 + 30; @@ -4722,7 +4948,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) m_sQueueSample.m_nFrequency = RandomDisplacement(500) + 11000; m_sQueueSample.m_nReleasingVolumeModificator = 18; m_sQueueSample.m_fSoundIntensity = 20.0f; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_bIs2D = false; emittingVolume = m_anRandomTable[2] % 20 + 30; @@ -4758,7 +4984,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_1_LOOP_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_CLUB_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_CLUB_1; + m_sQueueSample.m_nBankIndex = SFX_BANK_0;//SAMPLEBANK_BUILDING_CLUB_1; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_1); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -4768,7 +4994,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_1_LOOP_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_CLUB_1; + m_sQueueSample.m_nBankIndex = SFX_BANK_0;//SAMPLEBANK_BUILDING_CLUB_1; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_1); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -4778,7 +5004,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_2_LOOP_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_CLUB_2; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_CLUB_2; + m_sQueueSample.m_nBankIndex = SFX_BANK_0;//SAMPLEBANK_BUILDING_CLUB_2; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_2); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -4788,7 +5014,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_2_LOOP_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_2; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_CLUB_2; + m_sQueueSample.m_nBankIndex = SFX_BANK_0;//SAMPLEBANK_BUILDING_CLUB_2; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_2); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -4798,7 +5024,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_3_LOOP_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_CLUB_3; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_CLUB_3; + m_sQueueSample.m_nBankIndex = SFX_BANK_0;//SAMPLEBANK_BUILDING_CLUB_3; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_3); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -4808,7 +5034,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_3_LOOP_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_3; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_CLUB_3; + m_sQueueSample.m_nBankIndex = SFX_BANK_0;//SAMPLEBANK_BUILDING_CLUB_3; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_3); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -4818,7 +5044,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_4_LOOP_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_CLUB_4; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_CLUB_4; + m_sQueueSample.m_nBankIndex = SFX_BANK_0;//SAMPLEBANK_BUILDING_CLUB_4; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_4); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -4828,7 +5054,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_4_LOOP_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_4; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_CLUB_4; + m_sQueueSample.m_nBankIndex = SFX_BANK_0;//SAMPLEBANK_BUILDING_CLUB_4; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_4); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -4838,7 +5064,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_1_LOOP: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_CLUB_1; + m_sQueueSample.m_nBankIndex = SFX_BANK_0;//SAMPLEBANK_BUILDING_CLUB_1; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_1); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -4848,7 +5074,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PRETEND_FIRE_LOOP: m_sQueueSample.m_fSoundIntensity = 50.0f; m_sQueueSample.m_nSampleIndex = SFX_CAR_ON_FIRE; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; emittingVolume = 80; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CAR_ON_FIRE); m_sQueueSample.m_nReleasingVolumeModificator = 8; @@ -4888,12 +5114,12 @@ cAudioManager::ProcessWeather(int32 id) if (m_asAudioEntities[id].m_AudioEvents && m_asAudioEntities[id].m_awAudioEvent[0] == SOUND_LIGHTNING) { if (m_asAudioEntities[id].m_afVolume[0] >= 10.f) { m_sQueueSample.m_nSampleIndex = SFX_EXPLOSION_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_EXTRAS; + m_sQueueSample.m_nBankIndex = SFX_BANK_GENERIC_EXTRA; m_sQueueSample.m_nFrequency = RandomDisplacement(500) + 4000; vol = (m_asAudioEntities[id].m_afVolume[0] - 10.f) + 40; } else { m_sQueueSample.m_nSampleIndex = SFX_EXPLOSION_2; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nFrequency = RandomDisplacement(500) + 4000; vol = (m_asAudioEntities[id].m_afVolume[0]) + 35; } @@ -4920,7 +5146,7 @@ cAudioManager::ProcessWeather(int32 id) m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_RAIN); m_sQueueSample.m_nVolume = (int32)(25.f * CWeather::Rain); m_sQueueSample.m_nCounter = 4; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nReleasingVolumeModificator = 0; m_sQueueSample.m_nOffset = 63; m_sQueueSample.m_bIs2D = true; @@ -5086,7 +5312,7 @@ cAudioManager::ProcessFrontEnd() m_sQueueSample.m_nCounter = iSound++; m_sQueueSample.m_nLoopCount = 1; m_sQueueSample.m_bReleasingSoundFlag = true; - m_sQueueSample.m_nBankIndex = frontendBank ? SAMPLEBANK_FRONTEND : SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = frontendBank ? SFX_BANK_FRONT_END_MENU : SFX_BANK_0; m_sQueueSample.m_nReleasingVolumeModificator = 0; m_sQueueSample.m_bIs2D = true; m_sQueueSample.m_nEmittingVolume = m_sQueueSample.m_nVolume; @@ -5127,7 +5353,7 @@ cAudioManager::ProcessCrane() if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_nSampleIndex = SFX_CRANE_MAGNET; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 2; m_sQueueSample.m_nFrequency = 6000; @@ -5174,7 +5400,7 @@ cAudioManager::ProcessProjectiles() emittingVol = MAX_VOLUME; m_sQueueSample.m_fSoundIntensity = rocketLauncherIntensity; m_sQueueSample.m_nSampleIndex = SFX_ROCKET_FLY; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_ROCKET_FLY); m_sQueueSample.m_nReleasingVolumeModificator = 3; break; @@ -5182,7 +5408,7 @@ cAudioManager::ProcessProjectiles() emittingVol = molotovVolume; m_sQueueSample.m_fSoundIntensity = molotovIntensity; m_sQueueSample.m_nSampleIndex = SFX_PED_ON_FIRE; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nFrequency = 32 * SampleManager.GetSampleBaseFrequency(SFX_PED_ON_FIRE) / 25; m_sQueueSample.m_nReleasingVolumeModificator = 7; break; @@ -5278,7 +5504,7 @@ cAudioManager::ProcessGarages() m_sQueueSample.m_bReleasingSoundFlag = false; } - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_nEmittingVolume = 90; @@ -5311,7 +5537,7 @@ cAudioManager::ProcessGarages() m_sQueueSample.m_nSampleIndex = SFX_COL_GARAGE_DOOR_1; m_sQueueSample.m_nFrequency = 18000; } - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nReleasingVolumeModificator = 4; m_sQueueSample.m_nEmittingVolume = 60; m_sQueueSample.m_fSpeedMultiplier = 0.0f; @@ -5352,7 +5578,7 @@ cAudioManager::ProcessFireHydrant() if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_nSampleIndex = SFX_JUMBO_TAXI; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 4; m_sQueueSample.m_nFrequency = 15591; @@ -5439,7 +5665,7 @@ cAudioManager::ProcessBridgeMotor() if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 1; m_sQueueSample.m_nSampleIndex = SFX_FISHING_BOAT_IDLE; // todo check sfx name - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nFrequency = 5500; @@ -5474,7 +5700,7 @@ cAudioManager::ProcessBridgeOneShots() m_sQueueSample.m_nVolume = ComputeVolume(MAX_VOLUME, bridgeIntensity, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 2; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index f5cd9361..c0a70e31 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -86,7 +86,7 @@ cAudioManager::Terminate() m_sAudioScriptObjectManager.m_nScriptObjectEntityTotal = 0; PreTerminateGameSpecificShutdown(); - for (uint32 i = 0; i < MAX_SAMPLEBANKS; i++) { + for (uint32 i = 0; i < MAX_SFX_BANKS; i++) { if (SampleManager.IsSampleBankLoaded(i)) SampleManager.UnloadSampleBank(i); } @@ -934,7 +934,7 @@ cAudioManager::ClearActiveSamples() m_asActiveSamples[i].m_nEntityIndex = AEHANDLE_NONE; m_asActiveSamples[i].m_nCounter = 0; m_asActiveSamples[i].m_nSampleIndex = NO_SAMPLE; - m_asActiveSamples[i].m_nBankIndex = SAMPLEBANK_INVALID; + m_asActiveSamples[i].m_nBankIndex = INVALID_SFX_BANK; m_asActiveSamples[i].m_bIs2D = false; m_asActiveSamples[i].m_nReleasingVolumeModificator = 5; m_asActiveSamples[i].m_nFrequency = 0; diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index 64b5c625..20b9006a 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -371,6 +371,8 @@ public: void ProcessWeather(int32 id); bool ProcessWetRoadNoise(cVehicleParams *params); + void ProcessVehicleEngine1(cVehicleParams* params); + int32 RandomDisplacement(uint32 seed) const; void ReacquireDigitalHandle() const; void ReleaseDigitalHandle() const; diff --git a/src/audio/PoliceRadio.cpp b/src/audio/PoliceRadio.cpp index 5843fd09..a0c727cc 100644 --- a/src/audio/PoliceRadio.cpp +++ b/src/audio/PoliceRadio.cpp @@ -103,7 +103,7 @@ cAudioManager::DoPoliceRadioCrackle() m_sQueueSample.m_nEntityIndex = m_nPoliceChannelEntity; m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_nSampleIndex = SFX_POLICE_RADIO_CRACKLE; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = true; m_sQueueSample.m_nReleasingVolumeModificator = 10; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_POLICE_RADIO_CRACKLE); diff --git a/src/audio/sampman.h b/src/audio/sampman.h index a96704a1..dc4a8e3e 100644 --- a/src/audio/sampman.h +++ b/src/audio/sampman.h @@ -16,85 +16,101 @@ struct tSample { #ifdef GTA_PS2 #define PS2BANK(e) e #else -#define PS2BANK(e) e = SAMPLEBANK_MAIN +#define PS2BANK(e) e = SFX_BANK_0 #endif // GTA_PS2 enum { - SAMPLEBANK_MAIN, + SFX_BANK_0, +#ifdef GTA_PS2 + SFX_BANK_GENERIC_EXTRA, + SFX_BANK_PED_COMMENTS, + SFX_BANK_FRONT_END_MENU, +#else + SFX_BANK_GENERIC_EXTRA = SFX_BANK_0, + SFX_BANK_FRONT_END_MENU = SFX_BANK_0, - CAR_SAMPLEBANKS_OFFSET, - SAMPLEBANK_CAR_PACARD = CAR_SAMPLEBANKS_OFFSET, - SAMPLEBANK_CAR_PATHFINDER, - SAMPLEBANK_CAR_PORSCHE, - SAMPLEBANK_CAR_SPIDER, - SAMPLEBANK_CAR_MERC, - SAMPLEBANK_CAR_MACKTRUCK, - SAMPLEBANK_CAR_HOTROD, - SAMPLEBANK_CAR_COBRA, - SAMPLEBANK_CAR_NONE, + SFX_BANK_PED_COMMENTS, + MAX_SFX_BANKS, + INVALID_SFX_BANK, +#endif - PS2BANK(SAMPLEBANK_FRONTEND), + CAR_SFX_BANKS_OFFSET, + SFX_BANK_PONTIAC = CAR_SFX_BANKS_OFFSET, + SFX_BANK_PORSCHE, + SFX_BANK_SPIDER, + SFX_BANK_MERC, + SFX_BANK_TRUCK, + SFX_BANK_HOTROD, + SFX_BANK_COBRA, + SFX_BANK_PONTIAC_SLOW, + SFX_BANK_CADILLAC, + SFX_BANK_PATHFINDER, + SFX_BANK_PACARD, + SFX_BANK_GOLF_CART, + SFX_BANK_CAR_CHAINSAW, + SFX_BANK_RC, + SFX_BANK_RC_HELI, + SFX_BANK_CAR_UNUSED_4, - PS2BANK(SAMPLEBANK_TRAIN), + // bikes + SFX_BANK_VTWIN, + SFX_BANK_MOPED, + SFX_BANK_HONDA250, + SFX_BANK_SPORTS_BIKE, + SFX_BANK_BIKE_UNUSED_1, + SFX_BANK_BIKE_UNUSED_2, + SFX_BANK_BIKE_UNUSED_3, + SFX_BANK_BIKE_UNUSED_4, + SFX_BANK_BIKE_UNUSED_5, + SFX_BANK_BIKE_UNUSED_6, - PS2BANK(SAMPLEBANK_BUILDING_CLUB_1), - PS2BANK(SAMPLEBANK_BUILDING_CLUB_2), - PS2BANK(SAMPLEBANK_BUILDING_CLUB_3), - PS2BANK(SAMPLEBANK_BUILDING_CLUB_4), - PS2BANK(SAMPLEBANK_BUILDING_CLUB_5), - PS2BANK(SAMPLEBANK_BUILDING_CLUB_6), - PS2BANK(SAMPLEBANK_BUILDING_CLUB_7), - PS2BANK(SAMPLEBANK_BUILDING_CLUB_8), - PS2BANK(SAMPLEBANK_BUILDING_CLUB_9), - PS2BANK(SAMPLEBANK_BUILDING_CLUB_10), - PS2BANK(SAMPLEBANK_BUILDING_CLUB_11), - PS2BANK(SAMPLEBANK_BUILDING_CLUB_12), - PS2BANK(SAMPLEBANK_BUILDING_CLUB_RAGGA), - PS2BANK(SAMPLEBANK_BUILDING_STRIP_CLUB_1), - PS2BANK(SAMPLEBANK_BUILDING_STRIP_CLUB_2), - PS2BANK(SAMPLEBANK_BUILDING_WORKSHOP), - PS2BANK(SAMPLEBANK_BUILDING_PIANO_BAR), - PS2BANK(SAMPLEBANK_BUILDING_SAWMILL), - PS2BANK(SAMPLEBANK_BUILDING_DOG_FOOD_FACTORY), - PS2BANK(SAMPLEBANK_BUILDING_LAUNDERETTE), - PS2BANK(SAMPLEBANK_BUILDING_RESTAURANT_CHINATOWN), - PS2BANK(SAMPLEBANK_BUILDING_RESTAURANT_ITALY), - PS2BANK(SAMPLEBANK_BUILDING_RESTAURANT_GENERIC_1), - PS2BANK(SAMPLEBANK_BUILDING_RESTAURANT_GENERIC_2), - PS2BANK(SAMPLEBANK_BUILDING_AIRPORT), - PS2BANK(SAMPLEBANK_BUILDING_SHOP), - PS2BANK(SAMPLEBANK_BUILDING_CINEMA), - PS2BANK(SAMPLEBANK_BUILDING_DOCKS), - PS2BANK(SAMPLEBANK_BUILDING_HOME), - PS2BANK(SAMPLEBANK_BUILDING_PORN_1), - PS2BANK(SAMPLEBANK_BUILDING_PORN_2), - PS2BANK(SAMPLEBANK_BUILDING_PORN_3), - PS2BANK(SAMPLEBANK_BUILDING_POLICE_BALL), - PS2BANK(SAMPLEBANK_BUILDING_BANK_ALARM), - PS2BANK(SAMPLEBANK_BUILDING_RAVE_INDUSTRIAL), - PS2BANK(SAMPLEBANK_BUILDING_RAVE_COMMERCIAL), - PS2BANK(SAMPLEBANK_BUILDING_RAVE_SUBURBAN), - PS2BANK(SAMPLEBANK_BUILDING_RAVE_COMMERCIAL_2), + // heli + SFX_BANK_HELI_APACHE, + SFX_BANK_HELI_UNUSED_1, + SFX_BANK_HELI_UNUSED_2, + SFX_BANK_HELI_UNUSED_3, + SFX_BANK_HELI_UNUSED_4, - PS2BANK(SAMPLEBANK_BUILDING_39), - PS2BANK(SAMPLEBANK_BUILDING_40), - PS2BANK(SAMPLEBANK_BUILDING_41), - PS2BANK(SAMPLEBANK_BUILDING_42), - PS2BANK(SAMPLEBANK_BUILDING_43), - PS2BANK(SAMPLEBANK_BUILDING_44), - PS2BANK(SAMPLEBANK_BUILDING_45), - PS2BANK(SAMPLEBANK_BUILDING_46), - PS2BANK(SAMPLEBANK_BUILDING_47), - - PS2BANK(SAMPLEBANK_EXTRAS), - - SAMPLEBANK_PED, - MAX_SAMPLEBANKS, - SAMPLEBANK_INVALID + // plane + SFX_BANK_PLANE_SEAPLANE, + SFX_BANK_PLANE_UNUSED_1, + SFX_BANK_PLANE_UNUSED_2, + SFX_BANK_PLANE_UNUSED_3, + SFX_BANK_PLANE_UNUSED_4, + PS2BANK(SFX_BANK_BUILDING_BANK_ALARM), + PS2BANK(SFX_BANK_BUILDING_SNORING), + PS2BANK(SFX_BANK_BUILDING_BAR_1), + PS2BANK(SFX_BANK_BUILDING_BAR_2), + PS2BANK(SFX_BANK_BUILDING_BAR_3), + PS2BANK(SFX_BANK_BUILDING_BAR_4), + PS2BANK(SFX_BANK_BUILDING_MALIBU_1), + PS2BANK(SFX_BANK_BUILDING_MALIBU_2), + PS2BANK(SFX_BANK_BUILDING_MALIBU_3), + PS2BANK(SFX_BANK_BUILDING_STRIP_1), + PS2BANK(SFX_BANK_BUILDING_STRIP_2), + PS2BANK(SFX_BANK_BUILDING_STRIP_3), + PS2BANK(SFX_BANK_BUILDING_CHURCH), + PS2BANK(SFX_BANK_BUILDING_FAN_1), + PS2BANK(SFX_BANK_BUILDING_FAN_2), + PS2BANK(SFX_BANK_BUILDING_INSECT_1), + PS2BANK(SFX_BANK_BUILDING_INSECT_2), + PS2BANK(SFX_BANK_BUILDING_18), + PS2BANK(SFX_BANK_BUILDING_19), + PS2BANK(SFX_BANK_BUILDING_20), + PS2BANK(SFX_BANK_BUILDING_21), + PS2BANK(SFX_BANK_FOOTSTEPS_GRASS), + PS2BANK(SFX_BANK_FOOTSTEPS_GRAVEL), + PS2BANK(SFX_BANK_FOOTSTEPS_WOOD), + PS2BANK(SFX_BANK_FOOTSTEPS_METAL), + PS2BANK(SFX_BANK_FOOTSTEPS_WATER), + PS2BANK(SFX_BANK_FOOTSTEPS_SAND), +#ifdef GTA_PS2 + MAX_SFX_BANKS, + INVALID_SFX_BANK +#endif }; - #define MAX_PEDSFX 7 #define PED_BLOCKSIZE 79000 @@ -226,7 +242,7 @@ public: }; extern cSampleManager SampleManager; -extern uint32 BankStartOffset[MAX_SAMPLEBANKS]; +extern uint32 BankStartOffset[MAX_SFX_BANKS]; #ifdef AUDIO_OPUS static char StreamedNameTable[][25] = { diff --git a/src/audio/sampman_miles.cpp b/src/audio/sampman_miles.cpp index 537c3aef..6a7850d8 100644 --- a/src/audio/sampman_miles.cpp +++ b/src/audio/sampman_miles.cpp @@ -21,7 +21,7 @@ #pragma comment( lib, "mss32.lib" ) cSampleManager SampleManager; -uint32 BankStartOffset[MAX_SAMPLEBANKS]; +uint32 BankStartOffset[MAX_SFX_BANKS]; /////////////////////////////////////////////////////////////// char SampleBankDescFilename[] = "AUDIO\\SFX.SDT"; @@ -29,10 +29,10 @@ char SampleBankDataFilename[] = "AUDIO\\SFX.RAW"; FILE *fpSampleDescHandle; FILE *fpSampleDataHandle; -bool bSampleBankLoaded [MAX_SAMPLEBANKS]; -int32 nSampleBankDiscStartOffset [MAX_SAMPLEBANKS]; -int32 nSampleBankSize [MAX_SAMPLEBANKS]; -int32 nSampleBankMemoryStartAddress[MAX_SAMPLEBANKS]; +bool bSampleBankLoaded [MAX_SFX_BANKS]; +int32 nSampleBankDiscStartOffset [MAX_SFX_BANKS]; +int32 nSampleBankSize [MAX_SFX_BANKS]; +int32 nSampleBankMemoryStartAddress[MAX_SFX_BANKS]; int32 _nSampleDataEndOffset; int32 nPedSlotSfx [MAX_PEDSFX]; @@ -1007,7 +1007,7 @@ cSampleManager::Initialise(void) _nSampleDataEndOffset = 0; - for ( int32 i = 0; i < MAX_SAMPLEBANKS; i++ ) + for ( int32 i = 0; i < MAX_SFX_BANKS; i++ ) { bSampleBankLoaded[i] = false; nSampleBankDiscStartOffset[i] = 0; @@ -1059,14 +1059,14 @@ cSampleManager::Initialise(void) return false; } - nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN] = (int32)AIL_mem_alloc_lock(nSampleBankSize[SAMPLEBANK_MAIN]); - if ( !nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN] ) + nSampleBankMemoryStartAddress[SFX_BANK_0] = (int32)AIL_mem_alloc_lock(nSampleBankSize[SFX_BANK_0]); + if ( !nSampleBankMemoryStartAddress[SFX_BANK_0] ) { Terminate(); return false; } - nSampleBankMemoryStartAddress[SAMPLEBANK_PED] = (int32)AIL_mem_alloc_lock(PED_BLOCKSIZE*MAX_PEDSFX); + nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = (int32)AIL_mem_alloc_lock(PED_BLOCKSIZE*MAX_PEDSFX); } @@ -1287,7 +1287,7 @@ cSampleManager::Initialise(void) TRACE("bank"); - LoadSampleBank(SAMPLEBANK_MAIN); + LoadSampleBank(SFX_BANK_0); // mp3 TRACE("mp3"); @@ -1382,16 +1382,16 @@ cSampleManager::Terminate(void) _DeleteMP3Entries(); - if ( nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN] != 0 ) + if ( nSampleBankMemoryStartAddress[SFX_BANK_0] != 0 ) { - AIL_mem_free_lock((void *)nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN]); - nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN] = 0; + AIL_mem_free_lock((void *)nSampleBankMemoryStartAddress[SFX_BANK_0]); + nSampleBankMemoryStartAddress[SFX_BANK_0] = 0; } - if ( nSampleBankMemoryStartAddress[SAMPLEBANK_PED] != 0 ) + if ( nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] != 0 ) { - AIL_mem_free_lock((void *)nSampleBankMemoryStartAddress[SAMPLEBANK_PED]); - nSampleBankMemoryStartAddress[SAMPLEBANK_PED] = 0; + AIL_mem_free_lock((void *)nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS]); + nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = 0; } if ( DIG ) @@ -1546,7 +1546,7 @@ cSampleManager::LoadSampleBank(uint8 nBank) if ( MusicManager.IsInitialised() && MusicManager.GetMusicMode() == MUSICMODE_CUTSCENE - && nBank != SAMPLEBANK_MAIN ) + && nBank != SFX_BANK_0 ) { return false; } @@ -1643,10 +1643,10 @@ cSampleManager::LoadPedComment(uint32 nComment) if ( fseek(fpSampleDataHandle, m_aSamples[nComment].nOffset, SEEK_SET) != 0 ) return false; - if ( fread((void *)(nSampleBankMemoryStartAddress[SAMPLEBANK_PED] + PED_BLOCKSIZE*nCurrentPedSlot), 1, m_aSamples[nComment].nSize, fpSampleDataHandle) != m_aSamples[nComment].nSize ) + if ( fread((void *)(nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BLOCKSIZE*nCurrentPedSlot), 1, m_aSamples[nComment].nSize, fpSampleDataHandle) != m_aSamples[nComment].nSize ) return false; - nPedSlotSfxAddr[nCurrentPedSlot] = nSampleBankMemoryStartAddress[SAMPLEBANK_PED] + PED_BLOCKSIZE*nCurrentPedSlot; + nPedSlotSfxAddr[nCurrentPedSlot] = nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BLOCKSIZE*nCurrentPedSlot; nPedSlotSfx [nCurrentPedSlot] = nComment; if ( ++nCurrentPedSlot >= MAX_PEDSFX ) @@ -1658,13 +1658,13 @@ cSampleManager::LoadPedComment(uint32 nComment) int32 cSampleManager::GetBankContainingSound(uint32 offset) { - if ( offset >= BankStartOffset[SAMPLEBANK_PED] ) - return SAMPLEBANK_PED; + if ( offset >= BankStartOffset[SFX_BANK_PED_COMMENTS] ) + return SFX_BANK_PED_COMMENTS; - if ( offset >= BankStartOffset[SAMPLEBANK_MAIN] ) - return SAMPLEBANK_MAIN; + if ( offset >= BankStartOffset[SFX_BANK_0] ) + return SFX_BANK_0; - return SAMPLEBANK_INVALID; + return INVALID_SFX_BANK; } int32 @@ -2410,7 +2410,7 @@ cSampleManager::IsStreamPlaying(uint8 nStream) bool cSampleManager::InitialiseSampleBanks(void) { - int32 nBank = SAMPLEBANK_MAIN; + int32 nBank = SFX_BANK_0; fpSampleDescHandle = fopen(SampleBankDescFilename, "rb"); if ( fpSampleDescHandle == NULL ) @@ -2437,17 +2437,17 @@ cSampleManager::InitialiseSampleBanks(void) for ( int32 i = 0; i < TOTAL_AUDIO_SAMPLES; i++ ) { #ifdef FIX_BUGS - if (nBank >= MAX_SAMPLEBANKS) break; + if (nBank >= MAX_SFX_BANKS) break; #endif - if ( BankStartOffset[nBank] == BankStartOffset[SAMPLEBANK_MAIN] + i ) + if ( BankStartOffset[nBank] == BankStartOffset[SFX_BANK_0] + i ) { nSampleBankDiscStartOffset[nBank] = m_aSamples[i].nOffset; nBank++; } } - nSampleBankSize[SAMPLEBANK_MAIN] = nSampleBankDiscStartOffset[SAMPLEBANK_PED] - nSampleBankDiscStartOffset[SAMPLEBANK_MAIN]; - nSampleBankSize[SAMPLEBANK_PED] = _nSampleDataEndOffset - nSampleBankDiscStartOffset[SAMPLEBANK_PED]; + nSampleBankSize[SFX_BANK_0] = nSampleBankDiscStartOffset[SFX_BANK_PED_COMMENTS] - nSampleBankDiscStartOffset[SFX_BANK_0]; + nSampleBankSize[SFX_BANK_PED_COMMENTS] = _nSampleDataEndOffset - nSampleBankDiscStartOffset[SFX_BANK_PED_COMMENTS]; return true; } diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index 0b59766f..fe3ae51e 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -619,10 +619,10 @@ cSampleManager::Initialise(void) return false; } - nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN] = (uintptr)malloc(nSampleBankSize[SAMPLEBANK_MAIN]); - ASSERT(nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN] != 0); + nSampleBankMemoryStartAddress[SFX_BANK_0] = (uintptr)malloc(nSampleBankSize[SFX_BANK_0]); + ASSERT(nSampleBankMemoryStartAddress[SFX_BANK_0] != 0); - if ( nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN] == 0 ) + if ( nSampleBankMemoryStartAddress[SFX_BANK_0] == 0 ) { Terminate(); return false; @@ -677,7 +677,7 @@ cSampleManager::Initialise(void) #endif } - LoadSampleBank(SAMPLEBANK_MAIN); + LoadSampleBank(SFX_BANK_0); return true; } @@ -699,10 +699,10 @@ cSampleManager::Terminate(void) CStream::Terminate(); - if ( nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN] != 0 ) + if ( nSampleBankMemoryStartAddress[SFX_BANK_0] != 0 ) { - free((void *)nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN]); - nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN] = 0; + free((void *)nSampleBankMemoryStartAddress[SFX_BANK_0]); + nSampleBankMemoryStartAddress[SFX_BANK_0] = 0; } if ( nSampleBankMemoryStartAddress[SAMPLEBANK_PED] != 0 ) @@ -797,7 +797,7 @@ cSampleManager::LoadSampleBank(uint8 nBank) if ( MusicManager.IsInitialised() && MusicManager.GetMusicMode() == MUSICMODE_CUTSCENE - && nBank != SAMPLEBANK_MAIN ) + && nBank != SFX_BANK_0 ) { return false; } @@ -956,8 +956,8 @@ cSampleManager::GetBankContainingSound(uint32 offset) if ( offset >= BankStartOffset[SAMPLEBANK_PED] ) return SAMPLEBANK_PED; - if ( offset >= BankStartOffset[SAMPLEBANK_MAIN] ) - return SAMPLEBANK_MAIN; + if ( offset >= BankStartOffset[SFX_BANK_0] ) + return SFX_BANK_0; return SAMPLEBANK_INVALID; } @@ -1460,7 +1460,7 @@ cSampleManager::Service(void) bool cSampleManager::InitialiseSampleBanks(void) { - int32 nBank = SAMPLEBANK_MAIN; + int32 nBank = SFX_BANK_0; fpSampleDescHandle = fopen(SampleBankDescFilename, "rb"); if ( fpSampleDescHandle == NULL ) @@ -1494,14 +1494,14 @@ cSampleManager::InitialiseSampleBanks(void) #ifdef FIX_BUGS if (nBank >= MAX_SAMPLEBANKS) break; #endif - if ( BankStartOffset[nBank] == BankStartOffset[SAMPLEBANK_MAIN] + i ) + if ( BankStartOffset[nBank] == BankStartOffset[SFX_BANK_0] + i ) { nSampleBankDiscStartOffset[nBank] = m_aSamples[i].nOffset; nBank++; } } - nSampleBankSize[SAMPLEBANK_MAIN] = nSampleBankDiscStartOffset[SAMPLEBANK_PED] - nSampleBankDiscStartOffset[SAMPLEBANK_MAIN]; + nSampleBankSize[SFX_BANK_0] = nSampleBankDiscStartOffset[SAMPLEBANK_PED] - nSampleBankDiscStartOffset[SFX_BANK_0]; nSampleBankSize[SAMPLEBANK_PED] = _nSampleDataEndOffset - nSampleBankDiscStartOffset[SAMPLEBANK_PED]; return true; From 0f119ed371002922b52d46bba5a23e51b6b2f29a Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Mon, 21 Sep 2020 02:49:35 +0300 Subject: [PATCH 09/10] cleanup processVehicleEngine and some fixes --- src/audio/AudioLogic.cpp | 263 +++++++++------------------------------ src/audio/AudioManager.h | 4 +- 2 files changed, 57 insertions(+), 210 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 10978fb2..40d47e1b 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -736,7 +736,7 @@ void cAudioManager::ProcessVehicle(CVehicle* veh) switch (params.m_VehicleType) { case VEHICLE_TYPE_CAR: automobile = (CAutomobile*)veh; - UpdateGasPedalAudio(&automobile->m_fGasPedalAudio, automobile->m_fGasPedal); + UpdateGasPedalAudio(veh, params.m_VehicleType); if (veh->m_modelIndex == MI_RCBANDIT || veh->m_modelIndex == MI_RCBARON) { ProcessModelCarEngine(¶ms); ProcessEngineDamage(¶ms); @@ -805,7 +805,7 @@ void cAudioManager::ProcessVehicle(CVehicle* veh) break; case VEHICLE_TYPE_BIKE: bike = (CBike*)veh; - UpdateGasPedalAudio(&bike->m_fGasPedalAudio, bike->m_fGasPedal); + UpdateGasPedalAudio(veh, params.m_VehicleType); if (ProcessVehicleRoadNoise(¶ms)) { if (CWeather::WetRoads > 0.0f) ProcessWetRoadNoise(¶ms); @@ -1075,35 +1075,32 @@ cAudioManager::ProcessWetRoadNoise(cVehicleParams *params) } void -cAudioManager::ProcessVehicleEngine1(cVehicleParams* params) +cAudioManager::ProcessVehicleEngine(cVehicleParams* params) { const float SOUND_INTENSITY = 50.0f; CVehicle* playerVeh; CVehicle* veh; CAutomobile* automobile; - float relativeGearChange; - float relativeChange; - uint8 volume; - int32 freq = 0; - uint8 emittingVol; cTransmission* transmission; - uint8 currentGear; - float modificator; - float traction = 0.f; - - bool bPizzaFaggio; - bool bCaddy; CBike* bike; - int8 wheelsOnGround; - int8 wheelsOnGroundPrev; tWheelState* wheelState; float* gasPedalAudioPtr; - float someValue; + int32 freq = 0; + uint8 currentGear; + uint8 emittingVol; + int8 wheelsOnGround; + int8 wheelsOnGroundPrev; + float relativeGearChange; + float relativeChange; + float modificator; + float traction; + bool pizzaFaggBool; + bool caddyBool; - bPizzaFaggio = false; - bCaddy = false; + pizzaFaggBool = false; + caddyBool = false; traction = 0.0f; if (params->m_fDistance >= SQR(SOUND_INTENSITY)) return; @@ -1125,12 +1122,12 @@ cAudioManager::ProcessVehicleEngine1(cVehicleParams* params) switch (veh->m_modelIndex) { case MI_PIZZABOY: case MI_FAGGIO: - bPizzaFaggio = true; + pizzaFaggBool = true; currentGear = transmission->nNumberOfGears; break; case MI_CADDY: currentGear = transmission->nNumberOfGears; - bCaddy = true; + caddyBool = true; break; default: currentGear = veh->m_nCurrentGear; @@ -1157,8 +1154,8 @@ cAudioManager::ProcessVehicleEngine1(cVehicleParams* params) } if (wheelsOnGround != 0) { - if (!veh->bIsHandbrakeOn || bPizzaFaggio && bCaddy) { //mb bug, bcs it's can't be true together - if (veh->GetStatus() == STATUS_SIMPLE || bPizzaFaggio || bCaddy) { + if (!veh->bIsHandbrakeOn || pizzaFaggBool && caddyBool) { //mb bug, bcs it's can't be true together + if (veh->GetStatus() == STATUS_SIMPLE || pizzaFaggBool || caddyBool) { traction = 0.0f; } else { switch (transmission->nDriveType) { @@ -1199,46 +1196,43 @@ cAudioManager::ProcessVehicleEngine1(cVehicleParams* params) break; } } - } else if (0.0f != params->m_fVelocityChange) { + } else if (0.0f == params->m_fVelocityChange) { traction = 0.9f; } if (transmission->fMaxVelocity <= 0.0) { relativeChange = 0.0f; - //var = 0.0f; - //goto lab86; - } - - //201-243 - if (!bPizzaFaggio && !bCaddy) { - if (currentGear != 0) { - relativeGearChange = Min(1.0f, - params->m_fVelocityChange - transmission->Gears[currentGear].fShiftDownVelocity) / transmission->fMaxVelocity * 2.5f; - if (traction != 0.0f && veh->GetStatus() != STATUS_SIMPLE && params->m_fVelocityChange >= transmission->Gears[1].fShiftUpVelocity) - traction = 0.7f; - relativeChange = traction * *gasPedalAudioPtr * 0.95f + (1.0f - traction) * relativeGearChange; + modificator = 0.0f; + } else { + if (!pizzaFaggBool && !caddyBool) { + if (currentGear != 0) { + relativeGearChange = Min(1.0f, + params->m_fVelocityChange - transmission->Gears[currentGear].fShiftDownVelocity) / transmission->fMaxVelocity * 2.5f; + if (traction == 0.0f && veh->GetStatus() != STATUS_SIMPLE && + params->m_fVelocityChange < transmission->Gears[1].fShiftUpVelocity) + traction = 0.7f; + relativeChange = traction * *gasPedalAudioPtr * 0.95f + (1.0f - traction) * relativeGearChange; + } else { + relativeChange = Min(1.0f, + 1.0f - Abs((params->m_fVelocityChange - transmission->Gears[0].fShiftDownVelocity) / transmission->fMaxReverseVelocity)); + } + modificator = relativeChange; } else { - relativeChange = Min(1.0f, - 1.0f - Abs((params->m_fVelocityChange - transmission->Gears[0].fShiftDownVelocity) / transmission->fMaxReverseVelocity)); + modificator = Min(1.0, Abs(params->m_fVelocityChange / transmission->fMaxVelocity > 1.0f)); } - //goto lab85 } - - //244-254 - modificator = Min(1.0, Abs(params->m_fVelocityChange / transmission->fMaxVelocity > 1.0f)); } else { if (wheelsOnGroundPrev != 0) *gasPedalAudioPtr *= 0.4f; relativeChange = *gasPedalAudioPtr; modificator = relativeChange; } - //256-272 if (currentGear != 0 || wheelsOnGround == 0) freq = 1200 * currentGear + 18000.0f * modificator + 14000; else if (params->m_VehicleType == VEHICLE_TYPE_BIKE) freq = 22050; else freq = 13000.0f * modificator + 14000; - if (modificator < 0.75f) + if (modificator >= 0.75f) emittingVol = 90; else emittingVol = modificator * (4.0f / 3.0f) * 15.0f + 75; @@ -1246,19 +1240,18 @@ cAudioManager::ProcessVehicleEngine1(cVehicleParams* params) modificator = 0.0f; emittingVol = 75; } - //273- if (veh->bIsDrowning) emittingVol /= 4; - if (bCaddy) { + if (caddyBool) { emittingVol = 100.0f * modificator; freq = 2130.0f * modificator + 4270; m_sQueueSample.m_nCounter = 2; } m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { - if (!bCaddy) { + if (!caddyBool) { if (veh->GetStatus() == STATUS_SIMPLE) { - if (modificator >= 0.02f) { + if (modificator < 0.02f) { m_sQueueSample.m_nSampleIndex = aVehicleSettings[params->m_nIndex].m_nBank - CAR_SFX_BANKS_OFFSET + SFX_CAR_IDLE_1; m_sQueueSample.m_nCounter = 52; freq = 10000.0f * modificator + 22050; @@ -1267,7 +1260,7 @@ cAudioManager::ProcessVehicleEngine1(cVehicleParams* params) m_sQueueSample.m_nCounter = 2; } } else { - if (veh->m_fGasPedal >= 0.02f) { + if (veh->m_fGasPedal < 0.02f) { m_sQueueSample.m_nSampleIndex = aVehicleSettings[params->m_nIndex].m_nBank - CAR_SFX_BANKS_OFFSET + SFX_CAR_IDLE_1; m_sQueueSample.m_nCounter = 52; freq = 10000.0f * modificator + 22050; @@ -1301,171 +1294,27 @@ cAudioManager::ProcessVehicleEngine1(cVehicleParams* params) m_sQueueSample.m_bRequireReflection = false; AddSampleToRequestedQueue(); } - - } void -cAudioManager::ProcessVehicleEngine(cVehicleParams *params) +cAudioManager::UpdateGasPedalAudio(CVehicle* veh, eVehicleType vehType) { - const float SOUND_INTENSITY = 50.0f; + float gasPedal = Abs(veh->m_fGasPedal); + float* gasPealAudioPtr; - CVehicle *playerVeh; - CVehicle *veh; - CAutomobile *automobile; - float relativeGearChange; - float relativeChange; - uint8 volume; - int32 freq = 0; - uint8 emittingVol; - cTransmission *transmission; - uint8 currentGear; - float modificator; - float traction = 0.f; - - if (params->m_fDistance < SQR(SOUND_INTENSITY)) { - playerVeh = FindPlayerVehicle(); - veh = params->m_pVehicle; - if (playerVeh == veh && veh->GetStatus() == STATUS_WRECKED) { - SampleManager.StopChannel(m_nActiveSamples); - return; - } - if (!params->m_bDistanceCalculated) { - if (params->m_fDistance <= 0.0f) - m_sQueueSample.m_fDistance = 0.0f; - else - m_sQueueSample.m_fDistance = Sqrt(params->m_fDistance); - } - - if (veh->bEngineOn) { - CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); - automobile = (CAutomobile *)params->m_pVehicle; - if (params->m_nIndex == DODO) { - ProcessCesna(params); - return; - } - if (FindPlayerVehicle() == veh) { - ProcessPlayersVehicleEngine(params, params->m_pVehicle); - return; - } - transmission = params->m_pTransmission; - if (transmission != nil) { - currentGear = params->m_pVehicle->m_nCurrentGear; - if (automobile->m_nWheelsOnGround != 0) { - if (automobile->bIsHandbrakeOn) { - if (params->m_fVelocityChange == 0.0f) - traction = 0.9f; - } else if (params->m_pVehicle->GetStatus() == STATUS_SIMPLE) { - traction = 0.0f; - } else { - switch (transmission->nDriveType) { - case '4': - for (int32 i = 0; i < ARRAY_SIZE(automobile->m_aWheelState); i++) { - if (automobile->m_aWheelState[i] == WHEEL_STATE_SPINNING) - traction += 0.05f; - } - break; - case 'F': - if (automobile->m_aWheelState[CARWHEEL_FRONT_LEFT] == WHEEL_STATE_SPINNING) - traction += 0.1f; - if (automobile->m_aWheelState[CARWHEEL_FRONT_RIGHT] == WHEEL_STATE_SPINNING) - traction += 0.1f; - break; - case 'R': - if (automobile->m_aWheelState[CARWHEEL_REAR_LEFT] == WHEEL_STATE_SPINNING) - traction += 0.1f; - if (automobile->m_aWheelState[CARWHEEL_REAR_RIGHT] == WHEEL_STATE_SPINNING) - traction += 0.1f; - break; - } - } - if (transmission->fMaxVelocity <= 0.f) { - relativeChange = 0.f; - } else if (currentGear != 0) { - relativeGearChange = - Min(1.0f, (params->m_fVelocityChange - transmission->Gears[currentGear].fShiftDownVelocity) / transmission->fMaxVelocity * 2.5f); - if (traction == 0.0f && automobile->GetStatus() != STATUS_SIMPLE && - params->m_fVelocityChange < transmission->Gears[1].fShiftUpVelocity) { - traction = 0.7f; - } - relativeChange = traction * automobile->m_fGasPedalAudio * 0.95f + (1.0f - traction) * relativeGearChange; - } else - relativeChange = - Min(1.0f, 1.0f - Abs((params->m_fVelocityChange - transmission->Gears[0].fShiftDownVelocity) / transmission->fMaxReverseVelocity)); - } else { - if (automobile->m_nDriveWheelsOnGround != 0) - automobile->m_fGasPedalAudio *= 0.4f; - relativeChange = automobile->m_fGasPedalAudio; - } - modificator = relativeChange; - if (currentGear != 0 || automobile->m_nWheelsOnGround == 0) - freq = 1200 * currentGear + 18000.f * modificator + 14000; - else - freq = 13000.f * modificator + 14000; - if (modificator >= 0.75f) { - emittingVol = 120; - volume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance); - } else { - emittingVol = modificator * 4.0f / 3.0f * 40.f + 80.f; - volume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance); - } - } else { - modificator = 0.f; - emittingVol = 80; - volume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance); - } - m_sQueueSample.m_nVolume = volume; - if (m_sQueueSample.m_nVolume != 0) { - if (automobile->GetStatus() == STATUS_SIMPLE) { - if (modificator < 0.02f) { - m_sQueueSample.m_nSampleIndex = aVehicleSettings[params->m_nIndex].m_nBank - CAR_SFX_BANKS_OFFSET + SFX_CAR_IDLE_1; - freq = modificator * 10000 + 22050; - m_sQueueSample.m_nCounter = 52; - } else { - m_sQueueSample.m_nSampleIndex = aVehicleSettings[params->m_nIndex].m_nAccelerationSampleIndex; - m_sQueueSample.m_nCounter = 2; - } - } else { - if (automobile->m_fGasPedal < 0.05f) { - m_sQueueSample.m_nSampleIndex = aVehicleSettings[params->m_nIndex].m_nBank - CAR_SFX_BANKS_OFFSET + SFX_CAR_IDLE_1; - freq = modificator * 10000 + 22050; - m_sQueueSample.m_nCounter = 52; - } else { - m_sQueueSample.m_nSampleIndex = aVehicleSettings[params->m_nIndex].m_nAccelerationSampleIndex; - m_sQueueSample.m_nCounter = 2; - } - } - m_sQueueSample.m_nBankIndex = SFX_BANK_0; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nFrequency = freq + 100 * m_sQueueSample.m_nEntityIndex % 1000; - if (m_sQueueSample.m_nSampleIndex == SFX_CAR_IDLE_6 || m_sQueueSample.m_nSampleIndex == SFX_CAR_REV_6) - m_sQueueSample.m_nFrequency /= 2; - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nEmittingVolume = emittingVol; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_fSpeedMultiplier = 6.0f; - m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; - m_sQueueSample.m_bReleasingSoundFlag = false; - m_sQueueSample.m_nReleasingVolumeDivider = 8; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; - AddSampleToRequestedQueue(); - } - } + switch (vehType) { + case VEHICLE_TYPE_CAR: + gasPealAudioPtr = &((CAutomobile*)veh)->m_fGasPedalAudio; + case VEHICLE_TYPE_BIKE: + gasPealAudioPtr = &((CBike*)veh)->m_fGasPedalAudio; + default: + return; + break; } -} - -void -cAudioManager::UpdateGasPedalAudio(float* gasPedalAudio, float vehGasPedal) -{ - float gasPedal = Abs(vehGasPedal); - - if (*gasPedalAudio < gasPedal) - *gasPedalAudio = Min(*gasPedalAudio + 0.09f, gasPedal); + if (*gasPealAudioPtr < gasPedal) + *gasPealAudioPtr = Min(*gasPealAudioPtr + 0.09f, gasPedal); else - *gasPedalAudio = Max(*gasPedalAudio - 0.07f, gasPedal); + *gasPealAudioPtr = Max(*gasPealAudioPtr - 0.07f, gasPedal); } void diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index 20b9006a..4a32e9db 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -360,7 +360,7 @@ public: void ProcessVehicle(CVehicle *vehicle); bool ProcessVehicleDoors(cVehicleParams *params); void ProcessVehicleEngine(cVehicleParams *params); - void UpdateGasPedalAudio(float* gasPedalAudio, float vehGasPedal); + void UpdateGasPedalAudio(CVehicle* veh, eVehicleType vehType); void ProcessVehicleHorn(cVehicleParams *params); void ProcessVehicleOneShots(cVehicleParams *params); bool ProcessVehicleReverseWarning(cVehicleParams *params); @@ -371,8 +371,6 @@ public: void ProcessWeather(int32 id); bool ProcessWetRoadNoise(cVehicleParams *params); - void ProcessVehicleEngine1(cVehicleParams* params); - int32 RandomDisplacement(uint32 seed) const; void ReacquireDigitalHandle() const; void ReleaseDigitalHandle() const; From 579d96534dfcd9206c659b582740bcadda3469a3 Mon Sep 17 00:00:00 2001 From: Roman Masanin <36927roma@gmail.com> Date: Mon, 21 Sep 2020 03:21:17 +0300 Subject: [PATCH 10/10] fix enum edditing effects for oal target and small improvements --- src/audio/AudioLogic.cpp | 9 ++++---- src/audio/AudioManager.h | 2 +- src/audio/sampman_oal.cpp | 44 +++++++++++++++++++-------------------- 3 files changed, 28 insertions(+), 27 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 40d47e1b..e76bb99d 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -290,10 +290,11 @@ void cAudioManager::CalculateDistance(bool &distCalculated, float dist) { if (!distCalculated) { - if (dist <= 0.0) - m_sQueueSample.m_fDistance = 0.0; - else + if (dist > 0.0f) m_sQueueSample.m_fDistance = Sqrt(dist); + + else + m_sQueueSample.m_fDistance = 0.0f; distCalculated = true; } } @@ -1297,7 +1298,7 @@ cAudioManager::ProcessVehicleEngine(cVehicleParams* params) } void -cAudioManager::UpdateGasPedalAudio(CVehicle* veh, eVehicleType vehType) +cAudioManager::UpdateGasPedalAudio(CVehicle* veh, int vehType) { float gasPedal = Abs(veh->m_fGasPedal); float* gasPealAudioPtr; diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index 4a32e9db..a93aa6f7 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -360,7 +360,7 @@ public: void ProcessVehicle(CVehicle *vehicle); bool ProcessVehicleDoors(cVehicleParams *params); void ProcessVehicleEngine(cVehicleParams *params); - void UpdateGasPedalAudio(CVehicle* veh, eVehicleType vehType); + void UpdateGasPedalAudio(CVehicle* veh, int vehType); void ProcessVehicleHorn(cVehicleParams *params); void ProcessVehicleOneShots(cVehicleParams *params); bool ProcessVehicleReverseWarning(cVehicleParams *params); diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index fe3ae51e..94e653b1 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -43,7 +43,7 @@ cSampleManager SampleManager; bool _bSampmanInitialised = false; -uint32 BankStartOffset[MAX_SAMPLEBANKS]; +uint32 BankStartOffset[MAX_SFX_BANKS]; int prevprovider=-1; int curprovider=-1; @@ -77,10 +77,10 @@ OggOpusFile *fpSampleDataHandle; #else FILE *fpSampleDataHandle; #endif -bool bSampleBankLoaded [MAX_SAMPLEBANKS]; -int32 nSampleBankDiscStartOffset [MAX_SAMPLEBANKS]; -int32 nSampleBankSize [MAX_SAMPLEBANKS]; -uintptr nSampleBankMemoryStartAddress[MAX_SAMPLEBANKS]; +bool bSampleBankLoaded [MAX_SFX_BANKS]; +int32 nSampleBankDiscStartOffset [MAX_SFX_BANKS]; +int32 nSampleBankSize [MAX_SFX_BANKS]; +uintptr nSampleBankMemoryStartAddress[MAX_SFX_BANKS]; int32 _nSampleDataEndOffset; int32 nPedSlotSfx [MAX_PEDSFX]; @@ -574,7 +574,7 @@ cSampleManager::Initialise(void) fpSampleDescHandle = NULL; fpSampleDataHandle = NULL; - for ( int32 i = 0; i < MAX_SAMPLEBANKS; i++ ) + for ( int32 i = 0; i < MAX_SFX_BANKS; i++ ) { bSampleBankLoaded[i] = false; nSampleBankDiscStartOffset[i] = 0; @@ -628,8 +628,8 @@ cSampleManager::Initialise(void) return false; } - nSampleBankMemoryStartAddress[SAMPLEBANK_PED] = (uintptr)malloc(PED_BLOCKSIZE*MAX_PEDSFX); - ASSERT(nSampleBankMemoryStartAddress[SAMPLEBANK_PED] != 0); + nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = (uintptr)malloc(PED_BLOCKSIZE*MAX_PEDSFX); + ASSERT(nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] != 0); } @@ -705,10 +705,10 @@ cSampleManager::Terminate(void) nSampleBankMemoryStartAddress[SFX_BANK_0] = 0; } - if ( nSampleBankMemoryStartAddress[SAMPLEBANK_PED] != 0 ) + if ( nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] != 0 ) { - free((void *)nSampleBankMemoryStartAddress[SAMPLEBANK_PED]); - nSampleBankMemoryStartAddress[SAMPLEBANK_PED] = 0; + free((void *)nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS]); + nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = 0; } _bSampmanInitialised = false; @@ -790,7 +790,7 @@ cSampleManager::SetMonoMode(uint8 nMode) bool cSampleManager::LoadSampleBank(uint8 nBank) { - ASSERT( nBank < MAX_SAMPLEBANKS ); + ASSERT( nBank < MAX_SFX_BANKS); if ( CTimer::GetIsCodePaused() ) return false; @@ -831,7 +831,7 @@ cSampleManager::LoadSampleBank(uint8 nBank) void cSampleManager::UnloadSampleBank(uint8 nBank) { - ASSERT( nBank < MAX_SAMPLEBANKS ); + ASSERT( nBank < MAX_SFX_BANKS); bSampleBankLoaded[nBank] = false; } @@ -839,7 +839,7 @@ cSampleManager::UnloadSampleBank(uint8 nBank) bool cSampleManager::IsSampleBankLoaded(uint8 nBank) { - ASSERT( nBank < MAX_SAMPLEBANKS ); + ASSERT( nBank < MAX_SFX_BANKS); return bSampleBankLoaded[nBank]; } @@ -932,7 +932,7 @@ cSampleManager::LoadPedComment(uint32 nComment) if ( fseek(fpSampleDataHandle, m_aSamples[nComment].nOffset, SEEK_SET) != 0 ) return false; - if ( fread((void *)(nSampleBankMemoryStartAddress[SAMPLEBANK_PED] + PED_BLOCKSIZE*nCurrentPedSlot), 1, m_aSamples[nComment].nSize, fpSampleDataHandle) != m_aSamples[nComment].nSize ) + if ( fread((void *)(nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BLOCKSIZE*nCurrentPedSlot), 1, m_aSamples[nComment].nSize, fpSampleDataHandle) != m_aSamples[nComment].nSize ) return false; #endif @@ -940,7 +940,7 @@ cSampleManager::LoadPedComment(uint32 nComment) alBufferData(pedBuffers[nCurrentPedSlot], AL_FORMAT_MONO16, - (void *)(nSampleBankMemoryStartAddress[SAMPLEBANK_PED] + PED_BLOCKSIZE*nCurrentPedSlot), + (void *)(nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BLOCKSIZE*nCurrentPedSlot), m_aSamples[nComment].nSize, m_aSamples[nComment].nFrequency); @@ -953,13 +953,13 @@ cSampleManager::LoadPedComment(uint32 nComment) int32 cSampleManager::GetBankContainingSound(uint32 offset) { - if ( offset >= BankStartOffset[SAMPLEBANK_PED] ) - return SAMPLEBANK_PED; + if ( offset >= BankStartOffset[SFX_BANK_PED_COMMENTS] ) + return SFX_BANK_PED_COMMENTS; if ( offset >= BankStartOffset[SFX_BANK_0] ) return SFX_BANK_0; - return SAMPLEBANK_INVALID; + return INVALID_SFX_BANK; } int32 @@ -1492,7 +1492,7 @@ cSampleManager::InitialiseSampleBanks(void) for ( int32 i = 0; i < TOTAL_AUDIO_SAMPLES; i++ ) { #ifdef FIX_BUGS - if (nBank >= MAX_SAMPLEBANKS) break; + if (nBank >= MAX_SFX_BANKS) break; #endif if ( BankStartOffset[nBank] == BankStartOffset[SFX_BANK_0] + i ) { @@ -1501,8 +1501,8 @@ cSampleManager::InitialiseSampleBanks(void) } } - nSampleBankSize[SFX_BANK_0] = nSampleBankDiscStartOffset[SAMPLEBANK_PED] - nSampleBankDiscStartOffset[SFX_BANK_0]; - nSampleBankSize[SAMPLEBANK_PED] = _nSampleDataEndOffset - nSampleBankDiscStartOffset[SAMPLEBANK_PED]; + nSampleBankSize[SFX_BANK_0] = nSampleBankDiscStartOffset[SFX_BANK_PED_COMMENTS] - nSampleBankDiscStartOffset[SFX_BANK_0]; + nSampleBankSize[SFX_BANK_PED_COMMENTS] = _nSampleDataEndOffset - nSampleBankDiscStartOffset[SFX_BANK_PED_COMMENTS]; return true; }