From ea76b6988ccafaa6a4d4ed90f2489d0e49e1f180 Mon Sep 17 00:00:00 2001 From: Benjamin Barenblat Date: Sat, 5 Sep 2015 09:32:30 -0400 Subject: Imported Upstream version 0.40.24 --- g_src/music_and_sound_openal.h | 82 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100755 g_src/music_and_sound_openal.h (limited to 'g_src/music_and_sound_openal.h') diff --git a/g_src/music_and_sound_openal.h b/g_src/music_and_sound_openal.h new file mode 100755 index 0000000..b4f3de9 --- /dev/null +++ b/g_src/music_and_sound_openal.h @@ -0,0 +1,82 @@ +#ifndef MUSIC_AND_SOUND_OPENAL_H +#define MUSIC_AND_SOUND_OPENAL_H + +#include +#include + +// HACKY HACKY HACK +// Fixes sndfile.h, until the bug is properly fixed +#include +#include +#define _MSCVER +typedef int64_t __int64; +#include +#undef _MSCVER +// END HACKY HACKY HACK + +#include +#include +#include +#include +#include +#include + +#define SOUND_CHANNELNUM 16 + +// Preferred mixer frequency. Should be the same as what the ogg files +// use, to avoid resampling. +#define SOUND_FREQUENCY 44100 + +// If the bool is false, a sound; otherwise a song +typedef std::pair slot; + +class musicsoundst +{ + public: + bool initsound(); // Returns false if it failed + void update() {} + void set_master_volume(long newvol); + + void set_song(std::string &filename, slot slot); + void set_song(std::string &filename, int slot); + void playsound(slot slot); + void playsound(int slot); // Assumes sound + + void startbackgroundmusic(slot slot); + void startbackgroundmusic(int slot); // Assumes song + void stopbackgroundmusic(); + void stop_sound(); + void stop_sound(slot slot); + void playsound(int s,int channel); + void set_sound(std::string &filename,int slot,int pan=-1,int priority=0); + void deinitsound(); + + // Deprecated: + void forcebackgroundmusic(int slot, unsigned long time); + void playsound(int s,int min_channel,int max_channel,int force_channel); + void set_sound_params(int slot,int p1,int vol,int pan,int priority); + + musicsoundst() { + functional = false; + background_slot = slot(false,-1); + } + + ~musicsoundst() { + deinitsound(); + } + + private: + bool functional; + ALCdevice *device; + ALCcontext *context; + + std::map buffers; // OpenAL buffers + std::map sources; // And sources + std::map slot_buffer; // Mappings from DF slots to openal + std::map slot_source; + + slot background_slot; // Currently playing background music, or -1 +}; + + +#endif -- cgit v1.2.3