diff --git a/src/audio/sfx_buffer.cpp b/src/audio/sfx_buffer.cpp index 0f39c2d18..baa6374ae 100644 --- a/src/audio/sfx_buffer.cpp +++ b/src/audio/sfx_buffer.cpp @@ -38,7 +38,6 @@ SFXBuffer::SFXBuffer(const std::string& file, bool positional, - ALuint rolloffType, float rolloff, float gain) { @@ -51,7 +50,6 @@ SFXBuffer::SFXBuffer(const std::string& file, m_rolloff = rolloff; m_positional = positional; m_gain = gain; - m_rolloffType = rolloffType; } //---------------------------------------------------------------------------- @@ -65,21 +63,10 @@ SFXBuffer::SFXBuffer(const std::string& file, m_positional = false; m_loaded = false; m_file = file; - m_rolloffType = AL_INVERSE_DISTANCE_CLAMPED; node->get("rolloff", &m_rolloff ); node->get("positional", &m_positional ); node->get("volume", &m_gain ); - - std::string rolloffType; - node->get("rolloff_type", &rolloffType); - - if (rolloffType == "inverse") - m_rolloffType = AL_INVERSE_DISTANCE_CLAMPED; - else if (rolloffType == "linear") - m_rolloffType = AL_LINEAR_DISTANCE_CLAMPED; - else if (rolloffType != "") - fprintf(stderr, "[SfxBuffer] Unknown rolloff type '%s'\n", rolloffType.c_str()); } //---------------------------------------------------------------------------- diff --git a/src/audio/sfx_buffer.hpp b/src/audio/sfx_buffer.hpp index 2ee855307..da98a11a5 100644 --- a/src/audio/sfx_buffer.hpp +++ b/src/audio/sfx_buffer.hpp @@ -55,7 +55,6 @@ private: bool m_positional; float m_rolloff; float m_gain; - ALuint m_rolloffType; bool loadVorbisBuffer(const std::string &name, ALuint buffer); @@ -63,7 +62,6 @@ public: SFXBuffer(const std::string& file, bool positional, - ALuint rolloffType, float rolloff, float gain); @@ -100,9 +98,6 @@ public: std::string getFileName() const { return m_file; } void setPositional(bool positional) { m_positional = positional; } - - ALuint getRolloffType() const { return m_rolloffType; } - }; diff --git a/src/audio/sfx_manager.cpp b/src/audio/sfx_manager.cpp index 131b75c1c..514e57167 100644 --- a/src/audio/sfx_manager.cpp +++ b/src/audio/sfx_manager.cpp @@ -184,12 +184,11 @@ void SFXManager::loadSfx() SFXBuffer* SFXManager::addSingleSfx(const std::string &sfx_name, const std::string &sfx_file, bool positional, - ALuint rolloff_type, float rolloff, float gain) { - SFXBuffer* buffer = new SFXBuffer(sfx_file, positional, rolloff_type, rolloff, gain); + SFXBuffer* buffer = new SFXBuffer(sfx_file, positional, rolloff, gain); m_all_sfx_types[sfx_name] = buffer; @@ -250,7 +249,6 @@ SFXBuffer* SFXManager::loadSingleSfx(const XMLNode* node, return addSingleSfx(sfx_name, full_path, tmpbuffer.isPositional(), - tmpbuffer.getRolloffType(), tmpbuffer.getRolloff(), tmpbuffer.getGain()); diff --git a/src/audio/sfx_manager.hpp b/src/audio/sfx_manager.hpp index 2a405ca85..b64f51232 100644 --- a/src/audio/sfx_manager.hpp +++ b/src/audio/sfx_manager.hpp @@ -109,7 +109,6 @@ public: SFXBuffer* addSingleSfx(const std::string &sfx_name, const std::string &filename, bool positional, - ALuint rolloff_type, float rolloff, float gain); diff --git a/src/audio/sfx_openal.cpp b/src/audio/sfx_openal.cpp index c6b3cab57..48836f5f6 100644 --- a/src/audio/sfx_openal.cpp +++ b/src/audio/sfx_openal.cpp @@ -44,7 +44,6 @@ SFXOpenAL::SFXOpenAL(SFXBuffer* buffer, bool positional, float gain) : SFXBase() m_defaultGain = gain; m_loop = false; m_gain = -1.0f; - m_rolloffType = buffer->getRolloffType(); // Don't initialise anything else if the sfx manager was not correctly // initialised. First of all the initialisation will not work, and it @@ -86,17 +85,7 @@ bool SFXOpenAL::init() alSource3f(m_soundSource, AL_VELOCITY, 0.0, 0.0, 0.0); alSource3f(m_soundSource, AL_DIRECTION, 0.0, 0.0, 0.0); - alDistanceModel(m_rolloffType); - - if (m_rolloffType == AL_INVERSE_DISTANCE_CLAMPED) - { - alSourcef (m_soundSource, AL_ROLLOFF_FACTOR, m_soundBuffer->getRolloff()); - } - else if (m_rolloffType == AL_LINEAR_DISTANCE_CLAMPED) - { - alSourcef (m_soundSource, AL_MAX_DISTANCE, m_soundBuffer->getRolloff()); - } - + alSourcef (m_soundSource, AL_ROLLOFF_FACTOR, m_soundBuffer->getRolloff()); if (m_gain < 0.0f) { @@ -242,8 +231,9 @@ void SFXOpenAL::position(const Vec3 &position) if (!m_positional) { // in multiplayer, all sounds are positional, so in this case don't bug users with - // an error messageif (race_manager->getNumLocalPlayers() > 1) - if (race_manager->getNumLocalPlayers() == 1) + // an error message if (race_manager->getNumLocalPlayers() > 1) + // (note that 0 players is also possible, in cutscenes) + if (race_manager->getNumLocalPlayers() < 2) { fprintf(stderr, "WARNING, position called on non-positional SFX\n"); } diff --git a/src/audio/sfx_openal.hpp b/src/audio/sfx_openal.hpp index ad3005494..c10a54316 100644 --- a/src/audio/sfx_openal.hpp +++ b/src/audio/sfx_openal.hpp @@ -43,8 +43,6 @@ private: bool m_positional; float m_defaultGain; - int m_rolloffType; - /** The OpenAL source contains this info, but if audio is disabled initially then the sound source won't be created and we'll be left with no clue when enabling sounds later */ diff --git a/src/tracks/track_object.cpp b/src/tracks/track_object.cpp index a2dbc2783..a67a13cf2 100644 --- a/src/tracks/track_object.cpp +++ b/src/tracks/track_object.cpp @@ -135,20 +135,9 @@ TrackObject::TrackObject(const XMLNode &xml_node) xml_node.get("conditions", &m_trigger_condition); - ALuint rolloffType = AL_INVERSE_DISTANCE_CLAMPED; - std::string rolloffTypeStr; - xml_node.get("rolloff_type", &rolloffTypeStr ); - float rolloff_distance = 10.0f; xml_node.get("distance", &rolloff_distance ); - if (rolloffTypeStr == "inverse") - rolloffType = AL_INVERSE_DISTANCE_CLAMPED; - else if (rolloffTypeStr == "linear") - rolloffType = AL_LINEAR_DISTANCE_CLAMPED; - else if (rolloffTypeStr != "") - fprintf(stderr, "[TrackObject] Unknown rolloff type '%s'\n", rolloffTypeStr.c_str()); - // first try track dir, then global dir std::string soundfile = file_manager->getModelFile(sound); if (!file_manager->fileExists(soundfile)) @@ -156,16 +145,9 @@ TrackObject::TrackObject(const XMLNode &xml_node) soundfile = file_manager->getSFXFile(sound); } - float rolloff_param = 1.0f; - if (rolloffType == AL_INVERSE_DISTANCE_CLAMPED) - rolloff_param = rolloff; - else if (rolloffType == AL_LINEAR_DISTANCE_CLAMPED) - rolloff_param = rolloff_distance; - SFXBuffer* buffer = new SFXBuffer(soundfile, true /* positional */, - rolloffType, - rolloff_param, + rolloff, volume); buffer->load();