aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClyne Sullivan <clyne@bitgloo.com>2019-10-03 12:47:40 -0400
committerClyne Sullivan <clyne@bitgloo.com>2019-10-03 12:47:40 -0400
commit52cfc041425a80ffd7ec63b3aaa94289ec61a977 (patch)
tree3d33ed1e3f1110952d338c8d67a3b8e38cccc216
parenteed19ec73698c8180a51c33fa56c7cfe7c0e60f0 (diff)
controlled sound fading
-rw-r--r--src/audio.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/audio.cpp b/src/audio.cpp
index 2f14c97..7a5934f 100644
--- a/src/audio.cpp
+++ b/src/audio.cpp
@@ -57,10 +57,13 @@ void AudioSystem::configure([[maybe_unused]] entityx::EntityManager& entities,
if (alutInitWithoutContext(nullptr, nullptr) != AL_TRUE)
return; // TODO Third uh oh
+ // Set up listener
ALfloat listenerOri[] = { 0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f };
alListener3f(AL_POSITION, 0, 0, 0.0f);
alListener3f(AL_VELOCITY, 0, 0, 0);
alListenerfv(AL_ORIENTATION, listenerOri);
+
+ alDistanceModel(AL_LINEAR_DISTANCE);
}
void AudioSystem::update(entityx::EntityManager& entities,
@@ -85,6 +88,9 @@ void AudioSystem::receive(const entityx::ComponentAddedEvent<Audio>& cae)
buf != AL_NONE) {
const_cast<Audio*>(cae.component.get())->buffer = buf;
alSourcei(cae.component->source, AL_BUFFER, buf);
+ // TODO Do these values need to be scaled to the world or window?
+ alSourcef(cae.component->source, AL_MAX_DISTANCE, 25);
+ alSourcef(cae.component->source, AL_REFERENCE_DISTANCE, 2);
std::cout << "Loaded audio: " << cae.component->fileName << std::endl;
}