00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef __AUDIO_H__
00016 #define __AUDIO_H__
00017
00018 #include <SDL/SDL_mixer.h>
00019 #include "prefs.h"
00020 #include "py_object.h"
00021
00022
00023
00024 #define NUM_WAVES 5
00025
00026 #define NUM_MUSIC 3
00027
00028 #define NUM_CHANNELS 4
00029
00030 class audio
00031 {
00032 public:
00033 static void init(config*);
00034 static void cleanup(void);
00035
00036
00037 static s_int8 put_state (ogzstream& file);
00038 static s_int8 get_state (igzstream& file);
00039
00040
00041
00042 static int load_background(int slot, char *filename);
00043 static void unload_background(int slot);
00044
00045
00046 static void set_background_volume(int);
00047
00048
00049 static void pause_music(void);
00050 static void unpause_music(void);
00051
00052
00053 static int load_wave(int slot, char *filename);
00054 static void unload_wave(int slot);
00055
00056
00057 static void play_wave(int channel, int slot);
00058 static void play_background(int slot);
00059
00060
00061
00062 static void fade_in_background(int slot, int time);
00063 static void fade_out_background(int time);
00064
00065
00066 static void change_background(int slot, int time);
00067
00068 static bool is_initialized () { return audio_initialized; }
00069 static bool is_schedule_activated () { return schedule_active; }
00070 static bool is_background_finished () { return !Mix_PlayingMusic (); }
00071
00072 static void set_schedule_active (bool a) { schedule_active = a; }
00073
00074 static void set_schedule (string file, PyObject * args = NULL);
00075 static void run_schedule ();
00076
00077 #ifdef OGG_MUSIC
00078
00079
00080
00081
00082
00083
00084
00085 #endif
00086
00087 private:
00088 #ifndef SWIG
00089 static bool schedule_active;
00090 static bool audio_initialized;
00091 static int background_volume;
00092 static int effects_volume;
00093 static Mix_Music *music[NUM_MUSIC];
00094 static string music_file[NUM_MUSIC];
00095 static Mix_Chunk *sounds[NUM_WAVES];
00096 static int current_background;
00097 static int last_background;
00098 static bool background_paused;
00099 static int audio_rate;
00100 static Uint16 buffer_size;
00101 static Uint16 audio_format;
00102 static int audio_channels;
00103 static py_object schedule;
00104 static PyObject *schedule_args;
00105 #endif
00106 };
00107
00108 #endif