Skip to content

Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.

feat(milesaudiodevice): legacy sound option with retail's mix

Olcay Seyganed6968921855
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 20bff9fc1..782409fe1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -42,6 +42,7 @@ found and fixed, EA's own, not port damage.**
## Sound that travels
+- Legacy Sound, under Options, Audio, Output, brings back the original game's sound for anyone who misses it. It turns off everything below: the delay, the air, the pitch bend, the echo, the muffling behind hills, the deafening blasts, the cap on battle sounds and replies, the zoom mix, the map's ambience, the limiter and the music that follows the fight. Master volume, the output device and the speaker setup keep working, and the change is heard the moment you press Accept, in a match too.
- Sound takes time to cross the battlefield now. An explosion at the edge of the screen is heard about a quarter of a second after it is seen, one at the far end of a long view half a second after, at the speed of sound on the scale the units are drawn at. The wait never runs past a second. A sound also ends as late as it started: a missile's roar carries on until its boom arrives, instead of cutting out at the visible impact and leaving a hole seven decibels deep before the boom. Unit replies, the interface, music, speech and every sound a mission script waits on still play the moment they are asked for.
- Distance takes the top off a sound as air does, twelve decibels an octave. Fighting in the middle of the screen keeps its crack, a blast across a long view arrives with its crack gone, mostly thump, and a nuke across the map is low thunder and nothing else. The muffling EA gave sixteen explosions for when they go off out of view used to be only a drop in volume; it is a real muffling now, so those blasts are no quieter off screen than on it, only duller.
- Jets, helicopters and the Nuke Cannon's shell rise in pitch as they come in and drop as they pass, by how fast they move towards you. Units cross the map far slower than the real machines would, and the faster the unit the bigger the gap, so the bend is worked out at three times a tank's speed and more for anything quicker: a Raptor or a MiG is heard at five times its speed and comes in several semitones high on a normal pass, up to an octave dead overhead, and an Aurora screams in a full octave up.
diff --git a/GeneralsMD/Code/Data/Patch.str b/GeneralsMD/Code/Data/Patch.str
index ce7b94396..d1593fd27 100644
--- a/GeneralsMD/Code/Data/Patch.str
+++ b/GeneralsMD/Code/Data/Patch.str
@@ -685,6 +685,14 @@ TOOLTIP:MuteInBackground
"Silences the game while another window has the focus. Off keeps it playing behind a browser or on a second monitor."
END
+GUI:LegacySound
+"Legacy Sound"
+END
+
+TOOLTIP:LegacySound
+"The original game's sound: no echo off the map, no muffling by distance, hills or buildings, no delay or pitch bend on distant and passing sounds, no dip after big blasts, no cap on battle sounds or unit replies, no limiter, no map ambience and no music following the fight. Master volume, the device and the speakers still apply. Takes effect at once."
+END
+
GUI:IsometricCamera
"Isometric Camera"
END
diff --git a/GeneralsMD/Code/Data/Turkish/Generals.str b/GeneralsMD/Code/Data/Turkish/Generals.str
index cc2195e6e..4125e63d0 100644
--- a/GeneralsMD/Code/Data/Turkish/Generals.str
+++ b/GeneralsMD/Code/Data/Turkish/Generals.str
@@ -15169,6 +15169,14 @@ TOOLTIP:MuteInBackground
"Başka bir pencere öndeyken oyunu susturur. Kapalıyken oyun bir tarayıcının arkasında ya da ikinci monitörde de duyulur."
END
+GUI:LegacySound
+"Eski Ses"
+END
+
+TOOLTIP:LegacySound
+"Özgün oyunun sesi: haritada yankı yok, uzaklık, tepe ya da bina boğukluğu yok, uzak ve geçen seslerde gecikme ya da perde kayması yok, büyük patlamalardan sonra kısılma yok, savaş seslerine ve birlik cevaplarına sınır yok, sınırlayıcı yok, harita ambiyansı yok, müzik de çatışmayı izlemez. Ana ses, cihaz ve hoparlörler yine geçerlidir. Hemen etkili olur."
+END
+
GUI:IsometricCamera
"İzometrik Kamera"
END
diff --git a/GeneralsMD/Code/Data/Window/Menus/OptionsMenuClassic.wnd b/GeneralsMD/Code/Data/Window/Menus/OptionsMenuClassic.wnd
index 8af92c1b1..22cf0a08f 100644
--- a/GeneralsMD/Code/Data/Window/Menus/OptionsMenuClassic.wnd
+++ b/GeneralsMD/Code/Data/Window/Menus/OptionsMenuClassic.wnd
@@ -9333,6 +9333,53 @@ WINDOW
IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;
END
+ CHILD
+ WINDOW
+ WINDOWTYPE = CHECKBOX;
+ SCREENRECT = UPPERLEFT: 536 322, BOTTOMRIGHT: 760 346, CREATIONRESOLUTION: 800 600;
+ NAME = "OptionsMenu.wnd:CheckLegacySound";
+ STATUS = ENABLED+IMAGE+BORDER;
+ STYLE = CHECKBOX+MOUSETRACK;
+ SYSTEMCALLBACK = "[None]";
+ INPUTCALLBACK = "[None]";
+ TOOLTIPCALLBACK = "[None]";
+ DRAWCALLBACK = "[None]";
+ FONT = NAME: "Arial", SIZE: 14, BOLD: 0;
+ HEADERTEMPLATE = "MinorTitle";
+ TOOLTIPTEXT = "TOOLTIP:LegacySound";
+ TOOLTIPDELAY = -1;
+ TEXT = "GUI:LegacySound";
+ TEXTCOLOR = ENABLED: 255 255 255 255, ENABLEDBORDER: 0 0 0 255,
+ DISABLED: 192 192 192 255, DISABLEDBORDER: 64 64 64 255,
+ HILITE: 186 255 12 255, HILITEBORDER: 0 0 0 255;
+ ENABLEDDRAWDATA = IMAGE: NoImage, COLOR: 255 0 0 255, BORDERCOLOR: 255 128 128 255,
+ IMAGE: Active-Unchecked, COLOR: 255 255 255 0, BORDERCOLOR: 128 128 255 255,
+ IMAGE: Active-Checked, COLOR: 0 0 255 255, BORDERCOLOR: 128 128 255 255,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;
+ DISABLEDDRAWDATA = IMAGE: NoImage, COLOR: 128 128 128 255, BORDERCOLOR: 192 192 192 255,
+ IMAGE: Disabled-Unchecked, COLOR: 255 255 255 0, BORDERCOLOR: 192 192 192 255,
+ IMAGE: Disabled-Checked, COLOR: 64 64 64 255, BORDERCOLOR: 254 254 254 255,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;
+ HILITEDRAWDATA = IMAGE: NoImage, COLOR: 0 255 0 255, BORDERCOLOR: 128 255 128 255,
+ IMAGE: Active-HiLighted, COLOR: 255 255 255 0, BORDERCOLOR: 128 128 255 255,
+ IMAGE: Active-Checked, COLOR: 255 255 0 255, BORDERCOLOR: 254 254 254 255,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;
+ END
ENDALLCHILDREN
END
CHILD
diff --git a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h
index 87a72104c..62792876b 100644
--- a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h
+++ b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h
@@ -700,6 +700,7 @@ public:
Int m_ambientVolume; ///< "AmbientVolume" in Options.ini: percent for looping world ambience, in place of the effects slider
Int m_masterVolume; ///< "MasterVolume" in Options.ini: percent every other slider is multiplied by, music and speech included
Bool m_dynamicMusic; ///< "DynamicMusic" in Options.ini: a skirmish's music follows the fight (MusicManager::update)
+ Bool m_legacySound; ///< "LegacySound" in Options.ini: retail's mix, none of the v3.4 processing (MilesAudioManager::applyLegacySound)
Bool m_muteInBackground; ///< "MuteInBackground" in Options.ini: silent while another window has the focus (WinMain's WM_ACTIVATE)
Bool m_3DSoundPref; ///< Whether user wants to use 3DSound or not
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/Audio/GameMusic.cpp b/GeneralsMD/Code/GameEngine/Source/Common/Audio/GameMusic.cpp
index 9ae0f52c9..92ffc16a5 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/Audio/GameMusic.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/Audio/GameMusic.cpp
@@ -360,7 +360,7 @@ void MusicManager::startMatch( void )
* main thread outside the tick, where the audio already reads the player and the objects. */
Bool MusicManager::engaged( void ) const
{
- if (!TheGlobalData->m_dynamicMusic || TheGameLogic == NULL || !TheGameLogic->isInGame()
+ if (!TheGlobalData->m_dynamicMusic || TheGlobalData->m_legacySound || TheGameLogic == NULL || !TheGameLogic->isInGame()
|| TheGameLogic->isLoadingMap() || TheGameLogic->isInShellGame()
|| !(TheGameLogic->isInSkirmishGame() || TheGameLogic->isInMultiplayerGame()))
return FALSE;
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp
index e0d872d47..32fe93975 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp
@@ -1452,6 +1452,7 @@ GlobalData::GlobalData()
m_ambientVolume = 40;
m_masterVolume = 100;
m_dynamicMusic = TRUE;
+ m_legacySound = FALSE;
m_muteInBackground = TRUE; // retail's: loseFocus on every deactivation
m_3DSoundPref = false;
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cpp b/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cpp
index 756f3b819..bd71b439c 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cpp
@@ -96,6 +96,7 @@ static void set_m_masterVolume( Int value )
TheAudio->setVolume( value / 100.0f, (AudioAffect)(AudioAffect_Master | AudioAffect_SystemSetting) );
}
OPTION_BOOL_ACCESSORS( m_dynamicMusic )
+OPTION_BOOL_ACCESSORS( m_legacySound )
OPTION_BOOL_ACCESSORS( m_muteInBackground )
// The catalog loads before there is a game; the menu's Accept during a mission changes its speed
// on the spot, which only the pacing reads.
@@ -350,6 +351,14 @@ const OptionDef TheOptionCatalog[] =
OPTION_BOOL, APPLY_LIVE, 0, 1,
get_m_dynamicMusic, set_m_dynamicMusic },
+ // Retail's mix: no sound travel delay, air, doppler, room, occlusion, duck, limiter, battle voice
+ // budget, shot folding, reply limits, zoom mix, ambience bed or music following the fight. The
+ // audio manager takes it up on its next pass (MilesAudioManager::applyLegacySound), the room and
+ // the bed included. Master volume, the device and the speakers stay as they are. On Options > Audio.
+ { "LegacySound", OPT_WND( "CheckLegacySound" ), "GUI:LegacySound",
+ OPTION_BOOL, APPLY_LIVE, 0, 1,
+ get_m_legacySound, set_m_legacySound },
+
// Silent while another window has the focus, as retail always was; off keeps the game heard
// behind a browser or a second monitor's window. Read at the next focus change. On Options > Audio.
{ "MuteInBackground", OPT_WND( "CheckMuteInBackground" ), "GUI:MuteInBackground",
diff --git a/GeneralsMD/Code/GameEngineDevice/Include/MilesAudioDevice/MilesAudioManager.h b/GeneralsMD/Code/GameEngineDevice/Include/MilesAudioDevice/MilesAudioManager.h
index d40669577..9369687e7 100644
--- a/GeneralsMD/Code/GameEngineDevice/Include/MilesAudioDevice/MilesAudioManager.h
+++ b/GeneralsMD/Code/GameEngineDevice/Include/MilesAudioDevice/MilesAudioManager.h
@@ -23,6 +23,7 @@
// Author: John K. McDonald, July 2002
#include "Common/AsciiString.h"
+#include "Common/AudioSettings.h"
#include "Common/GameAudio.h"
#include "MSS/MSS.h"
#include "mutex.h"
@@ -290,6 +291,7 @@ class MilesAudioManager : public AudioManager
void advanceAudioClock( void );
void trackVelocity( PlayingAudio *playing, const Coord3D *pos );
void setRoomFromMap( void );
+ void applyLegacySound( void );
void updateAmbienceBed( void );
void duckForBlast( AudioEventRTS *event, H3DSAMPLE sample3D );
Bool checkForSample( AudioRequest *req );
@@ -381,6 +383,8 @@ class MilesAudioManager : public AudioManager
Real m_clockElapsedMs;
UnsignedInt m_clockMovedAt; ///< Clock_Milliseconds when the logic clock last moved on
AsciiString m_roomMap; ///< the map setRoomFromMap last set the room for
+ Bool m_legacySound; ///< what applyLegacySound last put into m_audioSettings
+ AudioSettings m_engineSettings; ///< AudioSettings.ini as init read it, for Legacy sound turned off again
Bool m_askingOnArrival; ///< checkForSample is asking canPlayNow about a sound that waited out its distance
/// The map's ambience bed (AmbienceBed* in AudioSettings.h): the event setRoomFromMap chose, the
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/MilesAudioDevice/MilesAudioManager.cpp b/GeneralsMD/Code/GameEngineDevice/Source/MilesAudioDevice/MilesAudioManager.cpp
index db7f432c4..d8637d8d6 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/MilesAudioDevice/MilesAudioManager.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/MilesAudioDevice/MilesAudioManager.cpp
@@ -145,6 +145,7 @@ MilesAudioManager::MilesAudioManager() :
m_clockFrame(0),
m_clockElapsedMs(MSEC_PER_LOGICFRAME_REAL),
m_clockMovedAt(0),
+ m_legacySound(FALSE),
m_askingOnArrival(false),
m_bedHandle(AHSV_Error),
m_bedStartedAt(0),
@@ -505,6 +506,7 @@ void MilesAudioManager::audioDebugDisplay(DebugDisplayInterface *dd, void *, FIL
void MilesAudioManager::init()
{
AudioManager::init();
+ m_engineSettings = *m_audioSettings;
#ifdef INTENSE_DEBUG
DEBUG_LOG(("Sound has temporarily been disabled in debug builds only. jkmcd\n"));
// for now, _DEBUG builds only should have no sound. ask jkmcd or srj about this.
@@ -622,6 +624,7 @@ void MilesAudioManager::update()
processCompletedAudio();
updateSoundCapture();
advanceAudioClock();
+ applyLegacySound();
if (TheGameLogic->isInGame() && !TheGameLogic->isLoadingMap() && m_roomMap != TheGlobalData->m_mapName)
{
m_roomMap = TheGlobalData->m_mapName;
@@ -3325,6 +3328,11 @@ void MilesAudioManager::updateOcclusion( PlayingAudio *playing, const Coord3D *p
{
const AudioEventInfo *info = playing->m_audioEventRTS->getAudioEventInfo();
if (m_audioSettings->m_occlusionStrength <= 0.0f || info == NULL || BitTest(info->m_type, ST_VOICE | ST_GLOBAL)) {
+ // occlusion switched off (Legacy sound) under a sound it had muffled
+ if (playing->m_occlusion > 0.0f) {
+ playing->m_occlusion = 0.0f;
+ applyOcclusion(playing);
+ }
return;
}
if (look) {
@@ -3449,6 +3457,56 @@ void MilesAudioManager::buildBlockers( void )
}
}
+//-------------------------------------------------------------------------------------------------
+/** The processing v3.4.0 put between a sound and the speakers, as AudioSettings.ini gives it (`from`)
+ * or, with `from` NULL, each stage at the value its own comment in AudioSettings.h calls none. */
+static void setSoundProcessing( AudioSettings *to, const AudioSettings *from )
+{
+ to->m_speedOfSound = from ? from->m_speedOfSound : 0.0f; // travel delay and doppler
+ to->m_maxSoundDelay = from ? from->m_maxSoundDelay : 0.0f;
+ to->m_dopplerScale = from ? from->m_dopplerScale : 0.0f;
+ to->m_airAbsorptionDistance = from ? from->m_airAbsorptionDistance : 0.0f; // the air's low pass
+ to->m_reverbLevel = from ? from->m_reverbLevel : 0.0f; // the map's room
+ to->m_duckVolume = from ? from->m_duckVolume : 1.0f;
+ to->m_replyUnitCooldown = from ? from->m_replyUnitCooldown : 0.0f;
+ to->m_replyGap = from ? from->m_replyGap : 0.0f;
+ to->m_replyMaxVoices = from ? from->m_replyMaxVoices : 0;
+ to->m_battleVoiceBudget = from ? from->m_battleVoiceBudget : 0;
+ to->m_coalesceRadius = from ? from->m_coalesceRadius : 0.0f; // shot folding
+ to->m_occlusionStrength = from ? from->m_occlusionStrength : 0.0f;
+ to->m_occlusionVolume = from ? from->m_occlusionVolume : 1.0f;
+ to->m_zoomMixDetailVolume = from ? from->m_zoomMixDetailVolume : 1.0f;
+ to->m_ambienceBedSnow = from ? from->m_ambienceBedSnow : AsciiString::TheEmptyString;
+ to->m_ambienceBedTown = from ? from->m_ambienceBedTown : AsciiString::TheEmptyString;
+ to->m_ambienceBedDesert = from ? from->m_ambienceBedDesert : AsciiString::TheEmptyString;
+ to->m_ambienceBedField = from ? from->m_ambienceBedField : AsciiString::TheEmptyString;
+}
+
+//-------------------------------------------------------------------------------------------------
+/** Legacy sound (LegacySound in Options.ini, on Options > Audio): retail's mix, every stage above off
+ * and the backend's limiter with them, and MusicManager::engaged leaving the music to the scripts.
+ * Taken up the pass after the option changes. The room and the bed are set again from the map on
+ * this same pass (setRoomFromMap), the bed playing now stopped; a sound already muffled opens up on
+ * its next position update (updateOcclusion). */
+void MilesAudioManager::applyLegacySound( void )
+{
+ if (m_legacySound == TheGlobalData->m_legacySound)
+ return;
+ m_legacySound = TheGlobalData->m_legacySound;
+ setSoundProcessing( m_audioSettings, m_legacySound ? NULL : &m_engineSettings );
+ AIL_ex_set_limiter( !m_legacySound );
+ AIL_ex_set_3D_air( m_audioSettings->m_speedOfSound, m_audioSettings->m_airAbsorptionDistance );
+ removeAudioEvent( m_bedHandle );
+ m_bedEvent.clear();
+ m_roomMap.clear();
+ DEBUG_LOG(("AUDIO: legacy sound %s: delay %.0f ms, doppler %.1f, air %.0f, room %.2f, duck %.2f, occlusion %.2f, "
+ "budget %d, folding %.0f, replies %d, zoom mix %.2f, limiter %s\n", m_legacySound ? "on" : "off",
+ m_audioSettings->m_maxSoundDelay, m_audioSettings->m_dopplerScale, m_audioSettings->m_airAbsorptionDistance,
+ m_audioSettings->m_reverbLevel, m_audioSettings->m_duckVolume, m_audioSettings->m_occlusionStrength,
+ m_audioSettings->m_battleVoiceBudget, m_audioSettings->m_coalesceRadius, m_audioSettings->m_replyMaxVoices,
+ m_audioSettings->m_zoomMixDetailVolume, m_legacySound ? "off" : "on"));
+}
+
//-------------------------------------------------------------------------------------------------
/** The room the map's world sounds send into (AIL_ex_set_reverb), from the map itself: how much of
* its playable ground the placed structures cover. Supply docks are left out, being on every map at
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/Miles6/include/MSS/MSS.h b/GeneralsMD/Code/Libraries/Source/WWVegas/Miles6/include/MSS/MSS.h
index bf35977bf..f7535a4a0 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/Miles6/include/MSS/MSS.h
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/Miles6/include/MSS/MSS.h
@@ -311,7 +311,8 @@ void AILCALL AIL_ex_set_3D_linear_falloff(S32 linear);
* (mss_ex_pcm.h) is never ducked.
*
* Both backends hold the mix under AIL_EX_LIMITER_CEILING with the same limiter (AIL_ex_limit), so
- * nothing they play or record clips.
+ * nothing they play or record clips. AIL_ex_set_limiter(0) passes the mix through untouched, as
+ * Miles did, for the Legacy sound option; it starts on.
*
* AIL_ex_set_3D_sample_dry: a 3D sample that takes no air, no doppler and no room, only its distance
* gain, pan and occlusion; a unit's reply stays clean. Set on each play; a fresh handle is wet. */
@@ -319,6 +320,7 @@ void AILCALL AIL_ex_set_3D_air(F32 speed_of_sound, F32 absorption_distance)
void AILCALL AIL_ex_set_reverb(F32 wet, F32 decay, F32 damping, F32 echo, F32 slap);
void AILCALL AIL_ex_duck(H3DSAMPLE trigger, F32 gain, F32 seconds);
void AILCALL AIL_ex_set_3D_sample_dry(H3DSAMPLE handle, S32 dry);
+void AILCALL AIL_ex_set_limiter(S32 on);
/* ---- output device ------------------------------------------------------ */
/* Not Miles. AIL_ex_set_output_device: the endpoint to play on, an MMDevice id as IMMDevice::GetId
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/Miles6/include/MSS/mss_backend_names.h b/GeneralsMD/Code/Libraries/Source/WWVegas/Miles6/include/MSS/mss_backend_names.h
index 67bc7468c..e7ee079db 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/Miles6/include/MSS/mss_backend_names.h
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/Miles6/include/MSS/mss_backend_names.h
@@ -87,6 +87,7 @@
#define AIL_ex_set_reverb MSS_BACKEND_NAME(AIL_ex_set_reverb)
#define AIL_ex_duck MSS_BACKEND_NAME(AIL_ex_duck)
#define AIL_ex_set_3D_sample_dry MSS_BACKEND_NAME(AIL_ex_set_3D_sample_dry)
+#define AIL_ex_set_limiter MSS_BACKEND_NAME(AIL_ex_set_limiter)
#define AIL_ex_set_output_device MSS_BACKEND_NAME(AIL_ex_set_output_device)
#define AIL_ex_enumerate_output_devices MSS_BACKEND_NAME(AIL_ex_enumerate_output_devices)
#define AIL_WAV_info MSS_BACKEND_NAME(AIL_WAV_info)
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/Miles6/miles_dispatch.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/Miles6/miles_dispatch.cpp
index b93d87f5f..9f540f8e1 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/Miles6/miles_dispatch.cpp
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/Miles6/miles_dispatch.cpp
@@ -87,6 +87,7 @@
MSS_API(void, AIL_ex_set_reverb, (F32 wet, F32 decay, F32 damping, F32 echo, F32 slap), (wet, decay, damping, echo, slap)) \
MSS_API(void, AIL_ex_duck, (H3DSAMPLE trigger, F32 gain, F32 seconds), (trigger, gain, seconds)) \
MSS_API(void, AIL_ex_set_3D_sample_dry, (H3DSAMPLE handle, S32 dry), (handle, dry)) \
+ MSS_API(void, AIL_ex_set_limiter, (S32 on), (on)) \
MSS_API(S32, AIL_WAV_info, (const void *data, AILSOUNDINFO *info), (data, info)) \
MSS_API(S32, AIL_decompress_ADPCM, (const AILSOUNDINFO *info, void **outdata, U32 *outsize), (info, outdata, outsize)) \
MSS_API(void, AIL_mem_free_lock, (void *ptr), (ptr))
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/Miles6/miniaudio/miles_miniaudio.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/Miles6/miniaudio/miles_miniaudio.cpp
index 6e4f9b197..f08e73292 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/Miles6/miniaudio/miles_miniaudio.cpp
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/Miles6/miniaudio/miles_miniaudio.cpp
@@ -625,6 +625,7 @@ std::atomic<S32> g_linearFalloff(0); // AIL_ex_set_3D_linear_falloff
std::atomic<float> g_speedOfSound(0.0f); // AIL_ex_set_3D_air
std::atomic<float> g_absorptionDistance(0.0f);
std::atomic<float> g_roomSend(0.0f); // AIL_ex_set_reverb's wet
+std::atomic<bool> g_limiter(true); // AIL_ex_set_limiter
// AIL_set_3D_speaker_type's AIL_3D_HEADPHONE, under the engine lock. Every other type is the stereo
// pan here: this backend's device is two channels (OUTPUT_CHANNELS), surround is miles_xaudio2's.
bool g_headphones = false;
@@ -1232,7 +1233,9 @@ void dataCallback(ma_device *, void *output, const void *, ma_uint32 frameCount)
if (g_engine.room.ready) {
processRoom(&g_engine.room, room, out, frameCount);
}
- AIL_ex_limit(&g_engine.limiter, out, (S32)frameCount);
+ if (g_limiter.load()) {
+ AIL_ex_limit(&g_engine.limiter, out, (S32)frameCount);
+ }
if (g_engine.capture != NULL) {
writeCapture(g_engine.capture, out, frameCount);
@@ -1962,6 +1965,11 @@ void AILCALL AIL_ex_set_3D_air(F32 speed_of_sound, F32 absorption_distance)
g_absorptionDistance.store(absorption_distance);
}
+void AILCALL AIL_ex_set_limiter(S32 on)
+{
+ g_limiter.store(on != 0);
+}
+
void AILCALL AIL_ex_set_reverb(F32 wet, F32 decay, F32 damping, F32 echo, F32 slap)
{
g_roomSend.store(wet);
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/Miles6/xaudio2/miles_xaudio2.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/Miles6/xaudio2/miles_xaudio2.cpp
index 4e1e57eaf..3bfdb8caf 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/Miles6/xaudio2/miles_xaudio2.cpp
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/Miles6/xaudio2/miles_xaudio2.cpp
@@ -571,6 +571,7 @@ S32 g_linearFalloff; // AIL_ex_set_3D_linear_falloff
std::atomic<float> g_speedOfSound(0.0f); // AIL_ex_set_3D_air
std::atomic<float> g_absorptionDistance(0.0f);
std::atomic<float> g_roomSend(0.0f); // AIL_ex_set_reverb's wet
+std::atomic<bool> g_limiter(true); // AIL_ex_set_limiter, read by MasterTap on XAudio2's thread
// The rest of AIL_ex_set_reverb, under the lock, for a room made again with the output.
struct RoomSettings
@@ -1347,7 +1348,9 @@ public:
if (input[0].BufferFlags == XAPO_BUFFER_SILENT) {
memset(mix, 0, samples * sizeof(float));
}
- AIL_ex_limit(&m_limiter, mix, (S32)input[0].ValidFrameCount);
+ if (g_limiter.load()) {
+ AIL_ex_limit(&m_limiter, mix, (S32)input[0].ValidFrameCount);
+ }
if (output != NULL) {
output[0].ValidFrameCount = input[0].ValidFrameCount;
output[0].BufferFlags = XAPO_BUFFER_VALID;
@@ -2254,6 +2257,12 @@ void AILCALL AIL_ex_set_3D_air(F32 speed_of_sound, F32 absorption_distance)
g_absorptionDistance.store(absorption_distance);
}
+void AILCALL AIL_ex_set_limiter(S32 on)
+{
+ // No lock, as AIL_ex_set_3D_linear_falloff; the master's next pass takes it up
+ g_limiter.store(on != 0);
+}
+
void AILCALL AIL_ex_set_reverb(F32 wet, F32 decay, F32 damping, F32 echo, F32 slap)
{
g_roomSend.store(wet);
diff --git a/GeneralsMD/Code/Tools/optionsmenu_layout.py b/GeneralsMD/Code/Tools/optionsmenu_layout.py
index 30ad1dde3..778daaf5f 100644
--- a/GeneralsMD/Code/Tools/optionsmenu_layout.py
+++ b/GeneralsMD/Code/Tools/optionsmenu_layout.py
@@ -216,6 +216,7 @@ NEW_CONTROLS = [
(LABEL, "LabelSpeakerType", "GUI:SpeakerType"),
(COMBO, "ComboBoxSpeakerType", None),
(CHECK, "CheckMuteInBackground", "GUI:MuteInBackground"),
+ (CHECK, "CheckLegacySound", "GUI:LegacySound"),
(LABEL, "LabelZoomSpeed", "GUI:ZoomSpeed"),
(SLIDER, "SliderZoomSpeed", None),
(LABEL, "LabelShadowQuality", "GUI:ShadowQuality"),
@@ -397,7 +398,8 @@ GROUP_LAYOUT = [
("GUI:OptionsGroupOutput", [
setting("LabelAudioDevice", "ComboBoxAudioDevice"),
setting("LabelSpeakerType", "ComboBoxSpeakerType"),
- ("check", "CheckMuteInBackground")])]),
+ ("check", "CheckMuteInBackground"),
+ ("check", "CheckLegacySound")])]),
("PageControls", [
("GUI:OptionsGroupCamera", [