Adonthell  0.4
audio.h
00001 /*
00002    $Id: audio.h,v 1.30 2008/01/19 16:02:16 ksterker Exp $
00003 
00004    Copyright (C) 2000 Andrew Henderson <hendersa@db.erau.edu>
00005    Part of the Adonthell Project http://adonthell.linuxgames.com
00006 
00007    This program is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License.
00009    This program is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY.
00011 
00012    See the COPYING file for more details.
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 // #include "audio_loop.h"
00022 
00023 // We'll only load five waves into memory
00024 #define NUM_WAVES 5
00025 // We'll only load three .ogg files into memory
00026 #define NUM_MUSIC 3
00027 // We can play four SFX at once
00028 #define NUM_CHANNELS 4
00029 
00030 class audio
00031 {
00032 public:
00033     static void init(config*);
00034     static void cleanup(void);
00035 
00036     // state saving/loading
00037     static s_int8 put_state (ogzstream& file);
00038     static s_int8 get_state (igzstream& file);
00039 
00040     // Background Music functions:
00041     // Use these to load/unload background music
00042     static int load_background(int slot, char *filename);
00043     static void unload_background(int slot);
00044 
00045     // All input is clamped from 0 to 100
00046     static void set_background_volume(int);
00047 
00048     // Use only when music is loaded
00049     static void pause_music(void);
00050     static void unpause_music(void);
00051 
00052     // Use these to load/unload wave files
00053     static int load_wave(int slot, char *filename);
00054     static void unload_wave(int slot);
00055 
00056     // Used to just start sounds playing
00057     static void play_wave(int channel, int slot);
00058     static void play_background(int slot);
00059 
00060     // Fade in and fade out background music (time in ms)
00061     // Fadeout unselects current tune when done
00062     static void fade_in_background(int slot, int time);
00063     static void fade_out_background(int time);
00064 
00065     // Temporary convience function to change background
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     // static loop_info *loop[NUM_MUSIC];
00079 
00080     // static int get_loop_start() { return loop[current_background]->start; }
00081     // static int get_loop_end() { return loop[current_background]->end; }
00082     // static int get_start_page_pcm() { return loop[current_background]->start_page_pcm; }
00083     // static int get_start_page_raw() { return loop[current_background]->start_page_raw; }
00084     // static OggVorbis_File* get_vorbisfile();
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