summaryrefslogtreecommitdiff
path: root/src/sound_openal.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2012-03-24 19:01:26 +0200
committerPerttu Ahola <celeron55@gmail.com>2012-03-24 19:01:26 +0200
commit601d1936c9ab4787d43f55d67900ed7c46fd3452 (patch)
treeb328ea7a66ee7dc37fffddd0ee063a0c7b1ea10f /src/sound_openal.cpp
parent06e93f8d9508a23e86751dfae2f6a7e550d8e1af (diff)
downloadminetest-601d1936c9ab4787d43f55d67900ed7c46fd3452.tar.gz
minetest-601d1936c9ab4787d43f55d67900ed7c46fd3452.tar.bz2
minetest-601d1936c9ab4787d43f55d67900ed7c46fd3452.zip
Lua API for playing sounds
Diffstat (limited to 'src/sound_openal.cpp')
-rw-r--r--src/sound_openal.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/sound_openal.cpp b/src/sound_openal.cpp
index edcb9e8d4..26ad6fa4c 100644
--- a/src/sound_openal.cpp
+++ b/src/sound_openal.cpp
@@ -482,6 +482,24 @@ public:
maintain();
deleteSound(sound);
}
+ bool soundExists(int sound)
+ {
+ maintain();
+ return (m_sounds_playing.count(sound) != 0);
+ }
+ void updateSoundPosition(int id, v3f pos)
+ {
+ std::map<int, PlayingSound*>::iterator i =
+ m_sounds_playing.find(id);
+ if(i == m_sounds_playing.end())
+ return;
+ PlayingSound *sound = i->second;
+
+ alSourcei(sound->source_id, AL_SOURCE_RELATIVE, false);
+ alSource3f(sound->source_id, AL_POSITION, pos.X, pos.Y, pos.Z);
+ alSource3f(sound->source_id, AL_VELOCITY, 0, 0, 0);
+ alSourcef(sound->source_id, AL_REFERENCE_DISTANCE, 30.0);
+ }
};
ISoundManager *createOpenALSoundManager(OnDemandSoundFetcher *fetcher)