Adonthell  0.4
audio.h
1 /*
2  $Id: audio.h,v 1.30 2008/01/19 16:02:16 ksterker Exp $
3 
4  Copyright (C) 2000 Andrew Henderson <hendersa@db.erau.edu>
5  Part of the Adonthell Project http://adonthell.linuxgames.com
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #ifndef __AUDIO_H__
16 #define __AUDIO_H__
17 
18 #include <SDL/SDL_mixer.h>
19 #include "prefs.h"
20 #include "py_object.h"
21 // #include "audio_loop.h"
22 
23 // We'll only load five waves into memory
24 #define NUM_WAVES 5
25 // We'll only load three .ogg files into memory
26 #define NUM_MUSIC 3
27 // We can play four SFX at once
28 #define NUM_CHANNELS 4
29 
30 class audio
31 {
32 public:
33  static void init(config*);
34  static void cleanup(void);
35 
36  // state saving/loading
37  static s_int8 put_state (ogzstream& file);
38  static s_int8 get_state (igzstream& file);
39 
40  // Background Music functions:
41  // Use these to load/unload background music
42  static int load_background(int slot, char *filename);
43  static void unload_background(int slot);
44 
45  // All input is clamped from 0 to 100
46  static void set_background_volume(int);
47 
48  // Use only when music is loaded
49  static void pause_music(void);
50  static void unpause_music(void);
51 
52  // Use these to load/unload wave files
53  static int load_wave(int slot, char *filename);
54  static void unload_wave(int slot);
55 
56  // Used to just start sounds playing
57  static void play_wave(int channel, int slot);
58  static void play_background(int slot);
59 
60  // Fade in and fade out background music (time in ms)
61  // Fadeout unselects current tune when done
62  static void fade_in_background(int slot, int time);
63  static void fade_out_background(int time);
64 
65  // Temporary convience function to change background
66  static void change_background(int slot, int time);
67 
68  static bool is_initialized () { return audio_initialized; }
69  static bool is_schedule_activated () { return schedule_active; }
70  static bool is_background_finished () { return !Mix_PlayingMusic (); }
71 
72  static void set_schedule_active (bool a) { schedule_active = a; }
73 
74  static void set_schedule (string file, PyObject * args = NULL);
75  static void run_schedule ();
76 
77 #ifdef OGG_MUSIC
78  // static loop_info *loop[NUM_MUSIC];
79 
80  // static int get_loop_start() { return loop[current_background]->start; }
81  // static int get_loop_end() { return loop[current_background]->end; }
82  // static int get_start_page_pcm() { return loop[current_background]->start_page_pcm; }
83  // static int get_start_page_raw() { return loop[current_background]->start_page_raw; }
84  // static OggVorbis_File* get_vorbisfile();
85 #endif
86 
87 private:
88 #ifndef SWIG
89  static bool schedule_active;
90  static bool audio_initialized;
91  static int background_volume;
92  static int effects_volume;
93  static Mix_Music *music[NUM_MUSIC];
94  static string music_file[NUM_MUSIC];
95  static Mix_Chunk *sounds[NUM_WAVES];
96  static int current_background;
97  static int last_background;
98  static bool background_paused;
99  static int audio_rate;
100  static Uint16 buffer_size;
101  static Uint16 audio_format;
102  static int audio_channels;
103  static py_object schedule;
104  static PyObject *schedule_args;
105 #endif
106 };
107 
108 #endif
Class to write data from a Gzip compressed file.
Definition: fileops.h:223
Class to read data from a Gzip compressed file.
Definition: fileops.h:131
Python object class.
Definition: py_object.h:41
Adonthell's configuration.
Definition: audio.h:30
Declares the py_object class.
This class contains the engine's configuration read either from the config file or from the command l...
Definition: prefs.h:70
#define s_int8
8 bits long signed integer
Definition: types.h:38