curses.h: need to define a magic flag to pull widechar support
[rofl0r-df-libgraphics.git] / g_src / music_and_sound_openal.h
blobb4f3de92900f2b7dc076635e8cfd0a9d756ae531
1 #ifndef MUSIC_AND_SOUND_OPENAL_H
2 #define MUSIC_AND_SOUND_OPENAL_H
4 #include <AL/al.h>
5 #include <AL/alc.h>
7 // HACKY HACKY HACK
8 // Fixes sndfile.h, until the bug is properly fixed
9 #include <stdio.h>
10 #include <sys/types.h>
11 #define _MSCVER
12 typedef int64_t __int64;
13 #include <sndfile.h>
14 #undef _MSCVER
15 // END HACKY HACKY HACK
17 #include <string>
18 #include <vector>
19 #include <list>
20 #include <map>
21 #include <algorithm>
22 #include <utility>
24 #define SOUND_CHANNELNUM 16
26 // Preferred mixer frequency. Should be the same as what the ogg files
27 // use, to avoid resampling.
28 #define SOUND_FREQUENCY 44100
30 // If the bool is false, a sound; otherwise a song
31 typedef std::pair<bool,int> slot;
33 class musicsoundst
35 public:
36 bool initsound(); // Returns false if it failed
37 void update() {}
38 void set_master_volume(long newvol);
40 void set_song(std::string &filename, slot slot);
41 void set_song(std::string &filename, int slot);
42 void playsound(slot slot);
43 void playsound(int slot); // Assumes sound
45 void startbackgroundmusic(slot slot);
46 void startbackgroundmusic(int slot); // Assumes song
47 void stopbackgroundmusic();
48 void stop_sound();
49 void stop_sound(slot slot);
50 void playsound(int s,int channel);
51 void set_sound(std::string &filename,int slot,int pan=-1,int priority=0);
52 void deinitsound();
54 // Deprecated:
55 void forcebackgroundmusic(int slot, unsigned long time);
56 void playsound(int s,int min_channel,int max_channel,int force_channel);
57 void set_sound_params(int slot,int p1,int vol,int pan,int priority);
59 musicsoundst() {
60 functional = false;
61 background_slot = slot(false,-1);
64 ~musicsoundst() {
65 deinitsound();
68 private:
69 bool functional;
70 ALCdevice *device;
71 ALCcontext *context;
73 std::map<std::string,ALuint> buffers; // OpenAL buffers
74 std::map<std::string,ALuint> sources; // And sources
75 std::map<slot, ALuint> slot_buffer; // Mappings from DF slots to openal
76 std::map<slot, ALuint> slot_source;
78 slot background_slot; // Currently playing background music, or -1
82 #endif