Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/audio/audio.cc')
-rw-r--r--src/audio/audio.cc41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/audio/audio.cc b/src/audio/audio.cc
index 1895d21..ff0918d 100644
--- a/src/audio/audio.cc
+++ b/src/audio/audio.cc
@@ -91,4 +91,45 @@ void play(const char *name)
}
}
+void update_source(size_t source_index, math::Vector3f const & location, math::Vector3f const & velocity, float pitch, float gain)
+{
+ ALuint source = Sources::source(source_index);
+ alSourcefv(source, AL_POSITION, location.ptr());
+ //alSourcefv(source, AL_VELOCITY, velocity.ptr());
+ alSourcef(source, AL_PITCH, pitch);
+ alSourcef(source, AL_GAIN, gain);
+}
+
+void loop( size_t source_index, const char *name, float pitch, float gain)
+{
+ if (!audio_context)
+ return;
+
+ ALuint source = Sources::source(source_index);
+ Buffers::bind(source, Buffers::load(std::string(name)));
+
+ alSourcef(source, AL_PITCH, pitch);
+ alSourcef(source, AL_GAIN, gain);
+
+ alSourcei(source, AL_LOOPING, AL_TRUE);
+ alSourceRewind(source);
+ alSourcePlay(source);
+}
+
+void update_listener(math::Vector3f const &location, math::Axis const &axis, float speed)
+{
+ alListenerfv(AL_POSITION, location.ptr());
+
+ math::Vector3f velocity(axis.forward());
+ velocity = velocity * speed;
+ //alListenerfv(AL_VELOCITY, velocity.ptr());
+
+ ALfloat orientation[6];
+ for (size_t i =0; i <3; i++) {
+ orientation[i] = axis.forward()[i];
+ orientation[i+3] = axis.up()[i];
+ }
+ alListenerfv(AL_ORIENTATION, orientation);
+}
+
}