Only use one sending socket; auto-determine ports
[tennix.git] / sound.h
blobb126c380258fe9e8b11718a04eb9383621a213da
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 "SDL_mixer.h"
29 #define FADE_OUT_MS 500
30 #define FADE_IN_MS 3000
32 #define VOICE_QUEUE_MAX 10
34 extern int voice_finished_flag;
36 typedef unsigned char sound_id;
37 enum {
38 SOUND_RAIN = 0,
39 SOUND_RACKET1,
40 SOUND_RACKET2,
41 SOUND_GROUND1,
42 SOUND_GROUND2,
43 SOUND_AUDIENCE,
44 SOUND_APPLAUSE,
45 SOUND_OUT,
46 SOUND_BACKGROUND,
47 SOUND_MOUSEOVER,
48 SOUND_MOUSECLICK,
50 #ifdef HAVE_VOICE_FILES
51 VOICE_TO,
52 VOICE_ALL,
53 VOICE_LOVE_IN,
54 VOICE_LOVE_OUT,
55 VOICE_FIFTEEN_IN,
56 VOICE_FIFTEEN_OUT,
57 VOICE_THIRTY_IN,
58 VOICE_THIRTY_OUT,
59 VOICE_FORTY_IN,
60 VOICE_FORTY_OUT,
61 VOICE_DEUCE,
62 VOICE_ADVANTAGE_PLAYER_ONE,
63 VOICE_ADVANTAGE_PLAYER_TWO,
65 VOICE_ZERO_IN,
66 VOICE_ZERO_OUT,
67 VOICE_ONE_IN,
68 VOICE_ONE_OUT,
69 VOICE_TWO_IN,
70 VOICE_TWO_OUT,
71 VOICE_THREE_IN,
72 VOICE_THREE_OUT,
73 VOICE_FOUR_IN,
74 VOICE_FOUR_OUT,
75 VOICE_FIVE_IN,
76 VOICE_FIVE_OUT,
77 VOICE_SIX_IN,
78 VOICE_SIX_OUT,
79 VOICE_SEVEN_IN,
80 VOICE_SEVEN_OUT,
82 VOICE_IN_THE_FIRST_SET,
83 VOICE_IN_THE_SECOND_SET,
84 VOICE_IN_THE_THIRD_SET,
85 VOICE_IN_THE_FOURTH_SET,
86 VOICE_IN_THE_FIFTH_SET,
88 VOICE_QUIT_IT1,
89 VOICE_QUIT_IT2,
90 VOICE_QUIT_IT3,
91 VOICE_QUIT_IT4,
93 VOICE_NEW_GAME1,
94 VOICE_NEW_GAME2,
95 VOICE_NEW_GAME3,
96 VOICE_NEW_GAME4,
97 VOICE_NEW_GAME5,
98 VOICE_NEW_GAME6,
100 VOICE_LETS_GO1,
101 VOICE_LETS_GO2,
102 VOICE_LETS_GO3,
103 VOICE_LETS_GO4,
104 #endif
106 SOUND_MAX
109 #define LAST_SOUNDEFFECT_ID SOUND_MOUSECLICK
111 /* Channel by id gives: 1-N (of 0-N) */
112 #define CHANNEL_BY_ID(id, numchannels) ((id)%numchannels+1)
113 #define CHANNEL_VOICE 0
115 #define SOUND_RACKET_FIRST SOUND_RACKET1
116 #define SOUND_RACKET_LAST SOUND_RACKET2
117 #define SOUND_GROUND_FIRST SOUND_GROUND1
118 #define SOUND_GROUND_LAST SOUND_GROUND2
119 #ifdef HAVE_VOICE_FILES
120 # define VOICE_QUIT_IT_FIRST VOICE_QUIT_IT1
121 # define VOICE_QUIT_IT_LAST VOICE_QUIT_IT4
122 # define VOICE_NEW_GAME_FIRST VOICE_NEW_GAME1
123 # define VOICE_NEW_GAME_LAST VOICE_NEW_GAME6
124 # define VOICE_LETS_GO_FIRST VOICE_LETS_GO1
125 # define VOICE_LETS_GO_LAST VOICE_LETS_GO4
126 #endif
128 #define SOUND_GROUND (SOUND_GROUND_FIRST + rand()%(SOUND_GROUND_LAST-SOUND_GROUND_FIRST+1))
129 #define SOUND_RACKET (SOUND_RACKET_FIRST + rand()%(SOUND_RACKET_LAST-SOUND_RACKET_FIRST+1))
130 #ifdef HAVE_VOICE_FILES
131 # define VOICE_QUIT_IT (VOICE_QUIT_IT_FIRST + rand()%(VOICE_QUIT_IT_LAST-VOICE_QUIT_IT_FIRST+1))
132 # define VOICE_NEW_GAME (VOICE_NEW_GAME_FIRST + rand()%(VOICE_NEW_GAME_LAST-VOICE_NEW_GAME_FIRST+1))
133 # define VOICE_LETS_GO (VOICE_LETS_GO_FIRST + rand()%(VOICE_LETS_GO_LAST-VOICE_LETS_GO_FIRST+1))
134 #endif
136 typedef struct {
137 Mix_Chunk* data;
138 } Sound;
140 void init_sound();
142 void play_sample_n(sound_id id, int n);
143 #define play_sample(id) play_sample_n(id,0)
144 #define play_sample_loop(id) play_sample_n(id,-1)
145 #define play_sample_background(id) play_sample_n(id,-2)
146 void stop_sample(sound_id id);
147 void sample_volume(sound_id id, float volume);
148 void sample_volume_group(sound_id first, sound_id last, float volume);
149 void pan_sample(sound_id id, float position);
150 void pan_sample_group(sound_id first, sound_id last, float position);
151 #define unpan_sample(id) pan_sample(id,0.5)
153 void voice_clear();
154 void voice_enqueue(sound_id id);
155 void voice_say();
156 void voice_say_list(int n, ...);
157 void voice_channel_finished(int channel);
159 #endif