00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef SOUND_H
00030 #define SOUND_H
00031 #define SOUND_DEBUG 0 //1 allows debug statements to be output
00032
00033
00034 #include <iostream>
00035
00036 #include <string>
00037 #include <vector>
00038
00039
00040 #include "SDL.h"
00041 using namespace std;
00042 using std::string;
00043
00044 #ifndef NOSOUND //define NOSOUND (in Makefile) if you don't have a working soundcard or SDL_mixer
00045 #include "SDL_mixer.h"
00046 #endif
00047
00048
00049
00050 #ifdef NOSOUND //don't want sound, need empty function replacements
00051 typedef struct{
00052 int garbage;
00053 }Mix_Music;
00054 typedef struct{
00055 int garbage;
00056 }Mix_Chunk;
00057 #endif
00058
00059 class Sound{
00060 private:
00061 SDL_AudioSpec spec;
00062 int NUM_SAMPLES;
00063 Mix_Music *bgm;
00064 struct Mix_Chunk *sfx;
00065 vector<string> sfx_name;
00066 int sfx_loaded[];
00067 int bgm_loop;
00068 char *bgm_name;
00069 int bgm_loaded;
00070 int play_flag;
00071 int volume;
00072 static int init_done;
00073 public:
00074 Sound(int);
00075 Sound();
00076 ~Sound();
00077
00078 int load_bgm (string filename);
00079 int load_sfx (string filename);
00080 int get_status ();
00081 int play_bgm ();
00082 int play_sample_name (string name);
00083 int play_sample_number (int number);
00084 int stop_all ();
00085 int pause_all ();
00086 int resume_all ();
00087 void raise_volume ();
00088 void lower_volume ();
00089 void set_volume (int volume);
00090 };
00091
00092 #endif
00093
00094
00095