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): drop the tunnel, Aurora passes with EA's boom

Olcay Seygan60069824716e
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 933c6f1c1..9a0ee50ee 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -58,21 +58,16 @@ found and fixed, EA's own, not port damage.**
- Music Follows the Fight is on by default and sits under Music Volume on the Audio page. Off, the music plays as the original game had it.
- A Master Volume slider heads the Audio page and turns the whole game down at once: music, effects, voices, ambience and movies. At half it put the music exactly 6.0 decibels lower. Unit replies keep their lift over the battle and are turned down with everything else, and at full volume the loudest moment of a tank fight still stops at the limiter's ceiling.
-## Sound that travels
+## Sound in the open air
-- 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.
+- The tunnel is gone. A player told us the game sounded like standing in a tunnel, and had it right: every map carried an echo up to 2.6 seconds long with a slap off the buildings, and a far sound was mostly that echo. Distance dulled it on top of that, a hill in the way muffled it again, and each one reached you late, by up to a second, while a big blast sank the rest of the battle to a sixth of its volume for four seconds. All of it is out of the game. A gun across the map now loses level with distance and keeps its crack, and when a sound stops, nothing is left ringing after it.
+- Legacy Sound, under Options, Audio, Output, brings back the original game's sound for anyone who misses it. It turns off everything below: the pitch bend, the Aurora's boom, 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.
- 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.
-- Every map has an echo of its own, worked out from how much of it is built over. A city rings for nearly two seconds with a slap straight back off the buildings. Open desert answers a quarter of a second late from the hills, a distinct second crack and then a long, thin, dark tail. Snow kills it: a short dead tail, no echo, and air that takes the top end off a sound sooner. Far sounds carry more of the room than near ones. Unit replies take none of this, no muffling, no pitch bend and no echo: a tank answering from across the map sounds like a radio in your ear, as it always has.
-- A nuke, a Particle Cannon sweep, a Daisy Cutter, a MOAB or a Nuke Cannon shell that lands within earshot leaves you half deaf. The rest of the battle drops to a sixth of its volume and is muffled down to a few hundred hertz for a second, then comes back over three more, all of it by how close the blast was.
-- Nothing clips any more. A dense tank fight in a city used to drive one sample in twenty past full scale, and the city's echo made it worse; a limiter at the end of the mix now looks two milliseconds ahead and turns the whole mix down just enough, so the loudest moment is as loud as the speakers go and no louder.
-- On Windows the echo was nearly lost. Windows played it through its own built-in reverb, which answered a shell 12 decibels quieter than intended on open ground, 20 in a city and 31 in snow, with its top end gone. A sound card set to 96 kHz got no echo at all. Windows now plays the very echo macOS, Linux and the recorded videos do, sample for sample.
-- A hill or a big building between you and a fight muffles it. Guns firing behind a cliff lose their crack altogether, their middle comes through ten decibels down and their thump four and a half, and the same guns heard across open ground sound as they always did. It eases in over a quarter of a second as the camera moves. Unit replies and the interface are never muffled.
+- An Aurora on its attack run now cracks past you with a sonic boom. EA recorded that boom, shipped it in the game's own sound archive and used it only in cinematics; no unit ever played it. It goes off as the bomber passes the camera at speed, louder the closer it flies, and a damaged Aurora limping home at cruising speed stays quiet.
+- Nothing clips any more. A dense tank fight in a city used to drive one sample in twenty past full scale; a limiter at the end of the mix now looks two milliseconds ahead and turns the whole mix down just enough, so the loudest moment is as loud as the speakers go and no louder.
- A big battle no longer fills every channel with gunfire. At most 16 battle sounds play at once, and when a seventeenth arrives the quietest, furthest one gives way, or the new one is dropped if it matters less than all of them. The same shot fired by several tanks side by side in the same moment is one louder sound instead of a stack. On a 290 unit crowd fight the busiest second went from 25 voices to 17, with the same peak level. Replies, EVA, the interface and looping sounds are never cut for it.
-- Sounds that travel before they are heard now obey the same limits as the ones that start at once. A rocket's launch heard a second late used to ignore the cap on how many copies of it may play, and a sound limited to one at a time could refuse itself and go silent. Both are EA's, both are fixed.
- Zoom out and the fight takes a step back. Unit and weapon sounds drop to 75 percent while the camera is high, and the wind, birds and city hum around them do not, so the whole map still sounds like a place.
-- A fight anywhere on the screen is heard now, zoomed out as well. The camera goes nearly three times further out than the original's, but every sound still carried only as far as it did at the original's zoom, so at full zoom the side of the screen was 700 units from the microphone and its top 1000, past the 800 most sounds reach: the top quarter of the screen was silent and a fight at the edge came through 14 decibels down with nothing above 5 kHz, against 9 decibels down for one in the middle. Every sound's reach and the air now stretch with the zoom, so the screen falls off from its middle to its edges the way it does zoomed in: at full zoom a fight in the middle plays 2.5 decibels down and one at the edge 3, still bright. The air is also thinner, so at the normal zoom a fight at the edge of the screen keeps everything up to about 13 kHz where it used to lose all above 10, and one just off it up to about 9 kHz where it used to lose all above 6.
+- A fight anywhere on the screen is heard now, zoomed out as well. The camera goes nearly three times further out than the original's, but every sound still carried only as far as it did at the original's zoom, so at full zoom the side of the screen was 700 units from the microphone and its top 1000, past the 800 most sounds reach: the top quarter of the screen was silent and a fight at the edge came through 14 decibels down, against 9 decibels down for one in the middle. Every sound's reach now stretches with the zoom, so the screen falls off from its middle to its edges the way it does zoomed in: at full zoom a fight in the middle plays 2.5 decibels down and one at the edge 3.
- Every map has a bed of ambience now: snow, town, desert or field, chosen from the terrain the map is made of and played from the game's own ambient loops. It sits under the battle and swells as you zoom out.
- The music crossfade is real. The old fade counted drawn frames, so it ran at the speed of your graphics card; it now runs on game time, two seconds, with no dip in the middle.
- A mod's music tracks can say whether they are calm, tense or battle music, and for which side, so Music Follows the Fight works with a mod's own soundtrack.
@@ -2378,6 +2373,7 @@ The whole HUD is on the hardware. Four colours carry it, and they mean the same
- That caught two changes that looked right and measured catastrophic - a wave that waited jammed the whole production line, and a retreat rule that counted buildings as gunfire sent every attack home. Both showed up as twenty matches with zero kills.
- The same habit caught a speed fix that measured beautifully for the wrong reason. Capping the search for room beside a supply dock cut a once-a-minute stall and dropped the average eight-player frame below a millisecond, which was the giveaway: the first supply centre of every match went down on a blocked spot and never went up, so no computer player had an economy and nothing was happening. Counting supply trucks and attack waves next to the frame times showed it at once. The cap came out, and the stall was cured instead by not ordering the same supply centre twice.
- Massing an army before attacking is written and measured but switched off: it needs somewhere to wait that is not the production queue.
+- The sound that crossed the battlefield, from 3.4, is out of the game again: the map echo, the air, the hills, the half-deaf blasts and the delay. Every one of them measured right in a recorded mix and none of them had been listened to on a played match, and a player called the sum a tunnel. The pitch bend and the limiter stayed.
- The whole of the group movement work is out of the game again, and that is the largest single thing this list has taken back. Lanes priced by how many other units already plan to drive over a square, a unit giving up on a queue and planning its way round, the shared corridor a selection travels down, routes priced by when somebody else will be standing on a square, spacing measured off the units you selected: all of it built, all of it measured, all of it removed. What sank it was that the self-play harness cannot see a traffic jam. A computer opponent moves five units at a time and never forms the queue a person makes by dragging a box round fifteen tanks, so thirty-three of forty-eight maps came out bit-identical over ninety-six matches and the rule fired about twice a match. Then it was asked to swing wider, and four ways of doing that were tried and thrown away - two changed nothing at all, two made units wait longer than doing nothing. Overtaking went the same way over forty matches, with the time units spend properly stuck moving in the wrong direction, which is the one column it had been rebuilt to protect. EA wrote a version of that in 2003 and switched theirs off too. The speed work underneath it stayed; the behaviour is retail's again, and this is a problem to come back to with a way of measuring it that a machine opponent cannot flatter.
- Bugs deliberately left alone are pinned by a test documenting the behaviour.
- Infantry shadows were fixed in the wrong place first, and nobody has eyeballed them yet.
diff --git a/GeneralsMD/Code/BuildFingerprint.manifest b/GeneralsMD/Code/BuildFingerprint.manifest
index 20d0e3957..5ff248f7a 100644
--- a/GeneralsMD/Code/BuildFingerprint.manifest
+++ b/GeneralsMD/Code/BuildFingerprint.manifest
@@ -2183,7 +2183,6 @@ Libraries/Source/WWVegas/Miles6/.gitignore
Libraries/Source/WWVegas/Miles6/include/MSS/MSS.h
Libraries/Source/WWVegas/Miles6/include/MSS/mss_backend_names.h
Libraries/Source/WWVegas/Miles6/include/MSS/mss_ex_pcm.h
-Libraries/Source/WWVegas/Miles6/include/MSS/mss_ex_room.h
Libraries/Source/WWVegas/Miles6/include/Mss.h
Libraries/Source/WWVegas/Miles6/miles_dispatch.cpp
Libraries/Source/WWVegas/Miles6/miniaudio/miles_miniaudio.cpp
diff --git a/GeneralsMD/Code/CMakeLists.txt b/GeneralsMD/Code/CMakeLists.txt
index e34a42731..551826db4 100644
--- a/GeneralsMD/Code/CMakeLists.txt
+++ b/GeneralsMD/Code/CMakeLists.txt
@@ -2219,7 +2219,7 @@ endfunction()
add_lib_test(test_msvc_float_casts)
target_include_directories(test_msvc_float_casts PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Libraries/Include)
-# MilesAudioDevice/AudioMixPolicy.h: the battle mix's budget, folding and occlusion arithmetic.
+# MilesAudioDevice/AudioMixPolicy.h: the battle mix's budget and folding arithmetic.
add_lib_test(test_audio_mix_policy)
target_include_directories(test_audio_mix_policy PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/GameEngineDevice/Include)
diff --git a/GeneralsMD/Code/Data/Patch.str b/GeneralsMD/Code/Data/Patch.str
index 31bcf8372..283e17ffb 100644
--- a/GeneralsMD/Code/Data/Patch.str
+++ b/GeneralsMD/Code/Data/Patch.str
@@ -690,7 +690,7 @@ GUI:LegacySound
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."
+"The original game's sound: no pitch bend on passing sounds, no Aurora sonic boom, 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
diff --git a/GeneralsMD/Code/Data/Turkish/Generals.str b/GeneralsMD/Code/Data/Turkish/Generals.str
index 71ae31dd2..38522a0e1 100644
--- a/GeneralsMD/Code/Data/Turkish/Generals.str
+++ b/GeneralsMD/Code/Data/Turkish/Generals.str
@@ -15174,7 +15174,7 @@ GUI:LegacySound
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."
+"Özgün oyunun sesi: geçen seslerde perde kayması yok, Aurora'nın ses patlaması 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
diff --git a/GeneralsMD/Code/GameEngine/Include/Common/AudioEventRTS.h b/GeneralsMD/Code/GameEngine/Include/Common/AudioEventRTS.h
index 1a9d59193..81d7cb76f 100644
--- a/GeneralsMD/Code/GameEngine/Include/Common/AudioEventRTS.h
+++ b/GeneralsMD/Code/GameEngine/Include/Common/AudioEventRTS.h
@@ -154,8 +154,6 @@ public:
Bool getUninterruptable( ) const { return m_uninterruptable; }
void setUninterruptable( Bool uninterruptable ) { m_uninterruptable = uninterruptable; }
void setSkipAttack( Bool skipAttack ) { m_skipAttack = skipAttack; } ///< start on the loop itself, for a loop picked up again mid-way
- Bool getTravels( void ) const { return m_travels; }
- void setTravels( Bool travels ) { m_travels = travels; } ///< started late by its distance, so it stops late by it too
/** LOGIC-THREAD.md M5. A random list remembers its last pick in the caller's event so it does not
* play one variant twice running, and a sound a tick asks for picks after the tick. The caller is
@@ -206,7 +204,6 @@ protected:
Bool m_isLogicalAudio; ///< Should probably only be true for scripted sounds
Bool m_uninterruptable;
Bool m_skipAttack;
- Bool m_travels;
// Playing attributes
Real m_pitchShift; ///< Pitch shift that should occur on this piece of audio
diff --git a/GeneralsMD/Code/GameEngine/Include/Common/AudioSettings.h b/GeneralsMD/Code/GameEngine/Include/Common/AudioSettings.h
index cea6485a0..35771829a 100644
--- a/GeneralsMD/Code/GameEngine/Include/Common/AudioSettings.h
+++ b/GeneralsMD/Code/GameEngine/Include/Common/AudioSettings.h
@@ -46,13 +46,8 @@ struct AudioSettings
AudioSettings() :
m_rangeVolumeFade( FALSE ),
m_speedOfSound( 1700.0f ),
- m_maxSoundDelay( 1000.0f ),
m_dopplerScale( 3.0f ),
m_dopplerFastSpeed( 100.0f ),
- m_airAbsorptionDistance( 450.0f ),
- m_reverbLevel( 1.0f ),
- m_duckVolume( 0.15f ),
- m_duckTime( 4000.0f ),
m_replyUnitCooldown( 1500.0f ),
m_replyGap( 400.0f ),
m_replyMaxVoices( 2 ),
@@ -61,11 +56,6 @@ struct AudioSettings
m_coalesceFrames( 2 ),
m_coalesceGainStep( 0.12f ),
m_coalesceMaxGain( 1.5f ),
- m_occlusionStrength( 0.75f ),
- m_occlusionVolume( 0.6f ),
- m_occlusionDepth( 20.0f ),
- m_occlusionTime( 250.0f ),
- m_occlusionRays( 16 ),
m_zoomMixNearHeight( 300.0f ),
m_zoomMixFarHeight( 900.0f ),
m_zoomMixDetailVolume( 0.75f ),
@@ -76,11 +66,6 @@ struct AudioSettings
m_ambienceBedDesert( "Amb_DesertNatureWindThinLoop" ),
m_ambienceBedField( "Amb_TemperateMeadowAmbientLoop" )
{
- m_duckSounds.push_back( "ExplosionNeutron" );
- m_duckSounds.push_back( "ExplosionDaisyCutter" );
- m_duckSounds.push_back( "ExplosionMOAB" );
- m_duckSounds.push_back( "ExplosionMiniNuke" );
- m_duckSounds.push_back( "ParticleUplinkCannon_GroundAnnihilationSoundLoop" );
}
AsciiString m_audioRoot;
@@ -107,33 +92,18 @@ struct AudioSettings
* `RangeVolumeFade` in AudioSettings.ini. */
Bool m_rangeVolumeFade;
- /** Sound in air, none of which the shipped file carries, so the defaults below are what plays.
+ /** Doppler, none of which the shipped file carries, so the defaults below are what plays.
*
- * `SpeedOfSound`, game units a second: a world sound starts late by its distance to the
- * microphone over it, never more than `MaxSoundDelay` milliseconds, and a moving one is pitched
- * by doppler. The ground is drawn at about 0.2 m a unit (a Ranger stands 13 units, a Crusader
- * is 30 long), so 343 m/s is 1700. Zero is neither. `DopplerScale` multiplies the speed doppler
- * hears, zero switching doppler alone off: 3, since a Raptor crosses the map at 35 m/s on that
- * scale and a real jet's pitch bend needs it about ten times faster. `DopplerFastSpeed`, units
- * a second: past it the scale grows with the speed, so at 100 a Raptor at 175 is heard at 5.25
- * times its speed and a tank at 30 at 3. Zero keeps one scale for everything.
- * `AirAbsorptionDistance`, game units: where air has taken the top end down from 20 kHz to 10,
- * falling with the square of the distance past it, through two stages. Zero is no air. A snow
- * map takes it at 60%, and a zoom past MaxCameraHeight stretches it with the ranges. 450: at
- * 300 a fight at the edge of the screen at EA's zoom (about 300 units off) lost all above 10 kHz
- * and one just past it (460) all above 6 kHz.
- * `ReverbLevel`: the room's send, as a share of what the map asks for. Zero is no room.
- * `DuckVolume` and `DuckTime` (milliseconds): when one of `DuckSounds` starts within earshot,
- * everything else dips to that volume and comes back over that time. 100% is no duck. */
+ * `SpeedOfSound`, game units a second: a moving world sound is pitched by doppler. The ground is
+ * drawn at about 0.2 m a unit (a Ranger stands 13 units, a Crusader is 30 long), so 343 m/s is
+ * 1700. Zero is none. `DopplerScale` multiplies the speed doppler hears, zero switching doppler
+ * off: 3, since a Raptor crosses the map at 35 m/s on that scale and a real jet's pitch bend needs
+ * it about ten times faster. `DopplerFastSpeed`, units a second: past it the scale grows with the
+ * speed, so at 100 a Raptor at 175 is heard at 5.25 times its speed and a tank at 30 at 3. Zero
+ * keeps one scale for everything. */
Real m_speedOfSound;
- Real m_maxSoundDelay;
Real m_dopplerScale;
Real m_dopplerFastSpeed;
- Real m_airAbsorptionDistance;
- Real m_reverbLevel;
- Real m_duckVolume;
- Real m_duckTime;
- std::vector<AsciiString> m_duckSounds;
/** The battle mix (MilesAudioManager), none of which the shipped file carries either.
*
@@ -149,13 +119,7 @@ struct AudioSettings
*
* `CoalesceRadius` (game units) and `CoalesceFrames` (logic frames): the same one-shot sound asked
* for that soon after and that close to another is folded into it, which plays `CoalesceGainStep`
- * louder for each one folded in, at most `CoalesceMaxGain` times. A zero radius folds nothing.
- *
- * Occlusion: ground or a building in the line from the microphone muffles a world sound, the low
- * pass at `OcclusionStrength` of the backend's occlusion and the volume down to `OcclusionVolume`
- * once `OcclusionDepth` units of hill stand in the line, moving over `OcclusionTime` milliseconds;
- * `OcclusionRaysPerFrame` playing sounds are looked at again each pass. A zero strength is no
- * occlusion. */
+ * louder for each one folded in, at most `CoalesceMaxGain` times. A zero radius folds nothing. */
Real m_replyUnitCooldown;
Real m_replyGap;
Int m_replyMaxVoices;
@@ -164,11 +128,6 @@ struct AudioSettings
Int m_coalesceFrames;
Real m_coalesceGainStep;
Real m_coalesceMaxGain;
- Real m_occlusionStrength;
- Real m_occlusionVolume;
- Real m_occlusionDepth;
- Real m_occlusionTime;
- Int m_occlusionRays;
/** The mix as the camera zooms out, none of which the shipped file carries.
*
@@ -177,7 +136,7 @@ struct AudioSettings
* to `ZoomMixDetailVolume` of their level, while ambience keeps its own; zoomed back in, the
* detail returns. 100% leaves the mix as it was. EA's own zoom bonus (`ZoomSoundVolume...`)
* still applies on top, to both. 75%, 2.5 dB: 60% took 4.4 dB off a zoomed out
- * fight, on top of EA's 1.9. The ranges and the air stretch with the zoom as well
+ * fight, on top of EA's 1.9. The ranges stretch with the zoom as well
* (AudioManager::getRangeScale), which is what keeps the edges of a zoomed out screen in earshot.
*
* The map's ambience bed (MilesAudioManager::updateAmbienceBed): one looping 2D sound chosen
diff --git a/GeneralsMD/Code/GameEngine/Include/Common/GameAudio.h b/GeneralsMD/Code/GameEngine/Include/Common/GameAudio.h
index c54759977..80690f6de 100644
--- a/GeneralsMD/Code/GameEngine/Include/Common/GameAudio.h
+++ b/GeneralsMD/Code/GameEngine/Include/Common/GameAudio.h
@@ -271,8 +271,6 @@ class AudioManager : public SubsystemInterface
const AudioSettings *getAudioSettings( void ) const;
const MiscAudio *getMiscAudio( void ) const;
- /// how long a sound from there takes to reach the microphone, milliseconds, at most MaxSoundDelay
- Real getTravelMs( const Coord3D *position ) const;
// This function should only be called by AudioManager, MusicManager and SoundManager
virtual void releaseAudioEventRTS( AudioEventRTS *eventToRelease );
@@ -316,7 +314,7 @@ class AudioManager : public SubsystemInterface
Real getZoomVolume() const { return m_zoomVolume; }
/// how far out the camera is between ZoomMixNearHeight (0) and ZoomMixFarHeight (1)
Real getZoomOut() const { return m_zoomOut; }
- /// what every world sound's MinRange, MaxRange and the air are multiplied by: the camera's zoom past
+ /// what every world sound's MinRange and MaxRange are multiplied by: the camera's zoom past
/// MaxCameraHeight, so the screen sounds as far across at any zoom as at the one the ranges were made for
Real getRangeScale() const { return m_rangeScale; }
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/Audio/AudioEventRTS.cpp b/GeneralsMD/Code/GameEngine/Source/Common/Audio/AudioEventRTS.cpp
index 5ec4659f2..09455b4e2 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/Audio/AudioEventRTS.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/Audio/AudioEventRTS.cpp
@@ -85,8 +85,7 @@ AudioEventRTS::AudioEventRTS()
m_playerIndex(-1),
m_delay(0.0f),
m_uninterruptable(FALSE),
- m_skipAttack(FALSE),
- m_travels(FALSE)
+ m_skipAttack(FALSE)
{
m_attackName.clear();
m_decayName.clear();
@@ -114,8 +113,7 @@ AudioEventRTS::AudioEventRTS( const AsciiString& eventName )
m_playerIndex(-1),
m_delay(0.0f),
m_uninterruptable(FALSE),
- m_skipAttack(FALSE),
- m_travels(FALSE)
+ m_skipAttack(FALSE)
{
m_attackName.clear();
m_decayName.clear();
@@ -144,8 +142,7 @@ AudioEventRTS::AudioEventRTS( const AsciiString& eventName, ObjectID ownerID )
m_playerIndex(-1),
m_delay(0.0f),
m_uninterruptable(FALSE),
- m_skipAttack(FALSE),
- m_travels(FALSE)
+ m_skipAttack(FALSE)
{
m_attackName.clear();
m_decayName.clear();
@@ -182,8 +179,7 @@ AudioEventRTS::AudioEventRTS( const AsciiString& eventName, DrawableID drawableI
m_playerIndex(-1),
m_delay(0.0f),
m_uninterruptable(FALSE),
- m_skipAttack(FALSE),
- m_travels(FALSE)
+ m_skipAttack(FALSE)
{
m_attackName.clear();
m_decayName.clear();
@@ -219,8 +215,7 @@ AudioEventRTS::AudioEventRTS( const AsciiString& eventName, const Coord3D *posit
m_playerIndex(-1),
m_delay(0.0f),
m_uninterruptable(FALSE),
- m_skipAttack(FALSE),
- m_travels(FALSE)
+ m_skipAttack(FALSE)
{
m_positionOfAudio.set( positionOfAudio );
m_attackName.clear();
@@ -253,7 +248,6 @@ AudioEventRTS::AudioEventRTS( const AudioEventRTS& right )
m_portionToPlayNext = right.m_portionToPlayNext;
m_uninterruptable = right.m_uninterruptable;
m_skipAttack = right.m_skipAttack;
- m_travels = right.m_travels;
if( m_ownerType == OT_Positional || m_ownerType == OT_Dead )
{
@@ -296,7 +290,6 @@ AudioEventRTS& AudioEventRTS::operator=( const AudioEventRTS& right )
m_portionToPlayNext = right.m_portionToPlayNext;
m_uninterruptable = right.m_uninterruptable;
m_skipAttack = right.m_skipAttack;
- m_travels = right.m_travels;
if( m_ownerType == OT_Positional || m_ownerType == OT_Dead )
{
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/Audio/GameAudio.cpp b/GeneralsMD/Code/GameEngine/Source/Common/Audio/GameAudio.cpp
index b8c32895b..f85eea5f2 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/Audio/GameAudio.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/Audio/GameAudio.cpp
@@ -131,14 +131,8 @@ static const FieldParse audioSettingsFieldParseTable[] =
{ "MinSampleVolume", INI::parsePercentToReal, NULL, offsetof( AudioSettings, m_minVolume) },
{ "RangeVolumeFade", INI::parseBool, NULL, offsetof( AudioSettings, m_rangeVolumeFade) },
{ "SpeedOfSound", INI::parseReal, NULL, offsetof( AudioSettings, m_speedOfSound) },
- { "MaxSoundDelay", INI::parseReal, NULL, offsetof( AudioSettings, m_maxSoundDelay) },
{ "DopplerScale", INI::parseReal, NULL, offsetof( AudioSettings, m_dopplerScale) },
{ "DopplerFastSpeed", INI::parseReal, NULL, offsetof( AudioSettings, m_dopplerFastSpeed) },
- { "AirAbsorptionDistance", INI::parseReal, NULL, offsetof( AudioSettings, m_airAbsorptionDistance) },
- { "ReverbLevel", INI::parsePercentToReal, NULL, offsetof( AudioSettings, m_reverbLevel) },
- { "DuckVolume", INI::parsePercentToReal, NULL, offsetof( AudioSettings, m_duckVolume) },
- { "DuckTime", INI::parseReal, NULL, offsetof( AudioSettings, m_duckTime) },
- { "DuckSounds", INI::parseAsciiStringVector, NULL, offsetof( AudioSettings, m_duckSounds) },
{ "ReplyUnitCooldown", INI::parseReal, NULL, offsetof( AudioSettings, m_replyUnitCooldown) },
{ "ReplyGap", INI::parseReal, NULL, offsetof( AudioSettings, m_replyGap) },
{ "ReplyMaxVoices", INI::parseInt, NULL, offsetof( AudioSettings, m_replyMaxVoices) },
@@ -147,11 +141,6 @@ static const FieldParse audioSettingsFieldParseTable[] =
{ "CoalesceFrames", INI::parseInt, NULL, offsetof( AudioSettings, m_coalesceFrames) },
{ "CoalesceGainStep", INI::parsePercentToReal, NULL, offsetof( AudioSettings, m_coalesceGainStep) },
{ "CoalesceMaxGain", INI::parsePercentToReal, NULL, offsetof( AudioSettings, m_coalesceMaxGain) },
- { "OcclusionStrength", INI::parsePercentToReal, NULL, offsetof( AudioSettings, m_occlusionStrength) },
- { "OcclusionVolume", INI::parsePercentToReal, NULL, offsetof( AudioSettings, m_occlusionVolume) },
- { "OcclusionDepth", INI::parseReal, NULL, offsetof( AudioSettings, m_occlusionDepth) },
- { "OcclusionTime", INI::parseReal, NULL, offsetof( AudioSettings, m_occlusionTime) },
- { "OcclusionRaysPerFrame", INI::parseInt, NULL, offsetof( AudioSettings, m_occlusionRays) },
{ "ZoomMixNearHeight", INI::parseReal, NULL, offsetof( AudioSettings, m_zoomMixNearHeight) },
{ "ZoomMixFarHeight", INI::parseReal, NULL, offsetof( AudioSettings, m_zoomMixFarHeight) },
{ "ZoomMixDetailVolume", INI::parsePercentToReal, NULL, offsetof( AudioSettings, m_zoomMixDetailVolume) },
@@ -610,19 +599,6 @@ AudioHandle AudioManager::addAudioEventNow(const AudioEventRTS *eventToAdd, Audi
((AudioEventRTS*)eventToAdd)->setPlayingAudioIndex( audioEvent->getPlayingAudioIndex() );
audioEvent->generatePlayInfo(); // generate pitch shift and volume shift now as well
- // Sound takes time to arrive: a world sound starts late by its distance to the microphone over
- // SpeedOfSound, at most MaxSoundDelay, on top of the delay its INI gives it. Not a unit's voice,
- // which answers the player, and not a script's sound, which logic waits on in the same frame. The
- // request list counts the delay down in logic time (MilesAudioManager::processRequestList). Such a
- // sound is marked as travelling, and its stop is held back the same way (stopAudioEvent).
- const AudioEventInfo *info = eventToAdd->getAudioEventInfo();
- if (info->m_soundType == AT_SoundEffect && audioEvent->isPositionalAudio() && !eventToAdd->getIsLogicalAudio()
- && !BitTest(info->m_type, ST_VOICE) && getAudioSettings()->m_speedOfSound > 0.0f)
- {
- audioEvent->setDelay(audioEvent->getDelay() + getTravelMs(audioEvent->getCurrentPosition()));
- audioEvent->setTravels(TRUE);
- }
-
std::list<std::pair<AsciiString, Real> >::iterator it;
for (it = m_adjustedVolumes.begin(); it != m_adjustedVolumes.end(); ++it) {
if (it->first == audioEvent->getEventName()) {
@@ -1136,15 +1112,6 @@ const AudioSettings *AudioManager::getAudioSettings( void ) const
return m_audioSettings;
}
-//-------------------------------------------------------------------------------------------------
-Real AudioManager::getTravelMs( const Coord3D *position ) const
-{
- Coord3D toMicrophone = *position;
- toMicrophone.sub(&m_listenerPosition);
- const Real travelMs = toMicrophone.length() / m_audioSettings->m_speedOfSound * MSEC_PER_SECOND;
- return travelMs < m_audioSettings->m_maxSoundDelay ? travelMs : m_audioSettings->m_maxSoundDelay;
-}
-
//-------------------------------------------------------------------------------------------------
AudioSettings *AudioManager::friend_getAudioSettings( void )
{
diff --git a/GeneralsMD/Code/GameEngineDevice/Include/MilesAudioDevice/AudioMixPolicy.h b/GeneralsMD/Code/GameEngineDevice/Include/MilesAudioDevice/AudioMixPolicy.h
index 598bc0dfd..d44dc9540 100644
--- a/GeneralsMD/Code/GameEngineDevice/Include/MilesAudioDevice/AudioMixPolicy.h
+++ b/GeneralsMD/Code/GameEngineDevice/Include/MilesAudioDevice/AudioMixPolicy.h
@@ -49,53 +49,4 @@ inline float coalescedGain(int merged, float step, float ceiling)
return gain < ceiling ? gain : ceiling;
}
-/// The deepest that ground or a roof stands above the straight line from the microphone (l) to the
-/// sound (s), in game units, or 0 for a clear line. heightAt(x, y) is the highest blocker at a point.
-/// The line is sampled every step units, leaving out margin units at either end, where the ground the
-/// sound stands on and the slope under the microphone would count as hills.
-template <class HeightAt>
-float rayObstruction(float lx, float ly, float lz, float sx, float sy, float sz, float step, float margin,
- int maxSamples, HeightAt heightAt)
-{
- const float dx = sx - lx;
- const float dy = sy - ly;
- const float length = sqrtf(dx * dx + dy * dy);
- if (length <= 2.0f * margin || step <= 0.0f)
- return 0.0f;
- int samples = (int)((length - 2.0f * margin) / step) + 1;
- if (samples > maxSamples)
- samples = maxSamples;
- float deepest = 0.0f;
- for (int i = 0; i < samples; ++i) {
- const float along = margin + (length - 2.0f * margin) * ((float)i + 0.5f) / (float)samples;
- const float t = along / length;
- const float lineZ = lz + (sz - lz) * t;
- const float depth = heightAt(lx + dx * t, ly + dy * t) - lineZ;
- if (depth > deepest)
- deepest = depth;
- }
- return deepest;
-}
-
-/// The share of the full muffle a depth earns: none at 0, all of it from fullDepth units of hill on.
-inline float occlusionAmount(float depth, float fullDepth)
-{
- if (depth <= 0.0f || fullDepth <= 0.0f)
- return depth > 0.0f ? 1.0f : 0.0f;
- const float amount = depth / fullDepth;
- return amount < 1.0f ? amount : 1.0f;
-}
-
-/// One step of a smoothed value towards its target, over elapsedMs, closing 63% of the gap every
-/// timeMs. No time at all leaves it where it is; a zero time jumps.
-inline float approach(float current, float target, float elapsedMs, float timeMs)
-{
- if (timeMs <= 0.0f)
- return target;
- if (elapsedMs <= 0.0f)
- return current;
- const float keep = expf(-elapsedMs / timeMs);
- return target + (current - target) * keep;
-}
-
} // namespace AudioMixPolicy
diff --git a/GeneralsMD/Code/GameEngineDevice/Include/MilesAudioDevice/MilesAudioManager.h b/GeneralsMD/Code/GameEngineDevice/Include/MilesAudioDevice/MilesAudioManager.h
index 517d379f5..2ecd008ed 100644
--- a/GeneralsMD/Code/GameEngineDevice/Include/MilesAudioDevice/MilesAudioManager.h
+++ b/GeneralsMD/Code/GameEngineDevice/Include/MilesAudioDevice/MilesAudioManager.h
@@ -93,16 +93,13 @@ struct PlayingAudio
Bool m_tracked;
Coord3D m_lastPosition;
Coord3D m_velocity;
- /// A sound that started late by its distance stops late by it too: the stop is held here, in
- /// logic milliseconds still to wait, and m_stopHeld stays set once it has gone through.
- Bool m_stopHeld;
- Real m_stopInMs;
- /// A world sound behind a hill or a building (MilesAudioManager::updateOcclusion): how muffled it
- /// is now, 0 to 1, what the last look along the line said it should be, and EA's off-screen low pass
- /// it was started with, which the muffle never goes under.
- Real m_occlusion;
- Real m_occlusionTarget;
+ /// EA's off-screen low pass (LowPassCutoff), which the sound was started with.
Real m_offscreenOcclusion;
+ /// The Aurora's pass (MilesAudioManager::updateSonicPass): the microphone's distance last pass,
+ /// whether that was closing, and the logic frame the jet last flew at its attack speed.
+ Real m_passDistance;
+ Bool m_passClosing;
+ UnsignedInt m_supersonicAt;
PlayingAudio() :
m_type(PAT_INVALID),
@@ -116,11 +113,10 @@ struct PlayingAudio
m_stream(0),
m_framesFaded(0.0f),
m_tracked(false),
- m_stopHeld(false),
- m_stopInMs(0.0f),
- m_occlusion(0.0f),
- m_occlusionTarget(0.0f),
- m_offscreenOcclusion(0.0f)
+ m_offscreenOcclusion(0.0f),
+ m_passDistance(0.0f),
+ m_passClosing(false),
+ m_supersonicAt(0)
{
m_lastPosition.zero();
m_velocity.zero();
@@ -271,13 +267,7 @@ class MilesAudioManager : public AudioManager
void logMix( void );
void noteReach( const PlayingAudio *playing, const Coord3D *pos ) const;
void setSampleDistances( H3DSAMPLE sample3D, const AudioEventRTS *event ) const;
-
- // Occlusion: the line from the microphone to a world sound, through the ground and the buildings.
- Real lookForOcclusion( const Coord3D *pos ) const;
- void updateOcclusion( PlayingAudio *playing, const Coord3D *pos, Bool look );
void applyOcclusion( PlayingAudio *playing );
- void buildBlockers( void );
- Real getBlockerHeight( Real x, Real y ) const;
virtual void adjustVolumeOfPlayingAudio(AsciiString eventName, Real newVolume);
@@ -292,10 +282,10 @@ class MilesAudioManager : public AudioManager
void adjustRequest( AudioRequest *req );
void advanceAudioClock( void );
void trackVelocity( PlayingAudio *playing, const Coord3D *pos );
- void setRoomFromMap( void );
+ void updateSonicPass( PlayingAudio *playing, const Coord3D *pos );
+ void chooseAmbienceBed( void );
void applyLegacySound( void );
void updateAmbienceBed( void );
- void duckForBlast( AudioEventRTS *event, H3DSAMPLE sample3D );
Bool checkForSample( AudioRequest *req );
virtual void setHardwareAccelerated(Bool accel);
@@ -384,14 +374,13 @@ class MilesAudioManager : public AudioManager
UnsignedInt m_clockFrame;
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
+ AsciiString m_bedMap; ///< the map chooseAmbienceBed last chose a bed for
Bool m_legacySound; ///< what applyLegacySound last put into m_audioSettings
- Real m_roomAbsorption; ///< the air's absorption distance the room asks for, before the range scale
- Real m_airScale; ///< the range scale the backend's air was last given with, 0 to give it again
+ UnsignedInt m_boomedAt; ///< the logic frame of the last sonic boom (updateSonicPass)
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
+ Bool m_askingOnArrival; ///< checkForSample is asking canPlayNow about a sound that waited out its Delay
- /// The map's ambience bed (AmbienceBed* in AudioSettings.h): the event setRoomFromMap chose, the
+ /// The map's ambience bed (AmbienceBed* in AudioSettings.h): the event chooseAmbienceBed chose, the
/// handle of the one playing, and the logic frame it was last started at.
AsciiString m_bedEvent;
AudioHandle m_bedHandle;
@@ -470,9 +459,8 @@ class MilesAudioManager : public AudioManager
/// What the mix did since the last AUDIO MIX line, and the most 3D voices heard at once.
struct MixCounts
{
- Int started3D, merged, stolen, overBudget, repliesLet, repliesHeld, looks;
+ Int started3D, merged, stolen, overBudget, repliesLet, repliesHeld;
UnsignedInt peak3D, peakBattle;
- Real occludedPeak;
// the AUDIO REACH line (noteReach): battle sounds started in the middle of the screen, on the
// rest of it and off it, their summed distance, gain in dB and cutoff in Hz
Int reachCount[3];
@@ -480,12 +468,6 @@ class MilesAudioManager : public AudioManager
};
mutable MixCounts m_mixCounts;
UnsignedInt m_mixLoggedAt;
- UnsignedInt m_occlusionCursor;
- /// The tallest roof over each cell, for occlusion, rebuilt now and then from the drawables.
- std::vector<Real> m_blockers;
- Int m_blockerColumns;
- Int m_blockerRows;
- UnsignedInt m_blockersBuiltAt;
AudioFileCache *m_audioCache;
PlayingAudio *m_binkHandle;
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/MilesAudioDevice/MilesAudioManager.cpp b/GeneralsMD/Code/GameEngineDevice/Source/MilesAudioDevice/MilesAudioManager.cpp
index 3b8f8d40e..344a1e556 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/MilesAudioDevice/MilesAudioManager.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/MilesAudioDevice/MilesAudioManager.cpp
@@ -146,17 +146,12 @@ MilesAudioManager::MilesAudioManager() :
m_clockElapsedMs(MSEC_PER_LOGICFRAME_REAL),
m_clockMovedAt(0),
m_legacySound(FALSE),
- m_roomAbsorption(0.0f),
- m_airScale(0.0f),
+ m_boomedAt(0),
m_askingOnArrival(false),
m_bedHandle(AHSV_Error),
m_bedStartedAt(0),
m_lastReplyAtMs(0),
m_mixLoggedAt(0),
- m_occlusionCursor(0),
- m_blockerColumns(0),
- m_blockerRows(0),
- m_blockersBuiltAt(0),
m_binkHandle(NULL),
m_pref3DProvider(AsciiString::TheEmptyString),
m_prefSpeaker(AsciiString::TheEmptyString)
@@ -509,7 +504,6 @@ void MilesAudioManager::init()
{
AudioManager::init();
m_engineSettings = *m_audioSettings;
- m_roomAbsorption = m_audioSettings->m_airAbsorptionDistance;
#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.
@@ -543,10 +537,8 @@ void MilesAudioManager::reset()
removeAllAudioRequests();
m_recentShots.clear();
m_replyAtMs.clear();
- m_blockers.clear();
- m_blockersBuiltAt = 0;
// the bed went with everything else; the next map, the same one again included, chooses anew
- m_roomMap.clear();
+ m_bedMap.clear();
m_bedEvent.clear();
m_bedHandle = AHSV_Error;
// This must come after stopAllAudioImmediately() and removeAllAudioRequests(), to ensure that
@@ -628,20 +620,10 @@ void MilesAudioManager::update()
updateSoundCapture();
advanceAudioClock();
applyLegacySound();
- if (TheGameLogic->isInGame() && !TheGameLogic->isLoadingMap() && m_roomMap != TheGlobalData->m_mapName)
+ if (TheGameLogic->isInGame() && !TheGameLogic->isLoadingMap() && m_bedMap != TheGlobalData->m_mapName)
{
- m_roomMap = TheGlobalData->m_mapName;
- setRoomFromMap();
- }
- // the air, as far as the room has it, stretched with the sounds' ranges (AudioManager::getRangeScale)
- if (m_airScale != getRangeScale())
- {
- m_airScale = getRangeScale();
- AIL_ex_set_3D_air(m_audioSettings->m_speedOfSound, m_roomAbsorption * m_airScale);
- }
- if (TheGameLogic->isInGame() && !TheGameLogic->isLoadingMap())
- {
- buildBlockers();
+ m_bedMap = TheGlobalData->m_mapName;
+ chooseAmbienceBed();
}
updateAmbienceBed();
setDeviceListenerPosition();
@@ -987,9 +969,6 @@ void MilesAudioManager::playAudioEvent( AudioEventRTS *event, Bool requestStop,
audio->m_file = playSample3D(audio);
m_sound->notifyOf3DSampleStart();
++m_mixCounts.started3D;
- if (audio->m_file && !nextLoop) {
- duckForBlast(event, sample3D);
- }
}
if( !audio->m_file )
@@ -1128,7 +1107,7 @@ void MilesAudioManager::stopAudioEvent( AudioHandle handle )
// event back to the request list. Stopping it there is the only way to stop it at all, or the
// loop outlives the thing that asked for it. A one-shot sound effect still plays the one pass
// it was waiting for, the same as one caught mid-play below; a loop is dropped, as one playing
- // below ends its pass, which matters since the distance delay holds nearly every world loop here.
+ // below ends its pass.
// A loop already heard and waiting between passes plays its decay now, as a playing one would.
//
std::list<AudioRequest*>::iterator ait;
@@ -1196,19 +1175,6 @@ void MilesAudioManager::stopAudioEvent( AudioHandle handle )
#ifdef INTENSIVE_AUDIO_DEBUG
DEBUG_LOG((" (%s)\n", audio->m_audioEventRTS->getEventName()));
#endif
- // What is heard is what happened a travel time ago, so a sound that started late by its
- // distance ends late by it too: a missile's flight loop runs on until its boom arrives,
- // rather than going quiet the moment it is seen to hit. processPlayingList lets it go.
- if (audio->m_stopHeld) {
- break;
- }
- const Real travelMs = audio->m_audioEventRTS->getTravels()
- ? getTravelMs(audio->m_audioEventRTS->getCurrentPosition()) : 0.0f;
- if (travelMs > 0.0f) {
- audio->m_stopHeld = true;
- audio->m_stopInMs = travelMs;
- break;
- }
audio->m_requestStop = true;
endLoopPassNow( audio );
break;
@@ -1663,15 +1629,10 @@ void MilesAudioManager::initFilters3D( PlayingAudio *audio, const Coord3D *pos )
AIL_set_3D_sample_playback_rate(sample, REAL_TO_INT(AIL_3D_sample_playback_rate(sample) * pitchShift));
}
- // Low pass filter: a real one now, a ceiling on the cutoff air already lowers with distance
- // (MSS.h's AIL_ex_3D_cutoff), where it used to be a cut in volume. Every pass of the sound asks
- // again, and a hill in the way muffles it further (updateOcclusion); applyOcclusion sets both, and
- // the volume, since a new file on the handle has put its occlusion back to none.
+ // Low pass filter: EA's LowPassCutoff, for a sound off screen (MSS.h's AIL_ex_3D_cutoff). Every
+ // pass of the sound asks again, since a new file on the handle has put its occlusion back to none.
audio->m_offscreenOcclusion = (event->getAudioEventInfo()->m_lowPassFreq > 0 && !isOnScreen(pos))
? 1.0f - event->getAudioEventInfo()->m_lowPassFreq : 0.0f;
- if (!audio->m_tracked) {
- updateOcclusion(audio, pos, TRUE); // the first pass hears its hill from the start
- }
applyOcclusion(audio);
noteReach(audio, pos);
}
@@ -1679,8 +1640,8 @@ void MilesAudioManager::initFilters3D( PlayingAudio *audio, const Coord3D *pos )
//-------------------------------------------------------------------------------------------------
/** What a battle sound starts at, for the AUDIO REACH line: where on the screen it is (the middle
* half of the width and height, the rest of the screen, off it), its distance from the microphone,
- * its gain before the sliders (distance, the hill in the way, the zoom mix) and its low-pass cutoff
- * (air and occlusion, AIL_ex_3D_cutoff; a snow map's thinner air is not counted). */
+ * its gain before the sliders (distance, the zoom mix) and its low-pass cutoff (EA's off-screen
+ * one, AIL_ex_3D_cutoff, or 20 kHz). */
void MilesAudioManager::noteReach( const PlayingAudio *playing, const Coord3D *pos ) const
{
const AudioEventInfo *info = playing->m_audioEventRTS->getAudioEventInfo();
@@ -1700,15 +1661,12 @@ void MilesAudioManager::noteReach( const PlayingAudio *playing, const Coord3D *p
Coord3D toMicrophone = *pos;
toMicrophone.sub(&m_listenerPosition);
const Real distance = toMicrophone.length();
- const AudioSettings *settings = m_audioSettings;
- const Real occlusionGain = 1.0f - (1.0f - settings->m_occlusionVolume) * playing->m_occlusion;
const Real gain = AIL_ex_3D_distance_gain(distance, info->m_minDistance * getRangeScale(), info->m_maxDistance * getRangeScale(),
- settings->m_rangeVolumeFade) * occlusionGain * m_zoomDetailVolume;
- const Real occlusion = max(playing->m_offscreenOcclusion, playing->m_occlusion * settings->m_occlusionStrength);
+ m_audioSettings->m_rangeVolumeFade) * m_zoomDetailVolume;
++m_mixCounts.reachCount[bucket];
m_mixCounts.reachDistance[bucket] += distance;
m_mixCounts.reachGainDb[bucket] += 20.0f * log10f(max(gain, 0.001f));
- m_mixCounts.reachCutoff[bucket] += AIL_ex_3D_cutoff(distance, settings->m_airAbsorptionDistance * getRangeScale(), occlusion);
+ m_mixCounts.reachCutoff[bucket] += AIL_ex_3D_cutoff(playing->m_offscreenOcclusion);
}
//-------------------------------------------------------------------------------------------------
@@ -1858,7 +1816,7 @@ void MilesAudioManager::openDevice( void )
// AIL_quick_startup should be replaced later with a call to actually pick which device to use, etc
const AudioSettings *audioSettings = getAudioSettings();
AIL_ex_set_3D_linear_falloff(audioSettings->m_rangeVolumeFade);
- AIL_ex_set_3D_air(audioSettings->m_speedOfSound, audioSettings->m_airAbsorptionDistance);
+ AIL_ex_set_3D_air(audioSettings->m_speedOfSound);
m_selectedSpeakerType = TheAudio->translateSpeakerTypeToUnsignedInt(m_prefSpeaker);
retval = AIL_quick_startup(audioSettings->m_useDigital, audioSettings->m_useMidi, audioSettings->m_outputRate, audioSettings->m_outputBits, audioSettings->m_outputChannels);
@@ -2537,7 +2495,7 @@ void MilesAudioManager::noteShot( AudioEventRTS *event ) const
* that matters least (AudioMixPolicy::importance: priority, then loudness at the microphone, so the
* quietest and farthest go first) through EA's own handle-to-kill, or is not played when it matters
* less than every one of them. Asked only when the sound is about to play: a sound still waiting
- * for its distance is let into the queue, since what plays by the time it arrives is not known yet.
+ * out its INI's Delay is let into the queue, since what plays by the time it starts is not known yet.
* Voices, ambience, loops and the 2D sounds of the interface are outside the budget, so battle noise
* never takes their voices. */
Bool MilesAudioManager::refuseOverBudget( AudioEventRTS *event ) const
@@ -2596,9 +2554,8 @@ void MilesAudioManager::logMix( void )
return;
}
DEBUG_LOG(("AUDIO MIX frame %u: %d 3D starts, peak %u voices (%u battle), %d folded, %d taken, %d over budget, "
- "%d replies let %d held, %d looks, most muffled %.2f\n", frame, m_mixCounts.started3D, m_mixCounts.peak3D,
- m_mixCounts.peakBattle, m_mixCounts.merged, m_mixCounts.stolen, m_mixCounts.overBudget, m_mixCounts.repliesLet,
- m_mixCounts.repliesHeld, m_mixCounts.looks, m_mixCounts.occludedPeak));
+ "%d replies let %d held\n", frame, m_mixCounts.started3D, m_mixCounts.peak3D, m_mixCounts.peakBattle,
+ m_mixCounts.merged, m_mixCounts.stolen, m_mixCounts.overBudget, m_mixCounts.repliesLet, m_mixCounts.repliesHeld));
// How far the microphone is from the ground at the middle of the screen's side and top and bottom
// edges, against which the battle sounds started this second in each part of the screen.
@@ -3086,14 +3043,9 @@ void MilesAudioManager::processPlayingList( void )
}
}
- // Occlusion looks along a few lines a pass, taking the playing sounds in turn (updateOcclusion).
- const UnsignedInt count3D = (UnsignedInt)m_playing3DSounds.size();
- const UnsignedInt looksThisPass = (UnsignedInt)max(m_audioSettings->m_occlusionRays, 0);
- UnsignedInt index3D = 0;
for (it = m_playing3DSounds.begin(); it != m_playing3DSounds.end(); ++it)
{
playing = (*it);
- const Bool lookAgain = (index3D++ + count3D - m_occlusionCursor % count3D) % count3D < looksThisPass;
if (!playing)
continue;
@@ -3113,17 +3065,6 @@ void MilesAudioManager::processPlayingList( void )
adjustPlayingVolume(playing);
}
- // a held stop (stopAudioEvent) goes through once its travel time has passed
- if (playing->m_stopHeld && playing->m_stopInMs > 0.0f)
- {
- playing->m_stopInMs -= m_clockElapsedMs;
- if (playing->m_stopInMs <= 0.0f)
- {
- playing->m_requestStop = true;
- endLoopPassNow( playing );
- }
- }
-
const Coord3D *pos = getCurrentPositionFromEvent(playing->m_audioEventRTS);
if (pos)
{
@@ -3161,8 +3102,8 @@ void MilesAudioManager::processPlayingList( void )
}
else
{
- updateOcclusion( playing, pos, lookAgain );
trackVelocity( playing, pos );
+ updateSonicPass( playing, pos );
setSampleDistances( playing->m_3DSample, playing->m_audioEventRTS );
Real x = pos->x;
Real y = pos->y;
@@ -3180,8 +3121,6 @@ void MilesAudioManager::processPlayingList( void )
}
}
- m_occlusionCursor += looksThisPass;
-
// what the AUDIO MIX line reports: the most 3D voices at once, and how many of them were battle
UnsignedInt playing3D = 0;
UnsignedInt playingBattle = 0;
@@ -3193,7 +3132,6 @@ void MilesAudioManager::processPlayingList( void )
if (info && !BitTest(info->m_type, ST_VOICE | ST_GLOBAL) && !isAmbientSound(info)) {
++playingBattle;
}
- m_mixCounts.occludedPeak = max(m_mixCounts.occludedPeak, playing->m_occlusion);
}
}
m_mixCounts.peak3D = max(m_mixCounts.peak3D, playing3D);
@@ -3334,8 +3272,7 @@ void MilesAudioManager::adjustRequest( AudioRequest *req )
}
// A world sound counts logic time, not a frame's worth a pass: at 120 fps that ran every delay
- // twice as fast as the picture, and a sound held back by its distance has to land with what is
- // seen. Everything else keeps a frame a pass, so the pause menu's sounds still play while the
+ // twice as fast as the picture. Everything else keeps a frame a pass, so the pause menu's sounds still play while the
// logic clock stands.
req->m_pendingEvent->decrementDelay(req->m_pendingEvent->isPositionalAudio() ? m_clockElapsedMs : MSEC_PER_LOGICFRAME_REAL);
req->m_requiresCheckForSample = true;
@@ -3402,165 +3339,72 @@ void MilesAudioManager::trackVelocity( PlayingAudio *playing, const Coord3D *pos
}
//-------------------------------------------------------------------------------------------------
-/** A world sound behind a hill or a building is muffled: the line from the microphone to it is looked
- * along (lookForOcclusion), and the deeper ground or a roof stands in it, the lower the backend's low
- * pass closes (the occlusion it already takes for EA's off-screen sounds, AIL_ex_3D_cutoff) and the
- * quieter it plays. A sound's first pass is looked at as it starts; after that OcclusionRaysPerFrame
- * playing sounds are looked at again a pass, in turn, and the muffle moves towards what they saw over
- * OcclusionTime of logic time, so a unit walking out from behind a ridge opens up rather than
- * jumping. Voices and sounds heard map-wide are never muffled. Only the client's view of the
- * ground and the drawables is read. */
-void MilesAudioManager::updateOcclusion( PlayingAudio *playing, const Coord3D *pos, Bool look )
+/** An Aurora at its attack speed breaks past the microphone with EA's sonic boom, a stereo sound in
+ * the base game's Audio.big that only a cinematic's event (Cin_SonicBoom) asks for. It is heard off
+ * the jet's own engine loop, so what the loop keeps quiet, a jet out of range or in the fog, stays
+ * quiet, and nothing here reaches logic. The jet slows the moment its bomb is away, so a pass just
+ * after still counts; the closest it comes picks the moment and the volume, and a flight of them
+ * booms once. */
+void MilesAudioManager::updateSonicPass( PlayingAudio *playing, const Coord3D *pos )
{
- 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);
- }
+ if (m_clockElapsedMs <= 0.0f || m_legacySound || playing->m_audioEventRTS->getEventName() != "AuroraBomberAmbientLoop") {
return;
}
- if (look) {
- playing->m_occlusionTarget = lookForOcclusion(pos);
- }
- const Real before = playing->m_occlusion;
- playing->m_occlusion = playing->m_tracked
- ? AudioMixPolicy::approach(before, playing->m_occlusionTarget, m_clockElapsedMs, m_audioSettings->m_occlusionTime)
- : playing->m_occlusionTarget;
- if (playing->m_occlusion != before) {
- applyOcclusion(playing);
- }
-}
-
-//-------------------------------------------------------------------------------------------------
-/** The low pass and the volume of a 3D sound: EA's off-screen low pass or the muffle, whichever is
- * the closer, and the sliders' volume taken down by the muffle. */
-void MilesAudioManager::applyOcclusion( PlayingAudio *playing )
-{
- const AudioSettings *settings = m_audioSettings;
- const Real muffle = playing->m_occlusion * settings->m_occlusionStrength;
- AIL_set_3D_sample_occlusion(playing->m_3DSample, max(playing->m_offscreenOcclusion, muffle));
- const Real gain = 1.0f - (1.0f - settings->m_occlusionVolume) * playing->m_occlusion;
- AIL_set_3D_sample_volume(playing->m_3DSample, getVoiceMixedVolume(playing->m_audioEventRTS, m_sound3DVolume) * gain);
-}
-
-//-------------------------------------------------------------------------------------------------
-/** How much of the full muffle the line from the microphone to pos earns, 0 to 1. */
-Real MilesAudioManager::lookForOcclusion( const Coord3D *pos ) const
-{
- const Real LIFT = 10.0f; // a sound comes off a unit, not out of the ground under it
- const Real STEP = 20.0f; // a sample of the line every cell of the blockers' grid
- const Real MARGIN = 25.0f; // the ground under either end is not a hill between them
- const Int MAX_SAMPLES = 48;
- ++m_mixCounts.looks;
- // A sound from a building, or a microphone over one, starts on its roof: its own roof is not in the way.
- const Real sourceZ = max(pos->z, getBlockerHeight(pos->x, pos->y)) + LIFT;
- const Real listenerZ = max(m_listenerPosition.z, getBlockerHeight(m_listenerPosition.x, m_listenerPosition.y) + LIFT);
- const Real depth = AudioMixPolicy::rayObstruction(m_listenerPosition.x, m_listenerPosition.y, listenerZ,
- pos->x, pos->y, sourceZ, STEP, MARGIN, MAX_SAMPLES,
- [this]( Real x, Real y ) { return getBlockerHeight( x, y ); });
- return AudioMixPolicy::occlusionAmount(depth, m_audioSettings->m_occlusionDepth);
-}
+ const Real ATTACK_SPEED = 220.0f; // over the 180 it cruises at, under the 240 a damaged one attacks at (480 whole)
+ const Real REACH = 600.0f;
+ const Real LEVEL = 0.5f; // at EA's own volume a pass overhead pinned the limiter for nearly two seconds
+ const UnsignedInt AFTER_FRAMES = LOGICFRAMES_PER_SECOND * 3 / 2;
+ const UnsignedInt BETWEEN_FRAMES = LOGICFRAMES_PER_SECOND * 3;
-//-------------------------------------------------------------------------------------------------
-static const Real BLOCKER_CELL = 20.0f;
-static const Real NO_ROOF = -100000.0f;
+ const UnsignedInt frame = TheGameLogic->getFrame();
+ if (playing->m_velocity.length() >= ATTACK_SPEED) {
+ playing->m_supersonicAt = frame > 0 ? frame : 1;
+ }
+ Coord3D toMicrophone = *pos;
+ toMicrophone.sub(&m_listenerPosition);
+ const Real distance = toMicrophone.length();
+ const Bool passed = playing->m_passClosing && distance > playing->m_passDistance;
+ playing->m_passClosing = distance < playing->m_passDistance;
+ playing->m_passDistance = distance;
-/** The ground, or the roof over it where a building stands. */
-Real MilesAudioManager::getBlockerHeight( Real x, Real y ) const
-{
- const Real ground = TheTerrainLogic->getGroundHeight( x, y );
- if (m_blockers.empty()) {
- return ground;
+ const Real reach = REACH * getRangeScale();
+ if (!passed || distance >= reach || playing->m_supersonicAt == 0 || frame > playing->m_supersonicAt + AFTER_FRAMES
+ || (m_boomedAt != 0 && frame >= m_boomedAt && frame < m_boomedAt + BETWEEN_FRAMES)) {
+ return;
}
- Region3D extent;
- TheTerrainLogic->getExtent(&extent);
- const Int column = (Int)floorf((x - extent.lo.x) / BLOCKER_CELL);
- const Int row = (Int)floorf((y - extent.lo.y) / BLOCKER_CELL);
- if (column < 0 || row < 0 || column >= m_blockerColumns || row >= m_blockerRows) {
- return ground;
+ const AudioEventInfo *info = findAudioEventInfo("Cin_SonicBoom");
+ if (info == NULL) { // a mod's own audio data need not have it
+ return;
}
- return max(ground, m_blockers[row * m_blockerColumns + column]);
+ AudioEventRTS boom("Cin_SonicBoom");
+ getInfoForAudioEvent(&boom);
+ boom.setVolume(LEVEL * info->m_volume * sqrtf(1.0f - distance / reach));
+ addAudioEvent(&boom);
+ m_boomedAt = frame > 0 ? frame : 1;
+ DEBUG_LOG(("AUDIO: sonic boom, Aurora at %.0f units flying %.0f a second, volume %.2f, frame %u\n",
+ distance, playing->m_velocity.length(), boom.getVolume(), frame));
}
//-------------------------------------------------------------------------------------------------
-/** The roofs, once a second of logic time: every structure the client draws, over the cells its
- * footprint covers, at its top. Bridges are left out (a sound under one is not behind it), and so is
- * a building the local player has never seen, whose muffle would give it away. */
-void MilesAudioManager::buildBlockers( void )
+/** The low pass and the volume of a 3D sound: EA's off-screen low pass, and the sliders' volume. */
+void MilesAudioManager::applyOcclusion( PlayingAudio *playing )
{
- const UnsignedInt frame = TheGameLogic->getFrame();
- if (m_audioSettings->m_occlusionStrength <= 0.0f
- || (!m_blockers.empty() && frame >= m_blockersBuiltAt && frame < m_blockersBuiltAt + LOGICFRAMES_PER_SECOND)) {
- return;
- }
- m_blockersBuiltAt = frame;
-
- Region3D extent;
- TheTerrainLogic->getExtent(&extent);
- m_blockerColumns = (Int)ceilf(extent.width() / BLOCKER_CELL);
- m_blockerRows = (Int)ceilf(extent.height() / BLOCKER_CELL);
- m_blockers.assign((size_t)(m_blockerColumns * m_blockerRows), NO_ROOF);
-
- const Int playerIndex = TheObserverCamera.getShroudPlayerIndex();
- for (Drawable *draw = TheGameClient->firstDrawable(); draw; draw = draw->getNextDrawable())
- {
- const ThingTemplate *thing = draw->getTemplate();
- if (!thing->isKindOf(KINDOF_STRUCTURE) || thing->isKindOf(KINDOF_BRIDGE) || thing->isKindOf(KINDOF_BRIDGE_TOWER)) {
- continue;
- }
- const Coord3D *pos = draw->getPosition();
- if (ThePartitionManager->getShroudStatusForPlayer(playerIndex, pos) == CELLSHROUD_SHROUDED) {
- continue;
- }
- const GeometryInfo &geometry = thing->getTemplateGeometryInfo();
- const Real roof = pos->z + geometry.getMaxHeightAbovePosition();
- const Real reach = geometry.getBoundingCircleRadius();
- const Real angle = draw->getOrientation();
- const Real c = cosf(angle);
- const Real s = sinf(angle);
- const Int firstColumn = max(0, (Int)floorf((pos->x - reach - extent.lo.x) / BLOCKER_CELL));
- const Int lastColumn = min(m_blockerColumns - 1, (Int)floorf((pos->x + reach - extent.lo.x) / BLOCKER_CELL));
- const Int firstRow = max(0, (Int)floorf((pos->y - reach - extent.lo.y) / BLOCKER_CELL));
- const Int lastRow = min(m_blockerRows - 1, (Int)floorf((pos->y + reach - extent.lo.y) / BLOCKER_CELL));
- for (Int row = firstRow; row <= lastRow; ++row)
- {
- for (Int column = firstColumn; column <= lastColumn; ++column)
- {
- // the cell's centre, in the building's own frame
- const Real dx = extent.lo.x + (column + 0.5f) * BLOCKER_CELL - pos->x;
- const Real dy = extent.lo.y + (row + 0.5f) * BLOCKER_CELL - pos->y;
- const Bool inside = geometry.getGeomType() == GEOMETRY_BOX
- ? fabsf(dx * c + dy * s) <= geometry.getMajorRadius() && fabsf(-dx * s + dy * c) <= geometry.getMinorRadius()
- : dx * dx + dy * dy <= geometry.getMajorRadius() * geometry.getMajorRadius();
- Real &cell = m_blockers[row * m_blockerColumns + column];
- if (inside && roof > cell) {
- cell = roof;
- }
- }
- }
- }
+ AIL_set_3D_sample_occlusion(playing->m_3DSample, playing->m_offscreenOcclusion);
+ AIL_set_3D_sample_volume(playing->m_3DSample, getVoiceMixedVolume(playing->m_audioEventRTS, m_sound3DVolume));
}
//-------------------------------------------------------------------------------------------------
-/** The processing v3.4.0 put between a sound and the speakers, as AudioSettings.ini gives it (`from`)
+/** The processing the fork puts 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_speedOfSound = from ? from->m_speedOfSound : 0.0f; // doppler
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;
@@ -3571,9 +3415,8 @@ static void setSoundProcessing( AudioSettings *to, const AudioSettings *from )
//-------------------------------------------------------------------------------------------------
/** 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). */
+ * Taken up the pass after the option changes. The bed is chosen again from the map on this same
+ * pass (chooseAmbienceBed), the one playing now stopped. */
void MilesAudioManager::applyLegacySound( void )
{
if (m_legacySound == TheGlobalData->m_legacySound)
@@ -3581,29 +3424,23 @@ void MilesAudioManager::applyLegacySound( void )
m_legacySound = TheGlobalData->m_legacySound;
setSoundProcessing( m_audioSettings, m_legacySound ? NULL : &m_engineSettings );
AIL_ex_set_limiter( !m_legacySound );
- m_roomAbsorption = m_audioSettings->m_airAbsorptionDistance;
- m_airScale = 0.0f;
+ AIL_ex_set_3D_air( m_audioSettings->m_speedOfSound );
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
- * a third to a full percent of it. The shipped maps measured that way run from about 0.1% (Twilight
- * Flame, Tournament Tundra) to near 3% (Tournament Urban, El Scorcho), and the room goes from open
- * ground at 0.3%, a loud late slap and a long thin tail, to a town at 1.9%, a strong early echo off
- * the walls and a brighter tail. Snow leaves a third of the send, no echo, a short dead tail and
- * air that takes the top end off sooner. The object list is the map file's, which the terrain
- * keeps until the next map, so nothing in logic is asked. */
-void MilesAudioManager::setRoomFromMap( void )
+ m_bedMap.clear();
+ DEBUG_LOG(("AUDIO: legacy sound %s: doppler %.1f, budget %d, folding %.0f, replies %d, zoom mix %.2f, limiter %s\n",
+ m_legacySound ? "on" : "off", m_audioSettings->m_dopplerScale, m_audioSettings->m_battleVoiceBudget,
+ m_audioSettings->m_coalesceRadius, m_audioSettings->m_replyMaxVoices, m_audioSettings->m_zoomMixDetailVolume,
+ m_legacySound ? "off" : "on"));
+}
+
+//-------------------------------------------------------------------------------------------------
+/** The map's ambience bed, from the map itself: how much of its playable ground the placed structures
+ * cover, supply docks left out, being on every map at a third to a full percent of it, and the
+ * ground it is painted with. The shipped maps run from about 0.1% built over (Twilight Flame,
+ * Tournament Tundra) to near 3% (Tournament Urban, El Scorcho). The object list is the map file's,
+ * which the terrain keeps until the next map, so nothing in logic is asked. */
+void MilesAudioManager::chooseAmbienceBed( void )
{
Real built = 0.0f;
for (MapObject *mapObject = MapObject::getFirstMapObject(); mapObject; mapObject = mapObject->getNext())
@@ -3621,40 +3458,12 @@ void MilesAudioManager::setRoomFromMap( void )
const Real TOWN_COVER = 0.019f;
Real town = (cover - OPEN_COVER) / (TOWN_COVER - OPEN_COVER);
town = town < 0.0f ? 0.0f : (town > 1.0f ? 1.0f : town);
-
- // Open ground answers late and thin: a ridge's slap a quarter second on, then a long dark tail. A
- // town answers at once off the walls across the street, brighter and stronger.
- Real wet = 0.14f + 0.16f * town;
- Real decay = 2.6f - 0.8f * town;
- Real damping = 0.8f - 0.5f * town;
- Real echo = 0.26f - 0.17f * town;
- Real slap = 1.2f - 0.85f * town;
- Real absorption = m_audioSettings->m_airAbsorptionDistance;
const Bool snowy = TheGlobalData->m_weather == WEATHER_SNOWY;
- if (snowy)
- {
- // snow swallows the echo and the top end, of the sound itself as well as the room's
- const Real SNOW_SEND_SHARE = 0.35f;
- const Real SNOW_DECAY_SECONDS = 0.4f;
- const Real SNOW_AIR_SHARE = 0.6f;
- wet *= SNOW_SEND_SHARE;
- decay = SNOW_DECAY_SECONDS;
- damping = 1.0f;
- echo = 0.0f;
- slap = 0.0f;
- absorption *= SNOW_AIR_SHARE;
- }
- m_roomAbsorption = absorption;
- m_airScale = 0.0f; // update() hands it down with the zoom's range scale
- AIL_ex_set_reverb(wet * m_audioSettings->m_reverbLevel, decay, damping, echo, slap);
- DEBUG_LOG(("AUDIO: room for %s: %.2f%% built over, town %.2f%s, send %.2f, decay %.2f s, damping %.2f, "
- "echo %d ms at %.2f, air %.0f\n", m_roomMap.str(), cover * 100.0f, town, snowy ? " in snow" : "",
- wet * m_audioSettings->m_reverbLevel, decay, damping, (Int)(echo * 1000.0f), slap, absorption));
-
- // The bed, from the same reading and the ground the map is painted with, sampled on a grid: snow
- // (the weather, or snow on most of the ground that is not plain dirt and rock), a town (half way to
- // the room's town or more, or streets and houses painted on a quarter of it), else desert or field,
- // whichever of the two covers more. The shell map behind the menus keeps quiet.
+
+ // That reading and the ground the map is painted with, sampled on a grid: snow (the weather, or
+ // snow on most of the ground that is not plain dirt and rock), a town (half way to a town's cover
+ // or more, or streets and houses painted on a quarter of it), else desert or field, whichever of
+ // the two covers more. The shell map behind the menus keeps quiet.
const Int GRID = 24;
Int desert = 0, field = 0, snow = 0, urban = 0, counted = 0;
for (Int i = 0; i < GRID; ++i)
@@ -3720,7 +3529,7 @@ void MilesAudioManager::setRoomFromMap( void )
m_bedHandle = AHSV_Error;
m_bedStartedAt = 0;
DEBUG_LOG(("AUDIO: ambience bed for %s: %s (%d desert, %d field, %d snow, %d town of %d samples), %s\n",
- m_roomMap.str(), kind, desert, field, snow, urban, counted, m_bedEvent.isEmpty() ? "none" : m_bedEvent.str()));
+ m_bedMap.str(), kind, desert, field, snow, urban, counted, m_bedEvent.isEmpty() ? "none" : m_bedEvent.str()));
}
//-------------------------------------------------------------------------------------------------
@@ -3763,45 +3572,6 @@ void MilesAudioManager::updateAmbienceBed( void )
}
}
-//-------------------------------------------------------------------------------------------------
-/** A big blast (DuckSounds) dips everything else for DuckTime, down to DuckVolume, as far as the blast
- * is loud at the microphone: by the square root of its distance gain, so a nuke across the map
- * still leans on the mix and one out of its range does nothing. Asked when the blast starts, so a
- * far one ducks when it is heard rather than when it is seen; a loop that ducks does so once. */
-void MilesAudioManager::duckForBlast( AudioEventRTS *event, H3DSAMPLE sample3D )
-{
- const AudioSettings *settings = m_audioSettings;
- if (settings->m_duckVolume >= 1.0f
- || std::find(settings->m_duckSounds.begin(), settings->m_duckSounds.end(), event->getEventName()) == settings->m_duckSounds.end())
- return;
-
- const AudioEventInfo *info = event->getAudioEventInfo();
- const Bool global = BitTest(info->m_type, ST_GLOBAL);
- Coord3D toMicrophone = *getCurrentPositionFromEvent(event);
- toMicrophone.sub(&m_listenerPosition);
- const Real distance = toMicrophone.length();
- const Real nearness = sqrtf(AIL_ex_3D_distance_gain(distance,
- (global ? (Real)settings->m_globalMinRange : info->m_minDistance) * getRangeScale(),
- (global ? (Real)settings->m_globalMaxRange : info->m_maxDistance) * getRangeScale(), settings->m_rangeVolumeFade));
- if (nearness <= 0.0f)
- {
- DEBUG_LOG(("AUDIO: duck by %s at %.0f units: out of earshot, none\n", event->getEventName().str(), distance));
- return;
- }
- const Real gain = 1.0f - (1.0f - settings->m_duckVolume) * nearness;
- const Real seconds = settings->m_duckTime / MSEC_PER_SECOND;
- AIL_ex_duck(sample3D, gain, seconds);
- // AIL_ex_duck_gain's shape: down by 0.05 s, held to a quarter of the time, back to full at its end
- const Real DUCK_ATTACK_SECONDS = 0.05f;
- const Real heldTo = 0.25f * seconds > DUCK_ATTACK_SECONDS ? 0.25f * seconds : DUCK_ATTACK_SECONDS;
- const Real halfway = 0.5f * (heldTo + seconds);
- const Real halfwayGain = AIL_ex_duck_gain(halfway, gain, seconds);
- DEBUG_LOG(("AUDIO: duck by %s at %.0f units, nearness %.2f: the rest at %.2f (%.1f dB) muffled to %.0f Hz, "
- "held to %.2f s, at %.2f s %.2f and %.0f Hz, full at %.2f s, frame %u\n",
- event->getEventName().str(), distance, nearness, gain, 20.0f * log10f(gain), AIL_ex_duck_cutoff(gain),
- heldTo, halfway, halfwayGain, AIL_ex_duck_cutoff(halfwayGain), seconds, TheGameLogic->getFrame()));
-}
-
//-------------------------------------------------------------------------------------------------
Bool MilesAudioManager::checkForSample( AudioRequest *req )
{
@@ -4128,7 +3898,7 @@ void *MilesAudioManager::playSample3D( PlayingAudio *audio )
void *fileBuffer = loadFileForRead(event);
if (fileBuffer) {
AIL_set_3D_sample_file(sample3D, fileBuffer);
- // a unit's reply is the radio in the commander's ear: no air, no doppler, no room
+ // a unit's reply is the radio in the commander's ear: no doppler
AIL_ex_set_3D_sample_dry(sample3D, BitTest(event->getAudioEventInfo()->m_type, ST_VOICE));
// Prep any sort of filtering, etc, here
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/Miles6/.gitignore b/GeneralsMD/Code/Libraries/Source/WWVegas/Miles6/.gitignore
index b6b717a1e..2c4a2296d 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/Miles6/.gitignore
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/Miles6/.gitignore
@@ -14,8 +14,6 @@
!include/MSS/MSS.h
# mss_ex_pcm.h: miniaudio's pushed-PCM voice for the movies (V1), declared beside it.
!include/MSS/mss_ex_pcm.h
-# mss_ex_room.h: the room both backends play, so the two cannot drift.
-!include/MSS/mss_ex_room.h
# Windows links both backends: each under its own prefix (mss_backend_names.h), miles_dispatch.cpp
# owning the plain names.
!include/MSS/mss_backend_names.h
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 f7535a4a0..4c7b25309 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/Miles6/include/MSS/MSS.h
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/Miles6/include/MSS/MSS.h
@@ -296,29 +296,16 @@ void AILCALL AIL_ex_set_3D_linear_falloff(S32 linear);
/* Not Miles. What MilesAudioManager hands down from AudioSettings.ini and the map.
*
* AIL_ex_set_3D_air: the speed of sound in game units a second, for doppler on the velocity
- * AIL_set_3D_velocity_vector gives a 3D sample (units a second as well), and the distance
- * AIL_ex_3D_cutoff takes for air absorption. Zero switches either off; both start off.
- *
- * AIL_ex_set_reverb: the one room every 3D sample sends to. wet is the send of a sample at full
- * volume (zero takes the room away), decay the seconds its tail takes to fall 60 dB, damping (0 to 1)
- * how much sooner the top end dies, echo the seconds before the first reflection comes back, and
- * slap that reflection's level against the send: the wall across a street, or a ridge far off.
- *
- * AIL_ex_duck: everything but the trigger, and any earlier trigger still sounding, dips to gain and
- * comes back over seconds, AIL_ex_duck_gain's shape, and the other 3D samples are muffled with it
- * (AIL_ex_duck_cutoff). miniaudio counts that time in frames mixed, so a -wav run ducks on the
- * picture's clock; XAudio2 counts it on the wall clock it plays on. The movies' voice
- * (mss_ex_pcm.h) is never ducked.
+ * AIL_set_3D_velocity_vector gives a 3D sample (units a second as well). Zero, where it starts,
+ * switches it off.
*
* Both backends hold the mix under AIL_EX_LIMITER_CEILING with the same limiter (AIL_ex_limit), so
* 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. */
-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);
+ * AIL_ex_set_3D_sample_dry: a 3D sample that takes no doppler, only its distance gain, pan and
+ * occlusion; a unit's reply stays clean. Set on each play; a fresh handle is wet. */
+void AILCALL AIL_ex_set_3D_air(F32 speed_of_sound);
void AILCALL AIL_ex_set_3D_sample_dry(H3DSAMPLE handle, S32 dry);
void AILCALL AIL_ex_set_limiter(S32 on);
@@ -370,22 +357,13 @@ static inline F32 AIL_ex_3D_distance_gain(F32 distance, F32 min_dist, F32 max_di
at the output rate, which is where XAudio2 runs a source voice's filter. */
#define AIL_EX_OPEN_CUTOFF 20000.0f
-/* The cutoff in Hz. Air takes the top off with distance: 20 kHz close, half that at
- absorption_distance and falling with the square of the distance past it, so a blast across the map
- is a rumble. Occlusion is EA's LowPassCutoff, which MilesAudioManager hands down as 1 - cutoff for
- a sound off screen; it used to be a cut in volume and is a ceiling now, 20 kHz times (1 - occlusion)
- squared: 5 kHz for the shipped 50%. Both backends run the cutoff through two one-pole stages, 12 dB
- an octave, steep enough to take the crack off a blast that is mostly bass. */
-static inline F32 AIL_ex_3D_cutoff(F32 distance, F32 absorption_distance, F32 occlusion)
+/* The cutoff in Hz. Occlusion is EA's LowPassCutoff, which MilesAudioManager hands down as 1 - cutoff
+ for a sound off screen: 20 kHz times (1 - occlusion) squared, 5 kHz for the shipped 50%, and open
+ for anything on screen. Both backends run the cutoff through two one-pole stages, 12 dB an octave. */
+static inline F32 AIL_ex_3D_cutoff(F32 occlusion)
{
- F32 cutoff = AIL_EX_OPEN_CUTOFF;
- if (absorption_distance > 0.0f) {
- const F32 ratio = distance / absorption_distance;
- cutoff /= 1.0f + ratio * ratio;
- }
const F32 open = 1.0f - occlusion;
- const F32 ceiling = AIL_EX_OPEN_CUTOFF * open * open;
- return cutoff < ceiling ? cutoff : ceiling;
+ return AIL_EX_OPEN_CUTOFF * open * open;
}
/* y += a * (x - y) for a cutoff at a rate: XAudio2CutoffFrequencyToOnePoleCoefficient, held at 1 (no
@@ -414,35 +392,6 @@ static inline F32 AIL_ex_doppler_ratio(F32 dx, F32 dy, F32 dz, F32 vx, F32 vy, F
return speed_of_sound / (speed_of_sound - approach);
}
-/* The send into the room: the dry sound falls with the distance gain, the room's share only with its
- square root, so a far sound is mostly room, and nothing reaches it past the maximum distance. */
-static inline F32 AIL_ex_3D_send(F32 volume, F32 attenuation, F32 wet)
-{
- return volume * wet * sqrtf(attenuation);
-}
-
-/* The duck's gain `elapsed` seconds after it began: down to `gain` over 50 ms, held for a quarter of
- `seconds`, then a straight line back to full by `seconds`. */
-static inline F32 AIL_ex_duck_gain(F32 elapsed, F32 gain, F32 seconds)
-{
- const F32 attack = 0.05f;
- const F32 hold = 0.25f * seconds > attack ? 0.25f * seconds : attack;
- if (elapsed < 0.0f || elapsed >= seconds)
- return 1.0f;
- if (elapsed < attack)
- return 1.0f - (1.0f - gain) * elapsed / attack;
- if (elapsed < hold)
- return gain;
- return gain + (1.0f - gain) * (elapsed - hold) / (seconds - hold);
-}
-
-/* The muffle a duck puts on the other 3D samples, a cutoff falling with the square of the duck's
- gain: a duck to 15% is a 450 Hz ceiling, one to 70% still 10 kHz, and the duck's end opens it. */
-static inline F32 AIL_ex_duck_cutoff(F32 duck)
-{
- return AIL_EX_OPEN_CUTOFF * duck * duck;
-}
-
/* Where (dx, dy, dz) lies round the listener, in the plane of its face and right (up x face) axes,
which is the plane the camera turns in: side -1 full left to 1 full right, front 1 ahead to -1
behind, side^2 + front^2 = 1. A sound straight above or below the listener is ahead. Headphones
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 e7ee079db..b4f046b6f 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
@@ -84,8 +84,6 @@
#define AIL_ex_capture_length MSS_BACKEND_NAME(AIL_ex_capture_length)
#define AIL_ex_set_3D_linear_falloff MSS_BACKEND_NAME(AIL_ex_set_3D_linear_falloff)
#define AIL_ex_set_3D_air MSS_BACKEND_NAME(AIL_ex_set_3D_air)
-#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)
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/Miles6/include/MSS/mss_ex_room.h b/GeneralsMD/Code/Libraries/Source/WWVegas/Miles6/include/MSS/mss_ex_room.h
deleted file mode 100644
index 027110991..000000000
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/Miles6/include/MSS/mss_ex_room.h
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * The room (AIL_ex_set_reverb): the reverb every 3D sample sends to, shared by both backends so that
- * what a player hears on Windows and what a -wav run records are the same room.
- *
- * Not Miles. A small reverb of Freeverb's shape, cut to four combs and two all-passes a side. The
- * send goes through the echo first, a delay that is also heard once on its own (a street of
- * buildings answering), then into the combs, damped in their feedback, and out through the
- * all-passes that smear them. Mono in, stereo out; the right side's lines are 23 samples longer
- * than the left's, Freeverb's spread, for width.
- *
- * XAudio2's own reverb was the Windows room until 2026-10-25, through an I3DL2 mapping of these
- * five numbers. Driven offline against this one it answered an impulse 12 dB quieter on open
- * ground, 20 dB in a town and 31 dB in snow, with the top end of its tail 19 dB further down, so a
- * player heard next to no room at all; and it takes 20 to 48 kHz only, so a device at 96 kHz had
- * none. miles_xaudio2 runs this as an effect on its room submix instead.
- *
- * C++ only: the two backends are. The caller keeps it to one thread at a time.
- */
-
-#ifndef MSS_EX_ROOM_H
-#define MSS_EX_ROOM_H
-
-#include <math.h>
-#include <stddef.h>
-#include <vector>
-
-const unsigned ROOM_COMBS = 4;
-const unsigned ROOM_ALLPASSES = 2;
-const unsigned ROOM_COMB_LENGTHS[ROOM_COMBS] = { 1116, 1188, 1277, 1356 }; // Freeverb's, at 44.1 kHz
-const unsigned ROOM_ALLPASS_LENGTHS[ROOM_ALLPASSES] = { 556, 441 };
-const unsigned ROOM_STEREO_SPREAD = 23;
-const unsigned ROOM_OUTPUT_CHANNELS = 2;
-const float ROOM_TUNING_RATE = 44100.0f;
-const float ROOM_ALLPASS_FEEDBACK = 0.5f;
-const float ROOM_INPUT_GAIN = 0.25f; // four combs at a second-long decay answer at about the send's level
-const float ROOM_MAX_DAMPING = 0.7f;
-const float ROOM_MAX_ECHO_SECONDS = 0.3f; // the longest echo MilesAudioManager asks for is 0.26
-const float ROOM_DENORMAL_GUARD = 1e-18f; // keeps a dying tail out of the denormals, which x64 does slowly
-
-struct DelayLine
-{
- DelayLine() : at(0), feedback(0.0f), store(0.0f) {}
-
- std::vector<float> line;
- size_t at;
- float feedback;
- float store; // a comb's damping filter
-};
-
-struct Room
-{
- Room() : ready(false), rate(0), damping(0.0f), slap(0.0f), echoLength(0) {}
-
- bool ready;
- unsigned rate;
- float damping;
- float slap; // the echo's own level, AIL_ex_set_reverb
- DelayLine echo;
- size_t echoLength;
- DelayLine combs[2][ROOM_COMBS];
- DelayLine allpasses[2][ROOM_ALLPASSES];
-};
-
-inline void initRoom(Room *room, unsigned rate)
-{
- const float scale = (float)rate / ROOM_TUNING_RATE;
- for (unsigned side = 0; side < 2; ++side) {
- for (unsigned i = 0; i < ROOM_COMBS; ++i) {
- room->combs[side][i].line.assign((size_t)((ROOM_COMB_LENGTHS[i] + side * ROOM_STEREO_SPREAD) * scale), 0.0f);
- }
- for (unsigned i = 0; i < ROOM_ALLPASSES; ++i) {
- room->allpasses[side][i].line.assign((size_t)((ROOM_ALLPASS_LENGTHS[i] + side * ROOM_STEREO_SPREAD) * scale), 0.0f);
- }
- }
- room->echo.line.assign((size_t)(ROOM_MAX_ECHO_SECONDS * rate) + 1, 0.0f);
- room->rate = rate;
- room->ready = true;
-}
-
-inline void setRoom(Room *room, float decay, float damping, float echo, float slap)
-{
- if (!room->ready) {
- return;
- }
- // each comb loses 60 dB in `decay` seconds: a gain per trip of 0.001 to the power of trips that long
- for (unsigned side = 0; side < 2; ++side) {
- for (unsigned i = 0; i < ROOM_COMBS; ++i) {
- DelayLine &comb = room->combs[side][i];
- comb.feedback = powf(0.001f, (float)comb.line.size() / (decay * (float)room->rate));
- }
- }
- room->damping = damping * ROOM_MAX_DAMPING;
- room->slap = slap;
- const size_t echoLength = echo > 0.0f ? (size_t)(echo * (float)room->rate) : 0;
- room->echoLength = echoLength < room->echo.line.size() ? echoLength : room->echo.line.size() - 1;
- room->echo.at = room->echoLength > 0 ? room->echo.at % room->echoLength : 0;
-}
-
-// Adds the room's answer to `input` (mono, the sends of one mix pass) into the stereo `output`.
-inline void processRoom(Room *room, const float *input, float *output, unsigned frames)
-{
- for (unsigned frame = 0; frame < frames; ++frame) {
- float in = input[frame];
- float echoed = 0.0f;
- if (room->echoLength > 0) {
- DelayLine &echo = room->echo;
- echoed = echo.line[echo.at];
- echo.line[echo.at] = in;
- echo.at = (echo.at + 1) % room->echoLength;
- in = echoed;
- }
- for (unsigned side = 0; side < 2; ++side) {
- float sum = 0.0f;
- for (unsigned i = 0; i < ROOM_COMBS; ++i) {
- DelayLine &comb = room->combs[side][i];
- const float out = comb.line[comb.at];
- comb.store = out + room->damping * (comb.store - out);
- comb.line[comb.at] = in * ROOM_INPUT_GAIN + comb.store * comb.feedback + ROOM_DENORMAL_GUARD;
- comb.at = (comb.at + 1) % comb.line.size();
- sum += out;
- }
- for (unsigned i = 0; i < ROOM_ALLPASSES; ++i) {
- DelayLine &pass = room->allpasses[side][i];
- const float held = pass.line[pass.at];
- pass.line[pass.at] = sum + held * ROOM_ALLPASS_FEEDBACK;
- pass.at = (pass.at + 1) % pass.line.size();
- sum = held - sum;
- }
- output[frame * ROOM_OUTPUT_CHANNELS + side] += sum + echoed * room->slap;
- }
- }
-}
-
-#endif /* MSS_EX_ROOM_H */
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/Miles6/miles_dispatch.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/Miles6/miles_dispatch.cpp
index 9f540f8e1..7f93ef976 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/Miles6/miles_dispatch.cpp
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/Miles6/miles_dispatch.cpp
@@ -83,9 +83,7 @@
MSS_API(S32, AIL_ex_start_capture, (const char *pathname), (pathname)) \
MSS_API(void, AIL_ex_stop_capture, (void), ()) \
MSS_API(void, AIL_ex_set_3D_linear_falloff, (S32 linear), (linear)) \
- MSS_API(void, AIL_ex_set_3D_air, (F32 speed_of_sound, F32 absorption_distance), (speed_of_sound, absorption_distance)) \
- 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_air, (F32 speed_of_sound), (speed_of_sound)) \
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)) \
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 f08e73292..f8348b87c 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/Miles6/miniaudio/miles_miniaudio.cpp
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/Miles6/miniaudio/miles_miniaudio.cpp
@@ -32,11 +32,10 @@
* HSTREAM / HAUDIO -> a file decoded by miniaudio through the game's own file callbacks, into
* ~200ms chunks the service thread keeps four ahead of the mixer.
* 3D positioning -> the same distance attenuation and stereo pan miles_xaudio2 computes,
- * not miniaudio's spatializer. The air, room and duck of MSS.h too, by the
- * same helpers: a one-pole low-pass where XAudio2 sets the voice's filter,
- * the resampler's rate for doppler, and the room of MSS/mss_ex_room.h,
- * which miles_xaudio2 runs as an effect on a submix.
- * the mix -> done here, in miniaudio's device callback, so that the output matrix is
+ * not miniaudio's spatializer. By the same helpers of MSS.h: a one-pole
+ * low-pass where XAudio2 sets the voice's filter, and the resampler's rate
+ * for doppler.
+ * the mix -> done here, in miniaudio's device callback, so that the output matrix is
* exactly XAudio2's: every source channel summed into left and right at
* the pan's two gains.
* EOS callbacks -> the service thread notices a voice run dry and calls back from there,
@@ -70,7 +69,6 @@
#include "MSS/MSS.h"
#include "MSS/mss_ex_pcm.h"
-#include "MSS/mss_ex_room.h" // the room (AIL_ex_set_reverb), miles_xaudio2's as well; under mixLock here
#ifndef WAVE_FORMAT_IMA_ADPCM
#define WAVE_FORMAT_IMA_ADPCM 0x0011
@@ -306,7 +304,7 @@ const float LOW_PASS_DENORMAL_GUARD = 1e-18f; // a filter left ringing on silenc
struct VoiceMix
{
VoiceMix() : resamplerReady(false), channels(0), gainLeft(0.0f), gainRight(0.0f), lowPass(1.0f), lowPassState(0.0f),
- lowPassSecond(0.0f), roomSend(0.0f), passThrough(false), headphones(false), pending(0), pendingAt(0)
+ lowPassSecond(0.0f), passThrough(false), headphones(false), pending(0), pendingAt(0)
{
AIL_ex_hrtf_reset(&head);
}
@@ -316,12 +314,11 @@ struct VoiceMix
unsigned channels;
float gainLeft;
float gainRight;
- // A 3D sample's air and occlusion, XAudio2's LowPassOnePoleFilter on the resampled sum, y += a(x - y),
- // a = 1 passing it untouched, and again after it as XAudio2's output filter. And its share into the room.
+ // A 3D sample's occlusion, XAudio2's LowPassOnePoleFilter on the resampled sum, y += a(x - y),
+ // a = 1 passing it untouched, and again after it as XAudio2's output filter.
float lowPass;
float lowPassState;
float lowPassSecond;
- float roomSend;
// An XAudio2 voice with the default matrix rather than a panned Miles one: left to left and right
// to right (a mono source to both), each at its gain. The movies' voice (mss_ex_pcm.h).
bool passThrough;
@@ -379,17 +376,13 @@ void resetResampler(VoiceMix *mix)
// Fills up to maxFrames of float source frames. Returns how many it gave; 0 means the source is dry.
typedef unsigned (*SourceRead)(void *source, float *out, unsigned maxFrames);
-// Mixes up to `frames` output frames of one voice into `output`, at `duck` (AIL_ex_duck) on top of its
-// gains with `muffle` (the duck's low-pass coefficient, 1 for none) as a ceiling on its own, and its
-// send into `room` when there is one. Returns true once the source is dry and nothing is left in
-// flight, which is XAudio2's BuffersQueued == 0.
-bool mixVoice(VoiceMix *mix, SourceRead read, void *source, float *output, unsigned frames, bool *sourceDry,
- float duck, float muffle, float *room)
-{
- const float left = mix->gainLeft * duck;
- const float right = mix->gainRight * duck;
- const float send = mix->roomSend * duck;
- const float lowPass = mix->lowPass < muffle ? mix->lowPass : muffle;
+// Mixes up to `frames` output frames of one voice into `output`. Returns true once the source is dry
+// and nothing is left in flight, which is XAudio2's BuffersQueued == 0.
+bool mixVoice(VoiceMix *mix, SourceRead read, void *source, float *output, unsigned frames, bool *sourceDry)
+{
+ const float left = mix->gainLeft;
+ const float right = mix->gainRight;
+ const float lowPass = mix->lowPass;
float resampled[MIX_CHUNK_FRAMES * 2];
float heard[MIX_CHUNK_FRAMES];
float ears[MIX_CHUNK_FRAMES * 2];
@@ -433,9 +426,6 @@ bool mixVoice(VoiceMix *mix, SourceRead read, void *source, float *output, unsig
output[(done + frame) * OUTPUT_CHANNELS + 0] += left * sum;
output[(done + frame) * OUTPUT_CHANNELS + 1] += right * sum;
}
- if (room != NULL) {
- room[done + frame] += send * sum;
- }
}
if (!mix->passThrough && mix->headphones) {
AIL_ex_hrtf_process(&mix->head, &mix->ears, heard, ears, (S32)outFrames);
@@ -480,13 +470,11 @@ struct Sample
float velocityX, velocityY, velocityZ; // units a second, AIL_set_3D_velocity_vector
// What the mix sees, under mixLock. `running` is the voice started, `queued` its one buffer
- // still in it, `cursor` the next source frame. `unducked`: it started a duck, which leaves it
- // alone until the duck is over or the sample stops.
+ // still in it, `cursor` the next source frame.
bool running;
bool queued;
unsigned int cursor;
bool sourceDry;
- bool unducked;
bool dry; // AIL_ex_set_3D_sample_dry
VoiceMix mix;
};
@@ -561,8 +549,7 @@ struct Capture
struct Engine
{
Engine() : contextReady(false), deviceReady(false), serviceRunning(false), started(false), deviceRate(0),
- capture(NULL), duckActive(false), duckFrames(0), duckGain(1.0f), duckSeconds(0.0f), offline(false),
- mixAnchored(false), mixedFrames(0), capturedFrames(0), capturedRate(0) {}
+ capture(NULL), offline(false), mixAnchored(false), mixedFrames(0), capturedFrames(0), capturedRate(0) {}
// A process can end without AIL_shutdown - a test, or a game that exits in a hurry - and a
// std::thread still joinable at destruction calls std::terminate. The Windows build's service
@@ -599,15 +586,7 @@ struct Engine
unsigned deviceRate;
Capture *capture;
- // Under mixLock: the room and one mix pass's sends into it, and AIL_ex_duck, timed in frames
- // mixed so that a -wav run ducks on the logic clock.
- Room room;
- std::vector<float> roomInput;
- AIL_EX_LIMITER limiter; // the last thing the mix goes through, MSS.h's
- bool duckActive;
- long long duckFrames;
- float duckGain;
- float duckSeconds;
+ AIL_EX_LIMITER limiter; // the last thing the mix goes through, MSS.h's; under mixLock
// AIL_ex_offline_mix: the device is opened on the null backend and never started, and the mix
// moves only through AIL_ex_mix_to_frame. mixedFrames is where the logic clock has it, in output
@@ -623,8 +602,6 @@ struct Engine
Engine g_engine;
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.
@@ -662,7 +639,6 @@ struct Spatial
float volume;
float pan;
float cutoff; // Hz, AIL_ex_3D_cutoff
- float send; // into the room, AIL_ex_3D_send
float doppler; // pitch ratio, AIL_ex_doppler_ratio
};
@@ -692,15 +668,8 @@ Spatial computeSpatial(const Sample &sample)
Spatial spatial;
spatial.volume = clampUnit(sample.volume) * attenuation;
spatial.pan = pan;
- if (sample.dry) {
- spatial.cutoff = AIL_ex_3D_cutoff(distance, 0.0f, sample.occlusion);
- spatial.send = 0.0f;
- spatial.doppler = 1.0f;
- return spatial;
- }
- spatial.cutoff = AIL_ex_3D_cutoff(distance, g_absorptionDistance.load(), sample.occlusion);
- spatial.send = AIL_ex_3D_send(clampUnit(sample.volume), attenuation, g_roomSend.load());
- spatial.doppler = AIL_ex_doppler_ratio(dx, dy, dz, sample.velocityX, sample.velocityY, sample.velocityZ, g_speedOfSound.load());
+ spatial.cutoff = AIL_ex_3D_cutoff(sample.occlusion);
+ spatial.doppler = sample.dry ? 1.0f : AIL_ex_doppler_ratio(dx, dy, dz, sample.velocityX, sample.velocityY, sample.velocityZ, g_speedOfSound.load());
return spatial;
}
@@ -715,7 +684,6 @@ void refreshSampleOutput(Sample *sample)
float pan = sample->pan;
float doppler = 1.0f;
float lowPass = 1.0f;
- float send = 0.0f;
const bool headphones = sample->is3D && g_headphones;
AIL_EX_HRTF_TARGET ears = {};
if (sample->is3D) {
@@ -724,7 +692,6 @@ void refreshSampleOutput(Sample *sample)
pan = spatial.pan;
doppler = spatial.doppler;
lowPass = AIL_ex_one_pole_coefficient(spatial.cutoff, (float)g_engine.deviceRate);
- send = spatial.send;
}
if (headphones) {
const Listener &listener = g_engine.listener;
@@ -756,7 +723,6 @@ void refreshSampleOutput(Sample *sample)
}
sample->mix.headphones = headphones;
sample->mix.lowPass = lowPass;
- sample->mix.roomSend = send;
setResampleRate(&sample->mix, (float)sample->baseRate * ratio, g_engine.deviceRate);
}
@@ -1182,35 +1148,12 @@ void dataCallback(ma_device *, void *output, const void *, ma_uint32 frameCount)
std::lock_guard<std::mutex> mixGuard(g_engine.mixLock);
- // One gain for the whole pass: a pass is ~10 ms and the duck moves over seconds.
- float duck = 1.0f;
- if (g_engine.duckActive) {
- const float elapsed = (float)g_engine.duckFrames / (float)g_engine.deviceRate;
- duck = AIL_ex_duck_gain(elapsed, g_engine.duckGain, g_engine.duckSeconds);
- g_engine.duckFrames += frameCount;
- if (elapsed >= g_engine.duckSeconds) {
- g_engine.duckActive = false;
- for (size_t i = 0; i < g_engine.samples.size(); ++i) {
- g_engine.samples[i]->unducked = false;
- }
- }
- }
-
- if (g_engine.roomInput.size() < frameCount) {
- g_engine.roomInput.resize(frameCount);
- }
- float *room = &g_engine.roomInput[0];
- memset(room, 0, (size_t)frameCount * sizeof(float));
-
- const float muffle = AIL_ex_one_pole_coefficient(AIL_ex_duck_cutoff(duck), (float)g_engine.deviceRate);
for (size_t i = 0; i < g_engine.samples.size(); ++i) {
Sample *sample = g_engine.samples[i];
if (!sample->running || !sample->queued || !sample->mix.resamplerReady) {
continue;
}
- const bool ducked = !sample->unducked;
- if (mixVoice(&sample->mix, readSampleSource, sample, out, frameCount, &sample->sourceDry,
- ducked ? duck : 1.0f, ducked && sample->is3D ? muffle : 1.0f, sample->is3D ? room : NULL)) {
+ if (mixVoice(&sample->mix, readSampleSource, sample, out, frameCount, &sample->sourceDry)) {
sample->queued = false;
}
}
@@ -1221,17 +1164,13 @@ void dataCallback(ma_device *, void *output, const void *, ma_uint32 frameCount)
continue;
}
stream->sourceDry = false;
- mixVoice(&stream->mix, readStreamSource, stream, out, frameCount, &stream->sourceDry, duck, 1.0f, NULL);
+ mixVoice(&stream->mix, readStreamSource, stream, out, frameCount, &stream->sourceDry);
}
for (size_t i = 0; i < g_engine.pcmVoices.size(); ++i) {
PcmVoice *voice = g_engine.pcmVoices[i];
// Dry is only until the owner queues more, so it is asked afresh each pass, as a stream's is.
- // A movie is not ducked, as XAudio2's movie voice is not: -wav has to sound like the game.
voice->sourceDry = false;
- mixVoice(&voice->mix, readPcmSource, voice, out, frameCount, &voice->sourceDry, 1.0f, 1.0f, NULL);
- }
- if (g_engine.room.ready) {
- processRoom(&g_engine.room, room, out, frameCount);
+ mixVoice(&voice->mix, readPcmSource, voice, out, frameCount, &voice->sourceDry);
}
if (g_limiter.load()) {
AIL_ex_limit(&g_engine.limiter, out, (S32)frameCount);
@@ -1299,7 +1238,6 @@ S32 AILCALL AIL_quick_startup(S32 use_digital, S32, U32, S32, S32)
return 0;
}
g_engine.deviceRate = g_engine.device.sampleRate;
- initRoom(&g_engine.room, g_engine.deviceRate);
AIL_ex_limiter_init(&g_engine.limiter, OUTPUT_CHANNELS, (float)g_engine.deviceRate);
g_engine.deviceReady = true;
if (!g_engine.offline && ma_device_start(&g_engine.device) != MA_SUCCESS) {
@@ -1651,7 +1589,6 @@ HSAMPLE AILCALL AIL_allocate_sample_handle(HDIGDRIVER dig)
sample->queued = false;
sample->cursor = 0;
sample->sourceDry = false;
- sample->unducked = false;
sample->dry = false;
std::lock_guard<std::recursive_mutex> guard(g_engine.lock);
@@ -1912,10 +1849,6 @@ void AILCALL AIL_resume_3D_sample(H3DSAMPLE handle)
void AILCALL AIL_end_3D_sample(H3DSAMPLE handle)
{
AIL_stop_sample((HSAMPLE)handle);
- // the manager ends every handle it takes back, and the next sound on it ducks like the rest; a
- // stop is also a pause, which keeps the exemption
- std::lock_guard<std::mutex> mixGuard(g_engine.mixLock);
- ((Sample *)handle)->unducked = false;
}
void AILCALL AIL_set_3D_sample_volume(H3DSAMPLE handle, F32 volume)
@@ -1959,10 +1892,9 @@ void AILCALL AIL_ex_set_3D_linear_falloff(S32 linear)
g_linearFalloff.store(linear);
}
-void AILCALL AIL_ex_set_3D_air(F32 speed_of_sound, F32 absorption_distance)
+void AILCALL AIL_ex_set_3D_air(F32 speed_of_sound)
{
g_speedOfSound.store(speed_of_sound);
- g_absorptionDistance.store(absorption_distance);
}
void AILCALL AIL_ex_set_limiter(S32 on)
@@ -1970,24 +1902,6 @@ 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);
- std::lock_guard<std::mutex> mixGuard(g_engine.mixLock);
- setRoom(&g_engine.room, decay, damping, echo, slap);
-}
-
-void AILCALL AIL_ex_duck(H3DSAMPLE trigger, F32 gain, F32 seconds)
-{
- std::lock_guard<std::recursive_mutex> guard(g_engine.lock);
- std::lock_guard<std::mutex> mixGuard(g_engine.mixLock);
- ((Sample *)trigger)->unducked = true;
- g_engine.duckActive = true;
- g_engine.duckFrames = 0;
- g_engine.duckGain = gain;
- g_engine.duckSeconds = seconds;
-}
-
void AILCALL AIL_ex_set_3D_sample_dry(H3DSAMPLE handle, S32 dry)
{
std::lock_guard<std::recursive_mutex> guard(g_engine.lock);
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 3bfdb8caf..196cd8a10 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/Miles6/xaudio2/miles_xaudio2.cpp
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/Miles6/xaudio2/miles_xaudio2.cpp
@@ -12,11 +12,9 @@
* a source voice in ~200ms buffers by the service thread below.
* 3D positioning -> distance attenuation and a stereo pan computed here, not by XAudio2's
* X3DAudio: the game only ever asks for a position, a min/max distance
- * pair and an occlusion scalar. On top of those (MSS.h's AIL_ex_ air,
- * room and duck): the voice's own one-pole filter for air and occlusion,
- * its frequency ratio for doppler, and a second send into one submix
- * running mss_ex_room.h's room, miles_miniaudio's own.
- * EOS callbacks -> the service thread notices a voice run dry and calls back from there,
+ * pair and an occlusion scalar. The voice's own one-pole filter plays the
+ * occlusion, and its frequency ratio doppler (MSS.h's AIL_ex_set_3D_air).
+ * EOS callbacks -> the service thread notices a voice run dry and calls back from there,
* which is the thread context Miles used (MilesAudioManager locks for it).
* speaker types -> headphones run AIL_ex_hrtf in an effect on every 3D voice; 4, 5.1 and 7.1
* are a mastering voice of that many channels, 3D voices panned round it.
@@ -46,7 +44,6 @@ extern "C" {
}
#include "MSS/MSS.h"
-#include "MSS/mss_ex_room.h"
namespace {
@@ -60,7 +57,6 @@ const int AVIO_BUFFER_BYTES = 32768;
// made again once the endpoints have been quiet this long, not once for each.
const ULONGLONG ENDPOINT_SETTLE_MS = 300;
const int OUTPUT_DEVICE_CHARS = 256;
-const float HEADPHONE_ROOM_SEND = 0.7071f; // both ears into the room: about the one signal a speaker voice sends
const float HALF_TURN_RADIANS = 3.14159265f;
struct WaveImage
@@ -483,7 +479,6 @@ struct Sample
float minDistance, maxDistance;
float occlusion;
float velocityX, velocityY, velocityZ; // units a second, AIL_set_3D_velocity_vector
- bool unducked; // started a duck, so the duck leaves it alone until it is over or the sample stops
bool dry; // AIL_ex_set_3D_sample_dry
HeadEffect *head; // our reference to the voice's head under AIL_3D_HEADPHONE, NULL otherwise
ULONGLONG silentEndMs; // playing with no voice: when the sound it would have been is over
@@ -543,7 +538,6 @@ struct Engine
unsigned int masterRate;
unsigned int masterChannels;
bool onPickedDevice; // the master is on AIL_ex_set_output_device's endpoint, not the default
- IXAudio2SubmixVoice *room; // RoomTap, AIL_ex_set_reverb; NULL where it could not be made
IMMDeviceEnumerator *endpoints; // holds EndpointWatch's registration
CRITICAL_SECTION lock;
HANDLE serviceThread;
@@ -569,32 +563,8 @@ std::atomic<ULONGLONG> g_endpointsMovedMs(0);
S32 g_linearFalloff; // AIL_ex_set_3D_linear_falloff
// written by the game's thread with no lock, read by the service thread under it
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
-{
- bool given;
- float decay;
- float damping;
- float echo;
- float slap;
-};
-RoomSettings g_roomSettings = { false, 0.0f, 0.0f, 0.0f, 0.0f };
-
-// AIL_ex_duck, under the lock. duckNow is the gain the service thread worked out last.
-struct Duck
-{
- bool active;
- ULONGLONG startMs;
- float gain;
- float seconds;
- float duckNow;
-};
-Duck g_duck = { false, 0, 1.0f, 0.0f, 1.0f };
-
AILFILEOPENCB g_fileOpen;
AILFILECLOSECB g_fileClose;
AILFILESEEKCB g_fileSeek;
@@ -614,8 +584,7 @@ float clampUnit(float value)
}
// Every source channel into each of the master's speakers at that speaker's gain, the way Miles sums a
-// sample's channels into both sides of a pan. The master by name: a 3D sample's voice has a second
-// send, into the room.
+// sample's channels into both sides of a pan.
void applySpeakerGains(IXAudio2SourceVoice *voice, unsigned int sourceChannels, const float *gains)
{
std::vector<float> matrix((size_t)sourceChannels * g_engine.masterChannels, 0.0f);
@@ -687,13 +656,6 @@ void applyEars(IXAudio2SourceVoice *voice)
voice->SetOutputMatrix(g_engine.master, 2, g_engine.masterChannels, &matrix[0]);
}
-// Every channel the voice gives out into both of the room's, at one gain relative to its volume.
-void applyRoomSend(IXAudio2SourceVoice *voice, unsigned int voiceChannels, float send)
-{
- std::vector<float> matrix((size_t)voiceChannels * 2, send);
- voice->SetOutputMatrix(g_engine.room, voiceChannels, 2, &matrix[0]);
-}
-
struct Spatial
{
float volume;
@@ -701,7 +663,6 @@ struct Spatial
float side; // AIL_ex_3D_bearing, for the head and the surround pan
float front;
float cutoff; // Hz, AIL_ex_3D_cutoff
- float send; // into the room, AIL_ex_3D_send
float doppler; // pitch ratio, AIL_ex_doppler_ratio
};
@@ -734,18 +695,8 @@ Spatial computeSpatial(const Sample &sample)
spatial.pan = pan;
AIL_ex_3D_bearing(dx, dy, dz, listener.faceX, listener.faceY, listener.faceZ,
listener.upX, listener.upY, listener.upZ, &spatial.side, &spatial.front);
- // a duck muffles everything but its trigger, as miles_miniaudio's mix does
- const float muffle = sample.unducked ? AIL_EX_OPEN_CUTOFF : AIL_ex_duck_cutoff(g_duck.duckNow);
- if (sample.dry) {
- spatial.cutoff = AIL_ex_3D_cutoff(distance, 0.0f, sample.occlusion);
- spatial.send = 0.0f;
- spatial.doppler = 1.0f;
- } else {
- spatial.cutoff = AIL_ex_3D_cutoff(distance, g_absorptionDistance.load(), sample.occlusion);
- spatial.send = AIL_ex_3D_send(clampUnit(sample.volume), attenuation, g_roomSend.load());
- spatial.doppler = AIL_ex_doppler_ratio(dx, dy, dz, sample.velocityX, sample.velocityY, sample.velocityZ, g_speedOfSound.load());
- }
- spatial.cutoff = spatial.cutoff < muffle ? spatial.cutoff : muffle;
+ spatial.cutoff = AIL_ex_3D_cutoff(sample.occlusion);
+ spatial.doppler = sample.dry ? 1.0f : AIL_ex_doppler_ratio(dx, dy, dz, sample.velocityX, sample.velocityY, sample.velocityZ, g_speedOfSound.load());
return spatial;
}
@@ -776,20 +727,6 @@ void refreshSampleOutput(Sample *sample)
if (sample->head != NULL) {
sample->head->aim(side, front);
}
- // the voice's volume scales both sends, so the room's is given relative to it; a head gives
- // out two ears where a speaker voice gives its own channels
- if (g_engine.room != NULL) {
- const float send = volume > 0.0f ? spatial.send / volume : 0.0f;
- sample->voice->SetOutputFilterParameters(g_engine.room, &filter);
- if (sample->head != NULL) {
- applyRoomSend(sample->voice, 2, send * HEADPHONE_ROOM_SEND);
- } else {
- applyRoomSend(sample->voice, sample->format.nChannels, send);
- }
- }
- }
- if (!sample->unducked) {
- volume *= g_duck.duckNow;
}
sample->voice->SetVolume(clampUnit(volume));
@@ -866,11 +803,11 @@ bool freshVoice(Sample *sample, const WAVEFORMATEX &format)
if (!sample->is3D) {
return SUCCEEDED(g_engine.xaudio->CreateSourceVoice(&sample->voice, &format, 0, 4.0f, &g_sampleCallback));
}
- // A 3D sample's voice has the filter for air and occlusion, and sends into the room as well. Each
- // send filters again, which makes the two one-pole stages miles_miniaudio runs. Under headphones
- // the voice's head comes after the filter and gives out two ears, whatever the file has.
- XAUDIO2_SEND_DESCRIPTOR sends[2] = { { XAUDIO2_SEND_USEFILTER, g_engine.master }, { XAUDIO2_SEND_USEFILTER, g_engine.room } };
- XAUDIO2_VOICE_SENDS sendList = { g_engine.room != NULL ? 2u : 1u, sends };
+ // A 3D sample's voice has the filter for occlusion. Its send filters again, which makes the two
+ // one-pole stages miles_miniaudio runs. Under headphones the voice's head comes after the filter
+ // and gives out two ears, whatever the file has.
+ XAUDIO2_SEND_DESCRIPTOR sends[1] = { { XAUDIO2_SEND_USEFILTER, g_engine.master } };
+ XAUDIO2_VOICE_SENDS sendList = { 1u, sends };
if (g_speakerType != AIL_3D_HEADPHONE) {
return SUCCEEDED(g_engine.xaudio->CreateSourceVoice(&sample->voice, &format, XAUDIO2_VOICE_USEFILTER, 4.0f,
&g_sampleCallback, &sendList));
@@ -1038,7 +975,7 @@ void playStream(Stream *stream)
stream->silentEndMs = GetTickCount64() + (ULONGLONG)(stream->totalMs * loops);
return;
}
- stream->voice->SetVolume(clampUnit(stream->volume) * g_duck.duckNow);
+ stream->voice->SetVolume(clampUnit(stream->volume));
applyPan(stream->voice, stream->voiceFormat.nChannels, stream->pan);
stream->voice->Start(0);
}
@@ -1189,26 +1126,8 @@ DWORD WINAPI serviceThreadMain(LPVOID)
}
}
- // A duck reaches every voice, 2D ones and streams too, so while it runs all of them are
- // refreshed, and once more as it ends; the triggers go back to being ducked like the rest.
- const bool ducking = g_duck.active;
- if (ducking) {
- const float elapsed = (float)(GetTickCount64() - g_duck.startMs) / 1000.0f;
- g_duck.duckNow = AIL_ex_duck_gain(elapsed, g_duck.gain, g_duck.seconds);
- g_duck.active = elapsed < g_duck.seconds;
- for (size_t i = 0; i < g_engine.streams.size(); ++i) {
- Stream *stream = g_engine.streams[i];
- if (stream->voice != NULL) {
- stream->voice->SetVolume(clampUnit(stream->volume) * g_duck.duckNow);
- }
- }
- }
-
for (size_t i = 0; i < g_engine.samples.size(); ++i) {
Sample *sample = g_engine.samples[i];
- if (ducking && !g_duck.active) {
- sample->unducked = false;
- }
// started with no voice to play on, or its voice went with the output: over once the
// sound would have been, and the handle comes back the way a played one does
if (sample->voice == NULL) {
@@ -1224,7 +1143,7 @@ DWORD WINAPI serviceThreadMain(LPVOID)
}
continue;
}
- if (sample->is3D || ducking) {
+ if (sample->is3D) {
refreshSampleOutput(sample);
}
if (!sample->playing) {
@@ -1433,99 +1352,6 @@ bool installMasterTap(FILE *file)
return SUCCEEDED(result);
}
-// The room submix's effect: the send, which every voice puts on both channels alike, through
-// mss_ex_room.h's room, the one miles_miniaudio mixes, so a player and a -wav run hear one room.
-class RoomTap : public Effect
-{
-public:
- explicit RoomTap(unsigned int samplesPerSecond)
- : Effect(true), m_pending(false), m_decay(0.0f), m_damping(0.0f), m_echo(0.0f), m_slap(0.0f)
- {
- InitializeCriticalSection(&m_settingsLock);
- initRoom(&m_room, samplesPerSecond);
- }
-
- // AIL_ex_set_reverb's, from the game's thread: the mixer takes them up at its next pass.
- void set(float decay, float damping, float echo, float slap)
- {
- EnterCriticalSection(&m_settingsLock);
- m_decay = decay;
- m_damping = damping;
- m_echo = echo;
- m_slap = slap;
- m_pending = true;
- LeaveCriticalSection(&m_settingsLock);
- }
-
- STDMETHOD(LockForProcess)(UINT32, const XAPO_LOCKFORPROCESS_BUFFER_PARAMETERS *input, UINT32,
- const XAPO_LOCKFORPROCESS_BUFFER_PARAMETERS *)
- {
- m_send.resize(input[0].MaxFrameCount);
- return S_OK;
- }
-
- STDMETHOD_(void, Process)(UINT32, const XAPO_PROCESS_BUFFER_PARAMETERS *input, UINT32,
- XAPO_PROCESS_BUFFER_PARAMETERS *output, BOOL)
- {
- EnterCriticalSection(&m_settingsLock);
- if (m_pending) {
- setRoom(&m_room, m_decay, m_damping, m_echo, m_slap);
- m_pending = false;
- }
- LeaveCriticalSection(&m_settingsLock);
-
- // in place: the send read off the left channel, then the buffer is the room's answer alone; a
- // silent pass is no send, and the tail still rings
- const UINT32 frames = input[0].ValidFrameCount;
- float *mix = (float *)input[0].pBuffer;
- const bool silent = input[0].BufferFlags == XAPO_BUFFER_SILENT;
- for (UINT32 frame = 0; frame < frames; ++frame) {
- m_send[frame] = silent ? 0.0f : mix[frame * ROOM_OUTPUT_CHANNELS];
- }
- memset(mix, 0, (size_t)frames * ROOM_OUTPUT_CHANNELS * sizeof(float));
- processRoom(&m_room, &m_send[0], mix, frames);
- if (output != NULL) {
- output[0].ValidFrameCount = frames;
- output[0].BufferFlags = XAPO_BUFFER_VALID;
- }
- }
-
-private:
- ~RoomTap()
- {
- DeleteCriticalSection(&m_settingsLock);
- }
-
- Room m_room; // the mixer thread's alone
- std::vector<float> m_send;
- CRITICAL_SECTION m_settingsLock;
- bool m_pending;
- float m_decay;
- float m_damping;
- float m_echo;
- float m_slap;
-};
-
-RoomTap *g_roomTap; // our reference, for AIL_ex_set_reverb; the room voice holds XAudio2's
-
-// The room every 3D sample sends to: RoomTap on a stereo submix into the master, at the master's
-// rate, and the last room AIL_ex_set_reverb asked for, since this is made again with the output.
-void createRoom()
-{
- RoomTap *tap = new RoomTap(g_engine.masterRate);
- XAUDIO2_EFFECT_DESCRIPTOR descriptor = { static_cast<IXAPO *>(tap), TRUE, 2 };
- XAUDIO2_EFFECT_CHAIN chain = { 1, &descriptor };
- if (FAILED(g_engine.xaudio->CreateSubmixVoice(&g_engine.room, 2, g_engine.masterRate, 0, 0, NULL, &chain))) {
- g_engine.room = NULL;
- tap->Release();
- return;
- }
- if (g_roomSettings.given) {
- tap->set(g_roomSettings.decay, g_roomSettings.damping, g_roomSettings.echo, g_roomSettings.slap);
- }
- g_roomTap = tap;
-}
-
// ---------------------------------------------------------------------------------------------
// The output, and keeping it
//
@@ -1620,12 +1446,6 @@ void closeOutput()
}
stream->queued.clear();
}
- if (g_engine.room != NULL) {
- g_engine.room->DestroyVoice();
- g_engine.room = NULL;
- g_roomTap->Release();
- g_roomTap = NULL;
- }
if (g_engine.master != NULL) {
g_engine.master->DestroyVoice();
g_engine.master = NULL;
@@ -1638,7 +1458,7 @@ void closeOutput()
}
// The engine and its master, on the endpoint AIL_ex_set_output_device picked or the default when that
-// one is not there, at the speaker type's channel count; then the room, the master's tap and a voice
+// one is not there, at the speaker type's channel count; then the master's tap and a voice
// for every stream, playing again where one was. False with no endpoint at all, the engine kept.
// Under the lock.
bool openOutput()
@@ -1664,7 +1484,6 @@ bool openOutput()
g_engine.master->GetVoiceDetails(&masterDetails);
g_engine.masterRate = masterDetails.InputSampleRate;
g_engine.masterChannels = masterDetails.InputChannels;
- createRoom();
installMasterTap(NULL);
for (size_t i = 0; i < g_engine.streams.size(); ++i) {
@@ -2199,11 +2018,6 @@ void AILCALL AIL_resume_3D_sample(H3DSAMPLE handle)
void AILCALL AIL_end_3D_sample(H3DSAMPLE handle)
{
AIL_stop_sample((HSAMPLE)handle);
- // the manager ends every handle it takes back, and the next sound on it ducks like the rest; a
- // stop is also a pause, which keeps the exemption
- EnterCriticalSection(&g_engine.lock);
- ((Sample *)handle)->unducked = false;
- LeaveCriticalSection(&g_engine.lock);
}
void AILCALL AIL_set_3D_sample_volume(H3DSAMPLE handle, F32 volume)
@@ -2250,11 +2064,10 @@ void AILCALL AIL_ex_set_3D_linear_falloff(S32 linear)
g_linearFalloff = linear;
}
-void AILCALL AIL_ex_set_3D_air(F32 speed_of_sound, F32 absorption_distance)
+void AILCALL AIL_ex_set_3D_air(F32 speed_of_sound)
{
// No lock, as AIL_ex_set_3D_linear_falloff
g_speedOfSound.store(speed_of_sound);
- g_absorptionDistance.store(absorption_distance);
}
void AILCALL AIL_ex_set_limiter(S32 on)
@@ -2263,35 +2076,6 @@ 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);
- // kept for a room made again with the output; the lock because that is when g_roomTap changes
- if (g_engine.started) {
- EnterCriticalSection(&g_engine.lock);
- }
- const RoomSettings settings = { true, decay, damping, echo, slap };
- g_roomSettings = settings;
- if (g_roomTap != NULL) {
- g_roomTap->set(decay, damping, echo, slap);
- }
- if (g_engine.started) {
- LeaveCriticalSection(&g_engine.lock);
- }
-}
-
-void AILCALL AIL_ex_duck(H3DSAMPLE trigger, F32 gain, F32 seconds)
-{
- EnterCriticalSection(&g_engine.lock);
- ((Sample *)trigger)->unducked = true;
- g_duck.active = true;
- g_duck.startMs = GetTickCount64();
- g_duck.gain = gain;
- g_duck.seconds = seconds;
- refreshSampleOutput((Sample *)trigger);
- LeaveCriticalSection(&g_engine.lock);
-}
-
void AILCALL AIL_ex_set_3D_sample_dry(H3DSAMPLE handle, S32 dry)
{
EnterCriticalSection(&g_engine.lock);
@@ -2579,8 +2363,7 @@ void AILCALL AIL_set_stream_volume_pan(HSTREAM handle, F32 volume, F32 pan)
stream->volume = volume;
stream->pan = pan;
if (stream->voice != NULL) {
- // a fade writes this every pass, so it carries the duck the service thread last set
- stream->voice->SetVolume(clampUnit(volume) * g_duck.duckNow);
+ stream->voice->SetVolume(clampUnit(volume));
applyPan(stream->voice, stream->voiceFormat.nChannels, pan);
}
LeaveCriticalSection(&g_engine.lock);
diff --git a/GeneralsMD/Code/Tests/test_audio_mix_policy.cpp b/GeneralsMD/Code/Tests/test_audio_mix_policy.cpp
index 77988da45..609714111 100644
--- a/GeneralsMD/Code/Tests/test_audio_mix_policy.cpp
+++ b/GeneralsMD/Code/Tests/test_audio_mix_policy.cpp
@@ -1,8 +1,7 @@
/*
* The arithmetic of MilesAudioManager's battle mix (MilesAudioDevice/AudioMixPolicy.h): which sound
- * gives way when the voices run out, how much louder a folded shot plays, how deep a hill stands in
- * the line from the microphone, and how the muffle moves. The manager itself, its lists and the
- * terrain it reads are measured in the -wav mix (experiments/proofs/2026-10-25/audio-mix).
+ * gives way when the voices run out, and how much louder a folded shot plays. The manager itself and
+ * its lists are measured in the -wav mix (experiments/proofs/2026-10-25/audio-mix).
*/
#include "test_harness.h"
@@ -24,46 +23,3 @@ TEST(a_folded_shot_grows_a_step_each_and_stops_at_the_ceiling)
CHECK_NEAR(coalescedGain(2, 0.12f, 1.5f), 1.24f, 1e-6f);
CHECK_NEAR(coalescedGain(19, 0.12f, 1.5f), 1.5f, 1e-6f);
}
-
-// A ridge 100 high between x = 400 and x = 600 on flat ground at 0.
-static float ridge(float x, float)
-{
- return x >= 400.0f && x <= 600.0f ? 100.0f : 0.0f;
-}
-
-TEST(a_ridge_between_microphone_and_sound_stands_in_the_line_by_its_height)
-{
- // microphone at 50 over the ground at x 0, the sound at 10 over it at x 1000: the line is near 30 at the ridge
- const float depth = rayObstruction(0.0f, 0.0f, 50.0f, 1000.0f, 0.0f, 10.0f, 20.0f, 25.0f, 64, ridge);
- CHECK(depth > 65.0f && depth < 75.0f);
- CHECK_NEAR(occlusionAmount(depth, 30.0f), 1.0f, 1e-6f);
-
- // the same ridge seen from high above clears the line
- CHECK_NEAR(rayObstruction(0.0f, 0.0f, 400.0f, 1000.0f, 0.0f, 10.0f, 20.0f, 25.0f, 64, ridge), 0.0f, 1e-6f);
-}
-
-TEST(the_ground_under_either_end_is_not_a_hill_between_them)
-{
- // flat ground at 0 and a sound on it at 0: only the margins touch the line, and they are left out
- struct Flat { float operator()(float, float) const { return 0.0f; } };
- CHECK_NEAR(rayObstruction(0.0f, 0.0f, 50.0f, 300.0f, 0.0f, 0.0f, 20.0f, 25.0f, 64, Flat()), 0.0f, 1e-6f);
- // a sound closer than both margins is never looked through
- CHECK_NEAR(rayObstruction(0.0f, 0.0f, 0.0f, 40.0f, 0.0f, 0.0f, 20.0f, 25.0f, 64, ridge), 0.0f, 1e-6f);
-}
-
-TEST(a_long_line_is_sampled_no_more_than_the_cap)
-{
- int calls = 0;
- rayObstruction(0.0f, 0.0f, 50.0f, 5000.0f, 0.0f, 0.0f, 20.0f, 25.0f, 48,
- [&calls](float, float) { ++calls; return 0.0f; });
- CHECK_EQ(calls, 48);
-}
-
-TEST(the_muffle_moves_towards_what_was_seen_and_stands_still_without_time)
-{
- CHECK_NEAR(approach(0.0f, 1.0f, 0.0f, 250.0f), 0.0f, 1e-6f);
- CHECK_NEAR(approach(0.0f, 1.0f, 250.0f, 250.0f), 0.6321f, 1e-3f);
- CHECK_NEAR(approach(0.3f, 1.0f, 16.0f, 0.0f), 1.0f, 1e-6f);
- // two half steps land where one whole step does, so the frame rate does not change how fast it opens
- CHECK_NEAR(approach(approach(1.0f, 0.0f, 125.0f, 250.0f), 0.0f, 125.0f, 250.0f), approach(1.0f, 0.0f, 250.0f, 250.0f), 1e-5f);
-}
diff --git a/GeneralsMD/Code/Tests/test_miles_effects.cpp b/GeneralsMD/Code/Tests/test_miles_effects.cpp
index 7b8cf6fc0..813c7a664 100644
--- a/GeneralsMD/Code/Tests/test_miles_effects.cpp
+++ b/GeneralsMD/Code/Tests/test_miles_effects.cpp
@@ -1,6 +1,8 @@
/*
- * The air, room, duck and limiter of the Miles surface on miniaudio (MSS.h's AIL_ex_set_3D_air,
- * AIL_ex_set_reverb, AIL_ex_duck and AIL_ex_limit), measured in the mix a -wav run records.
+ * Doppler and the limiter of the Miles surface on miniaudio (MSS.h's AIL_ex_set_3D_air and
+ * AIL_ex_limit), measured in the mix a -wav run records, and what the mix does not do: no echo after
+ * a sound has stopped, and no filter that grows with distance, the two that made every map sound
+ * like the inside of a tunnel.
*
* miles_miniaudio.cpp is compiled into this test on its own, without the XAudio2 half, and run on its
* offline mix: AIL_ex_offline_mix, then AIL_ex_mix_to_frame moves the mix by logic frames, so every
@@ -8,10 +10,7 @@
* back through AIL_ex_start_capture, the tap -wav writes its file from. The expected numbers are the
* physics the helpers in MSS.h claim, worked out here, not read back from them.
*
- * The room is MSS/mss_ex_room.h, which miles_xaudio2 runs too, so the room tests hold for what a
- * player on Windows hears. Not covered: XAudio2's own filter and its wall-clock duck, which need an
- * audio device, and the delay a world sound starts with, which is the game's request list and not
- * this library.
+ * Not covered: XAudio2's own filter, which needs an audio device.
*/
#include "test_harness.h"
@@ -189,25 +188,14 @@ static double brightnessAt(float x)
return rms(capture, 0.1, 0.4) / (10.0 / fabs(x));
}
-TEST(air_takes_the_top_off_a_far_sound)
+TEST(distance_changes_the_level_and_leaves_the_top_end)
{
startAudio();
- // No air: distance changes the level and nothing else.
- AIL_ex_set_3D_air(0.0f, 0.0f);
- const double nearOpen = brightnessAt(-20.0f);
- const double farOpen = brightnessAt(-1600.0f);
+ const double nearLevel = brightnessAt(-20.0f);
+ const double farLevel = brightnessAt(-1600.0f);
// all of it on the right, half of the mono average: 0.17263 / 2 at full volume
- CHECK(nearOpen > 0.05);
- CHECK(fabs(farOpen / nearOpen - 1.0) < 0.05);
-
- // Air at 400: 1600 out is a cutoff of 20 kHz / 17, 1.2 kHz, where a one-pole leaves an 8 kHz
- // tone under a fifth of itself; 20 out the cutoff is still near 20 kHz and the tone passes.
- AIL_ex_set_3D_air(0.0f, 400.0f);
- const double nearAir = brightnessAt(-20.0f);
- const double farAir = brightnessAt(-1600.0f);
- AIL_ex_set_3D_air(0.0f, 0.0f);
- CHECK(nearAir / nearOpen > 0.9);
- CHECK(farAir / nearAir < 0.2);
+ CHECK(nearLevel > 0.05);
+ CHECK(fabs(farLevel / nearLevel - 1.0) < 0.05);
}
TEST(doppler_raises_what_comes_and_lowers_what_goes)
@@ -215,7 +203,7 @@ TEST(doppler_raises_what_comes_and_lowers_what_goes)
startAudio();
// A quarter of the speed of sound towards the listener is 1700 / 1275, a third up; the same away
// is 1700 / 2125, a fifth down.
- AIL_ex_set_3D_air(1700.0f, 0.0f);
+ AIL_ex_set_3D_air(1700.0f);
std::vector<unsigned char> tone = makeTone(440.0, 500);
std::vector<H3DSAMPLE> coming(1, place(tone, -500.0f, 425.0f, 1.0f));
const Capture up = listen(coming, 0.6);
@@ -223,114 +211,42 @@ TEST(doppler_raises_what_comes_and_lowers_what_goes)
const Capture down = listen(going, 0.6);
std::vector<H3DSAMPLE> standing(1, place(tone, -500.0f, 0.0f, 1.0f));
const Capture still = listen(standing, 0.6);
- AIL_ex_set_3D_air(0.0f, 0.0f);
+ AIL_ex_set_3D_air(0.0f);
CHECK_NEAR(frequency(still, 0.05, 0.25), 440.0, 440.0 * 0.02);
CHECK_NEAR(frequency(up, 0.05, 0.25), 440.0 * 4.0 / 3.0, 440.0 * 0.02);
CHECK_NEAR(frequency(down, 0.05, 0.25), 440.0 * 0.8, 440.0 * 0.02);
}
-TEST(the_room_rings_on_after_the_sound_has_stopped)
+TEST(a_sound_that_has_stopped_leaves_no_echo)
{
startAudio();
- // A tenth of a second of tone, then listen past it: dry is silence, a room is a tail.
+ // A tenth of a second of tone, then listen past it, near and far: silence, where the room this
+ // mix used to have rang on for two seconds.
std::vector<unsigned char> tone = makeTone(440.0, 100);
- AIL_ex_set_reverb(0.0f, 1.5f, 0.3f, 0.0f, 0.0f);
- std::vector<H3DSAMPLE> dry(1, place(tone, -20.0f, 0.0f, 1.0f));
- const Capture dryCapture = listen(dry, 1.0);
-
- AIL_ex_set_reverb(0.5f, 1.5f, 0.3f, 0.0f, 0.0f);
- std::vector<H3DSAMPLE> wet(1, place(tone, -20.0f, 0.0f, 1.0f));
- const Capture wetCapture = listen(wet, 1.0);
-
- // An echo holds the room back: after a 30 ms blip the room answers within a comb's length, 25 ms,
- // and with a 90 ms echo nothing comes back before the echo does.
- // Each waits out the last one's tail first, four seconds being 160 dB at this decay.
- std::vector<unsigned char> blip = makeTone(440.0, 30);
- runSeconds(4.0);
- std::vector<H3DSAMPLE> prompt(1, place(blip, -20.0f, 0.0f, 1.0f));
- const Capture promptCapture = listen(prompt, 0.3);
- runSeconds(4.0);
- AIL_ex_set_reverb(0.5f, 1.5f, 0.3f, 0.09f, 0.35f);
- std::vector<H3DSAMPLE> echoed(1, place(blip, -20.0f, 0.0f, 1.0f));
- const Capture echoCapture = listen(echoed, 0.3);
- AIL_ex_set_reverb(0.0f, 1.0f, 0.0f, 0.0f, 0.0f);
- runSeconds(3.0); // let the tail die before the next test listens
-
- CHECK(rms(dryCapture, 0.0, 0.1) > 0.02);
- CHECK(rms(dryCapture, 0.3, 0.6) < 0.0002);
- CHECK(rms(wetCapture, 0.3, 0.6) > 0.001);
- CHECK(rms(wetCapture, 0.3, 0.6) < rms(wetCapture, 0.0, 0.1));
- CHECK(rms(promptCapture, 0.035, 0.085) > 0.001);
- CHECK(rms(echoCapture, 0.035, 0.085) < 0.0002);
- CHECK(rms(echoCapture, 0.095, 0.12) > 0.002);
+ std::vector<H3DSAMPLE> nearSound(1, place(tone, -20.0f, 0.0f, 1.0f));
+ const Capture nearCapture = listen(nearSound, 1.0);
+ std::vector<H3DSAMPLE> farSound(1, place(tone, -200.0f, 0.0f, 1.0f));
+ const Capture farCapture = listen(farSound, 1.0);
+
+ CHECK(rms(nearCapture, 0.0, 0.1) > 0.02);
+ CHECK(rms(nearCapture, 0.15, 0.9) < 0.0002);
+ CHECK(rms(farCapture, 0.0, 0.1) > 0.002);
+ CHECK(rms(farCapture, 0.15, 0.9) < 0.0002);
}
-TEST(a_dry_sample_takes_no_air_and_no_room)
+TEST(a_dry_sample_takes_no_doppler)
{
startAudio();
- // A unit's reply: 1600 out with air at 400 keeps its 8 kHz, and a room at half send adds no tail.
- AIL_ex_set_3D_air(0.0f, 400.0f);
- AIL_ex_set_reverb(0.5f, 1.5f, 0.3f, 0.0f, 0.0f);
- std::vector<unsigned char> bright = makeTone(8000.0, 500);
- std::vector<H3DSAMPLE> farReply(1, place(bright, -1600.0f, 0.0f, 1.0f));
- AIL_ex_set_3D_sample_dry(farReply[0], 1);
- const double farLevel = rms(listen(farReply, 0.6), 0.1, 0.4) / (10.0 / 1600.0);
- std::vector<H3DSAMPLE> nearReply(1, place(bright, -20.0f, 0.0f, 1.0f));
- AIL_ex_set_3D_sample_dry(nearReply[0], 1);
- const double nearLevel = rms(listen(nearReply, 0.6), 0.1, 0.4) / (10.0 / 20.0);
- runSeconds(4.0);
- std::vector<unsigned char> blip = makeTone(440.0, 100);
- std::vector<H3DSAMPLE> reply(1, place(blip, -20.0f, 0.0f, 1.0f));
+ // A unit's reply, coming at a quarter of the speed of sound, keeps its pitch.
+ AIL_ex_set_3D_air(1700.0f);
+ std::vector<unsigned char> tone = makeTone(440.0, 500);
+ std::vector<H3DSAMPLE> reply(1, place(tone, -500.0f, 425.0f, 1.0f));
AIL_ex_set_3D_sample_dry(reply[0], 1);
- const Capture replyCapture = listen(reply, 1.0);
- AIL_ex_set_3D_air(0.0f, 0.0f);
- AIL_ex_set_reverb(0.0f, 1.0f, 0.0f, 0.0f, 0.0f);
- runSeconds(3.0);
-
- CHECK(nearLevel > 0.05);
- CHECK(fabs(farLevel / nearLevel - 1.0) < 0.05);
- CHECK(rms(replyCapture, 0.0, 0.1) > 0.02);
- CHECK(rms(replyCapture, 0.3, 0.6) < 0.0002);
-}
-
-TEST(a_duck_dips_the_rest_and_spares_the_blast)
-{
- startAudio();
- // The rest is a steady tone, low enough that the duck's muffle leaves it be; the blast is a silent
- // sample, since only its exemption matters.
- std::vector<unsigned char> steady = makeTone(110.0, 4000);
- std::vector<unsigned char> blastTone = makeTone(880.0, 4000);
- std::vector<H3DSAMPLE> samples;
- samples.push_back(place(steady, -20.0f, 0.0f, 1.0f));
- samples.push_back(place(blastTone, -20.0f, 0.0f, 0.0f));
- AIL_ex_duck(samples[1], 0.25f, 2.0f);
- const Capture capture = listen(samples, 3.0);
-
- // Held at a quarter for the first half second (the hold is a quarter of the two), back by two.
- const double full = rms(capture, 2.2, 2.9);
- CHECK(full > 0.02);
- CHECK_NEAR(rms(capture, 0.1, 0.45) / full, 0.25, 0.03);
- CHECK(rms(capture, 1.2, 1.3) / full > 0.4);
- CHECK(rms(capture, 1.2, 1.3) / full < 0.9);
-}
-
-TEST(a_duck_muffles_what_it_dips)
-{
- startAudio();
- // A duck to a quarter is a 1250 Hz ceiling, AIL_ex_duck_cutoff: an 8 kHz tone under it loses far
- // more than the quarter the gain takes.
- std::vector<unsigned char> bright = makeTone(8000.0, 3000);
- std::vector<unsigned char> blastTone = makeTone(880.0, 3000);
- std::vector<H3DSAMPLE> samples;
- samples.push_back(place(bright, -20.0f, 0.0f, 1.0f));
- samples.push_back(place(blastTone, -20.0f, 0.0f, 0.0f));
- AIL_ex_duck(samples[1], 0.25f, 2.0f);
- const Capture capture = listen(samples, 2.5);
+ const Capture capture = listen(reply, 0.6);
+ AIL_ex_set_3D_air(0.0f);
- const double full = rms(capture, 2.1, 2.4);
- CHECK(full > 0.02);
- CHECK(rms(capture, 0.1, 0.45) / full < 0.1);
+ CHECK_NEAR(frequency(capture, 0.05, 0.25), 440.0, 440.0 * 0.02);
}
TEST(a_loud_mix_never_reaches_full_scale)
diff --git a/GeneralsMD/Code/Tests/test_miles_miniaudio.cpp b/GeneralsMD/Code/Tests/test_miles_miniaudio.cpp
index bc43a56af..a9d9744b6 100644
--- a/GeneralsMD/Code/Tests/test_miles_miniaudio.cpp
+++ b/GeneralsMD/Code/Tests/test_miles_miniaudio.cpp
@@ -381,8 +381,7 @@ TEST(linear_falloff_is_a_straight_line_between_the_distances)
TEST(occlusion_is_a_low_pass_and_inside_the_minimum_is_full)
{
- // Occlusion was a cut in volume and is a filter now (MSS.h's AIL_ex_3D_cutoff): half occluded is a
- // one-pole at 5 kHz, which leaves the 440 Hz tone at 0.993 of itself.
+ // Occlusion is a filter (MSS.h's AIL_ex_3D_cutoff): half occluded is a one-pole at 5 kHz, which leaves the 440 Hz tone at 0.993 of itself.
Heard heard = play3D(-5.0f, 0.5f);
if (!audio()) return;
CHECK(near(heard.right, TONE_RMS));