Tennix 0.6.0 and documentation updates
[tennix.git] / sound.h
blob75c160fecaaa8d84ad63ede7160a3885c5baa2bd
2 /**
4 * Tennix! SDL Port
5 * Copyright (C) 2003, 2007, 2008 Thomas Perl <thp@perli.net>
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 typedef unsigned char sound_id;
33 enum {
34 SOUND_RACKET1 = 0,
35 SOUND_RACKET2,
36 SOUND_GROUND1,
37 SOUND_GROUND2,
38 SOUND_AUDIENCE,
39 SOUND_APPLAUSE,
40 SOUND_OUT,
41 SOUND_BACKGROUND,
42 SOUND_MAX,
45 #define SOUND_RACKET_FIRST SOUND_RACKET1
46 #define SOUND_RACKET_LAST SOUND_RACKET2
47 #define SOUND_GROUND_FIRST SOUND_GROUND1
48 #define SOUND_GROUND_LAST SOUND_GROUND2
50 #define SOUND_GROUND (SOUND_GROUND_FIRST + rand()%(SOUND_GROUND_LAST-SOUND_GROUND_FIRST))
51 #define SOUND_RACKET (SOUND_RACKET_FIRST + rand()%(SOUND_RACKET_LAST-SOUND_RACKET_FIRST))
53 typedef struct {
54 Mix_Chunk* data;
55 } Sound;
57 void init_sound();
59 void play_sample_n(sound_id id, int n);
60 #define play_sample(id) play_sample_n(id,0)
61 #define play_sample_loop(id) play_sample_n(id,-1)
62 #define play_sample_background(id) play_sample_n(id,-2)
63 void stop_sample(sound_id id);
64 void pan_sample(sound_id id, float position);
65 #define unpan_sample(id) pan_sample(id,0.5)
67 #endif