diff --git a/sound/filters/pure_filter.hpp b/sound/filters/pure_filter.hpp index 9d19ffd18..1e8b9f92c 100644 --- a/sound/filters/pure_filter.hpp +++ b/sound/filters/pure_filter.hpp @@ -25,6 +25,8 @@ namespace Mangle { client->setPos(x,y,z); } void setPitch(float p) { client->setPitch(p); } void setRepeat(bool b) { client->setRepeat(b); } + void setRange(float a, float b=0, float c=0) + { client->setRange(a,b,c); } void setStreaming(bool b) { client->setStreaming(b); } // The clone() function is not implemented here, as you will diff --git a/sound/output.hpp b/sound/output.hpp index 35182e58c..596e08c58 100644 --- a/sound/output.hpp +++ b/sound/output.hpp @@ -51,6 +51,10 @@ class Sound /// Set pitch (1.0 is normal speed) virtual void setPitch(float) = 0; + /// Set range factors for 3D sounds. The meaning of the fields + /// depend on implementation. + virtual void setRange(float a, float b=0.0, float c=0.0) = 0; + /// Set the position. May not work with all backends. virtual void setPos(float x, float y, float z) = 0; diff --git a/sound/outputs/openal_out.cpp b/sound/outputs/openal_out.cpp index 363097c3e..f0d5b1c0e 100644 --- a/sound/outputs/openal_out.cpp +++ b/sound/outputs/openal_out.cpp @@ -140,6 +140,13 @@ void OpenAL_Sound::setVolume(float volume) checkALError("setting volume"); } +void OpenAL_Sound::setRange(float a, float b, float) +{ + alSourcef(inst, AL_REFERENCE_DISTANCE, a); + alSourcef(inst, AL_MAX_DISTANCE, b); + checkALError("setting sound ranges"); +} + void OpenAL_Sound::setPos(float x, float y, float z) { alSource3f(inst, AL_POSITION, x, y, z); diff --git a/sound/outputs/openal_out.hpp b/sound/outputs/openal_out.hpp index 084128e89..c22be0de7 100644 --- a/sound/outputs/openal_out.hpp +++ b/sound/outputs/openal_out.hpp @@ -41,6 +41,11 @@ class OpenAL_Sound : public Sound void setStreaming(bool) {} // Not implemented yet SoundPtr clone() const; + // a = AL_REFERENCE_DISTANCE + // b = AL_MAX_DISTANCE + // c = ignored + void setRange(float a, float b=0.0, float c=0.0); + /// Not implemented void setPan(float) {} }; diff --git a/sound/tests/output/openal_mpg123_test.out b/sound/tests/output/openal_mpg123_test.out new file mode 100644 index 000000000..e55dabbb1 --- /dev/null +++ b/sound/tests/output/openal_mpg123_test.out @@ -0,0 +1 @@ +Please specify an MP3 file