Skip to content

Commit

Permalink
xrSound: removed sound environment code
Browse files Browse the repository at this point in the history
The reason is because it was used only for EAX effects and we just removed EAX code in 7fbfeb8

Also, "environment" model is always an approximation. With SteamAudio it's possible to simulate much more realistic sound effects.
  • Loading branch information
Xottab-DUTY committed May 31, 2024
1 parent 2e0451d commit 6b30049
Show file tree
Hide file tree
Showing 14 changed files with 2 additions and 483 deletions.
7 changes: 0 additions & 7 deletions src/xrGame/Level_load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,6 @@ bool CLevel::Load_GameSpecific_After()
VERIFY(m_level_sound_manager);
m_level_sound_manager->Load();

// loading sound environment
if (FS.exist(fn_game, "$level$", "level.snd_env"))
{
IReader* F = FS.r_open(fn_game);
Sound->set_geometry_env(F);
FS.r_close(F);
}
// loading SOM
if (FS.exist(fn_game, "$level$", "level.som"))
{
Expand Down
8 changes: 0 additions & 8 deletions src/xrSound/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,6 @@ target_sources_grouped(
SoundRender_Emitter_StartStop.cpp
)

target_sources_grouped(
TARGET xrSound
NAME "Environment"
FILES
SoundRender_Environment.cpp
SoundRender_Environment.h
)

target_sources_grouped(
TARGET xrSound
NAME "Scene"
Expand Down
32 changes: 0 additions & 32 deletions src/xrSound/Sound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ void CSoundManager::Create()

if (SoundRender->bPresent)
{
env_load();
SoundRender->_initialize();
}
}
Expand All @@ -43,8 +42,6 @@ void CSoundManager::Destroy()
SoundRender->_clear();
xr_delete(SoundRender);

env_unload();

for (auto& token : soundDevices)
{
pstr tokenName = const_cast<pstr>(token.name);
Expand All @@ -57,32 +54,3 @@ bool CSoundManager::IsSoundEnabled() const
{
return SoundRender && SoundRender->bPresent;
}

void CSoundManager::env_load()
{
string_path fn;
if (FS.exist(fn, "$game_data$", SNDENV_FILENAME))
{
soundEnvironment = xr_new<SoundEnvironment_LIB>();
soundEnvironment->Load(fn);
}
}

void CSoundManager::env_unload()
{
if (soundEnvironment)
soundEnvironment->Unload();
xr_delete(soundEnvironment);
}

SoundEnvironment_LIB* CSoundManager::get_env_library() const
{
return soundEnvironment;
}

void CSoundManager::refresh_env_library()
{
env_unload();
env_load();
SoundRender->env_apply();
}
20 changes: 0 additions & 20 deletions src/xrSound/Sound.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
# endif
#endif

constexpr pcstr SNDENV_FILENAME = "sEnvironment.xr";
#define OGG_COMMENT_VERSION 0x0003

// refs
Expand All @@ -29,8 +28,6 @@ class XRSOUND_API CSound_params;
class XRSOUND_API CSound_source;
class XRSOUND_API CSound_emitter;
class XRSOUND_API CSound_stream_interface;
class XRSOUND_API CSound_environment;
class XRSOUND_API SoundEnvironment_LIB; // editor only ref
class XRSOUND_API CSound_stats_ext;
struct xr_token;
class IReader;
Expand Down Expand Up @@ -103,10 +100,6 @@ class XRSOUND_API XR_NOVTABLE CSound_source

inline CSound_source::~CSound_source() = default;

/// definition (Sound Source)
class XRSOUND_API CSound_environment
{};

/// definition (Sound Params)
class XRSOUND_API CSound_params
{
Expand Down Expand Up @@ -183,15 +176,9 @@ class XRSOUND_API XR_NOVTABLE ISoundScene
virtual int pause_emitters(bool pauseState) = 0;

virtual void set_handler(sound_event* E) = 0;
virtual void set_geometry_env(IReader* I) = 0;
virtual void set_geometry_som(IReader* I) = 0;
virtual void set_geometry_occ(CDB::MODEL* M, const Fbox& aabb) = 0;

virtual void set_user_env(CSound_environment* E) = 0;
virtual void set_environment(u32 id, CSound_environment** dst_env) = 0;
virtual void set_environment_size(CSound_environment* src_env, CSound_environment** dst_env) = 0;
virtual CSound_environment* get_environment(const Fvector& P) = 0;

virtual float get_occlusion_to(const Fvector& hear_pt, const Fvector& snd_pt, float dispersion = 0.2f) = 0;
virtual float get_occlusion(const Fvector& P, float R, Fvector* occ) = 0;

Expand Down Expand Up @@ -240,8 +227,6 @@ class XRSOUND_API CSoundManager
{
xr_vector<xr_token> soundDevices;

SoundEnvironment_LIB* soundEnvironment{};

public:
void CreateDevicesList();
auto& GetDevicesList() { return soundDevices; }
Expand All @@ -251,11 +236,6 @@ class XRSOUND_API CSoundManager

[[nodiscard]]
bool IsSoundEnabled() const;

void env_load();
void env_unload();
void refresh_env_library();
SoundEnvironment_LIB* get_env_library() const;
};

class CSound_UserDataVisitor;
Expand Down
13 changes: 2 additions & 11 deletions src/xrSound/SoundRender_Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ CSoundRender_Core::CSoundRender_Core(CSoundManager& p)
{
bPresent = false;
s_emitters_u = 0;
e_current.set_identity();
e_target.set_identity();
bReady = false;
isLocked = false;
fTimer_Value = Timer.GetElapsed_sec();
Expand Down Expand Up @@ -186,17 +184,10 @@ void CSoundRender_Core::update_listener(const Fvector& P, const Fvector& D, cons
Listener.orientation[1] = N;
Listener.orientation[2] = R;

if (!psSoundFlags.test(ss_EFX))
if (!psSoundFlags.test(ss_EFX) || !bListenerMoved)
return;

// Update effects
if (bListenerMoved)
{
bListenerMoved = false;
e_target = *(CSoundRender_Environment*)DefaultSoundScene->get_environment(P);
}

e_current.lerp(e_current, e_target, fTimer_Delta);
bListenerMoved = false;
}

void CSoundRender_Core::refresh_sources()
Expand Down
3 changes: 0 additions & 3 deletions src/xrSound/SoundRender_Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "xrCommon/xr_unordered_map.h"

#include "SoundRender.h"
#include "SoundRender_Environment.h"
#include "SoundRender_Scene.h"

class CSoundRender_Core : public ISoundManager
Expand Down Expand Up @@ -48,8 +47,6 @@ class CSoundRender_Core : public ISoundManager

bool bListenerMoved{};

CSoundRender_Environment e_current;
CSoundRender_Environment e_target;
SoundStatistics Stats;

public:
Expand Down
3 changes: 0 additions & 3 deletions src/xrSound/SoundRender_Emitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "xrCore/_std_extensions.h"

#include "SoundRender.h"
#include "SoundRender_Environment.h"
#include "SoundRender_Scene.h"

struct OggVorbis_File;
Expand Down Expand Up @@ -56,8 +55,6 @@ class CSoundRender_Emitter final : public CSound_emitter
u32 m_stream_cursor{};
u32 m_cur_handle_cursor{};
CSound_params p_source;
CSoundRender_Environment e_current;
CSoundRender_Environment e_target;

int iPaused{};
bool bMoved;
Expand Down
5 changes: 0 additions & 5 deletions src/xrSound/SoundRender_Emitter_FSM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ void CSoundRender_Emitter::update(float fTime, float dt)
smooth_volume = p_source.base_volume * p_source.volume *
(owner_data->s_type == st_Effect ? psSoundVEffects * psSoundVFactor : psSoundVMusic) *
(b2D ? 1.f : occluder_volume);
e_current = e_target = *(CSoundRender_Environment*)scene->get_environment(p_source.position);
if (update_culling(dt))
{
m_current_state = stPlaying;
Expand Down Expand Up @@ -98,7 +97,6 @@ void CSoundRender_Emitter::update(float fTime, float dt)
smooth_volume = p_source.base_volume * p_source.volume *
(owner_data->s_type == st_Effect ? psSoundVEffects * psSoundVFactor : psSoundVMusic) *
(b2D ? 1.f : occluder_volume);
e_current = e_target = *(CSoundRender_Environment*)scene->get_environment(p_source.position);
if (update_culling(dt))
{
m_current_state = stPlayingLooped;
Expand Down Expand Up @@ -365,9 +363,6 @@ float CSoundRender_Emitter::priority() const

void CSoundRender_Emitter::update_environment(float dt)
{
if (bMoved)
e_target = *(CSoundRender_Environment*)scene->get_environment(p_source.position);
e_current.lerp(e_current, e_target, dt);
}

void CSoundRender_Emitter::render()
Expand Down
Loading

0 comments on commit 6b30049

Please sign in to comment.