diff options
author | Stijn Buys <ingar@osirion.org> | 2008-07-17 14:19:18 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2008-07-17 14:19:18 +0000 |
commit | ae65ef53fc8b70ebee3b43bb06ecd091aaae2a26 (patch) | |
tree | d8a2a253314e0bab54edc9ee829aee819a7860bd /src/audio/audio.cc | |
parent | eb075660e7cb61b138c2da337115c59857f89e17 (diff) |
engine sounds
Diffstat (limited to 'src/audio/audio.cc')
-rw-r--r-- | src/audio/audio.cc | 41 |
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); +} + } |