1 #ifndef __SOUND_MANAGER_H__
2 #define __SOUND_MANAGER_H__
10 #include "math/vector.hpp"
12 typedef void* SoundHandle;
16 class StreamSoundSource;
22 virtual ~SoundManager();
24 void enable_sound(bool sound_enabled);
26 * Creates a new sound source object which plays the specified soundfile.
27 * You are responsible for deleting the sound source later (this will stop the
29 * This function might throw exceptions. It returns 0 if no audio device is
32 SoundSource* create_sound_source(const std::string& filename);
34 * Convenience function to simply play a sound at a given position.
36 void play(const std::string& name, const Vector& pos = Vector(-1, -1));
38 void set_listener_position(const Vector& position);
39 void set_listener_velocity(const Vector& velocity);
41 void enable_music(bool music_enabled);
42 void play_music(const std::string& filename, bool fade = false);
43 void stop_music(bool fade = true);
48 friend class SoundSource;
49 friend class StreamSoundSource;
51 static ALuint load_file_into_buffer(const std::string& filename);
52 static ALenum get_sample_format(SoundFile* file);
54 void print_openal_version();
55 void check_alc_error(const char* message);
56 static void check_al_error(const char* message);
62 typedef std::map<std::string, ALuint> SoundBuffers;
64 typedef std::vector<SoundSource*> SoundSources;
67 StreamSoundSource* music_source;
70 std::string current_music;
73 extern SoundManager* sound_manager;