Streamline the archive loading mechanism
[tennix.git] / sound.h
blob87b765af6d802bcd75dd997b5879f1fe4eaea7e3
2 /**
4 * Tennix! SDL Port
5 * Copyright (C) 2003, 2007, 2008, 2009 Thomas Perl <thp@thpinfo.com>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20 * MA 02110-1301, USA.
22 **/
24 #ifndef __SOUND_H
25 #define __SOUND_H
27 #include "archive.hh"
29 #include "SDL_mixer.h"
31 #define FADE_OUT_MS 500
32 #define FADE_IN_MS 3000
34 #define VOICE_QUEUE_MAX 10
36 extern int voice_finished_flag;
38 typedef unsigned char sound_id;
39 enum {
40 SOUND_RAIN = 0,
41 SOUND_RACKET1,
42 SOUND_RACKET2,
43 SOUND_GROUND1,
44 SOUND_GROUND2,
45 SOUND_AUDIENCE,
46 SOUND_APPLAUSE,
47 SOUND_OUT,
48 SOUND_BACKGROUND,
49 SOUND_MOUSEOVER,
50 SOUND_MOUSECLICK,
52 #ifdef HAVE_VOICE_FILES
53 VOICE_TO,
54 VOICE_ALL,
55 VOICE_LOVE_IN,
56 VOICE_LOVE_OUT,
57 VOICE_FIFTEEN_IN,
58 VOICE_FIFTEEN_OUT,
59 VOICE_THIRTY_IN,
60 VOICE_THIRTY_OUT,
61 VOICE_FORTY_IN,
62 VOICE_FORTY_OUT,
63 VOICE_DEUCE,
64 VOICE_ADVANTAGE_PLAYER_ONE,
65 VOICE_ADVANTAGE_PLAYER_TWO,
67 VOICE_ZERO_IN,
68 VOICE_ZERO_OUT,
69 VOICE_ONE_IN,
70 VOICE_ONE_OUT,
71 VOICE_TWO_IN,
72 VOICE_TWO_OUT,
73 VOICE_THREE_IN,
74 VOICE_THREE_OUT,
75 VOICE_FOUR_IN,
76 VOICE_FOUR_OUT,
77 VOICE_FIVE_IN,
78 VOICE_FIVE_OUT,
79 VOICE_SIX_IN,
80 VOICE_SIX_OUT,
81 VOICE_SEVEN_IN,
82 VOICE_SEVEN_OUT,
84 VOICE_IN_THE_FIRST_SET,
85 VOICE_IN_THE_SECOND_SET,
86 VOICE_IN_THE_THIRD_SET,
87 VOICE_IN_THE_FOURTH_SET,
88 VOICE_IN_THE_FIFTH_SET,
90 VOICE_QUIT_IT1,
91 VOICE_QUIT_IT2,
92 VOICE_QUIT_IT3,
93 VOICE_QUIT_IT4,
95 VOICE_NEW_GAME1,
96 VOICE_NEW_GAME2,
97 VOICE_NEW_GAME3,
98 VOICE_NEW_GAME4,
99 VOICE_NEW_GAME5,
100 VOICE_NEW_GAME6,
102 VOICE_LETS_GO1,
103 VOICE_LETS_GO2,
104 VOICE_LETS_GO3,
105 VOICE_LETS_GO4,
106 #endif
108 SOUND_MAX
111 #define LAST_SOUNDEFFECT_ID SOUND_MOUSECLICK
113 /* Channel by id gives: 1-N (of 0-N) */
114 #define CHANNEL_BY_ID(id, numchannels) ((id)%numchannels+1)
115 #define CHANNEL_VOICE 0
117 #define SOUND_RACKET_FIRST SOUND_RACKET1
118 #define SOUND_RACKET_LAST SOUND_RACKET2
119 #define SOUND_GROUND_FIRST SOUND_GROUND1
120 #define SOUND_GROUND_LAST SOUND_GROUND2
121 #ifdef HAVE_VOICE_FILES
122 # define VOICE_QUIT_IT_FIRST VOICE_QUIT_IT1
123 # define VOICE_QUIT_IT_LAST VOICE_QUIT_IT4
124 # define VOICE_NEW_GAME_FIRST VOICE_NEW_GAME1
125 # define VOICE_NEW_GAME_LAST VOICE_NEW_GAME6
126 # define VOICE_LETS_GO_FIRST VOICE_LETS_GO1
127 # define VOICE_LETS_GO_LAST VOICE_LETS_GO4
128 #endif
130 #define SOUND_GROUND (SOUND_GROUND_FIRST + rand()%(SOUND_GROUND_LAST-SOUND_GROUND_FIRST+1))
131 #define SOUND_RACKET (SOUND_RACKET_FIRST + rand()%(SOUND_RACKET_LAST-SOUND_RACKET_FIRST+1))
132 #ifdef HAVE_VOICE_FILES
133 # define VOICE_QUIT_IT (VOICE_QUIT_IT_FIRST + rand()%(VOICE_QUIT_IT_LAST-VOICE_QUIT_IT_FIRST+1))
134 # define VOICE_NEW_GAME (VOICE_NEW_GAME_FIRST + rand()%(VOICE_NEW_GAME_LAST-VOICE_NEW_GAME_FIRST+1))
135 # define VOICE_LETS_GO (VOICE_LETS_GO_FIRST + rand()%(VOICE_LETS_GO_LAST-VOICE_LETS_GO_FIRST+1))
136 #endif
138 typedef struct {
139 Mix_Chunk* data;
140 } Sound;
142 void init_sound(TennixArchive& tnxar);
144 void play_sample_n(sound_id id, int n);
145 #define play_sample(id) play_sample_n(id,0)
146 #define play_sample_loop(id) play_sample_n(id,-1)
147 #define play_sample_background(id) play_sample_n(id,-2)
148 void stop_sample(sound_id id);
149 void sample_volume(sound_id id, float volume);
150 void sample_volume_group(sound_id first, sound_id last, float volume);
151 void pan_sample(sound_id id, float position);
152 void pan_sample_group(sound_id first, sound_id last, float position);
153 #define unpan_sample(id) pan_sample(id,0.5)
155 void voice_clear();
156 void voice_enqueue(sound_id id);
157 void voice_say();
158 void voice_say_list(int n, ...);
159 void voice_channel_finished(int channel);
161 #endif