added asking for and uploading tapes to score server (only once)
[rocksndiamonds.git] / src / libgame / sound.h
1 // ============================================================================
2 // Artsoft Retro-Game Library
3 // ----------------------------------------------------------------------------
4 // (c) 1995-2014 by Artsoft Entertainment
5 //                  Holger Schemel
6 //                  info@artsoft.org
7 //                  https://www.artsoft.org/
8 // ----------------------------------------------------------------------------
9 // sound.h
10 // ============================================================================
11
12 #ifndef SOUND_H
13 #define SOUND_H
14
15 #include "system.h"
16
17
18 // values for platform specific sound initialization
19 #define AUDIO_SAMPLE_RATE_22050         22050
20
21 #define AUDIO_FRAGMENT_SIZE_512         512
22 #define AUDIO_FRAGMENT_SIZE_1024        1024
23 #define AUDIO_FRAGMENT_SIZE_2048        2048
24 #define AUDIO_FRAGMENT_SIZE_4096        4096
25 #define AUDIO_FRAGMENT_SIZE_32768       32768
26
27 #define AUDIO_NUM_CHANNELS_MONO         1
28 #define AUDIO_NUM_CHANNELS_STEREO       2
29
30 #define AUDIO_FORMAT_UNKNOWN            (0)
31 #define AUDIO_FORMAT_U8                 (1 << 0)
32 #define AUDIO_FORMAT_S16                (1 << 1)
33 #define AUDIO_FORMAT_LE                 (1 << 2)
34 #define AUDIO_FORMAT_BE                 (1 << 3)
35
36 #define DEFAULT_AUDIO_SAMPLE_RATE       AUDIO_SAMPLE_RATE_22050
37
38 #if defined(PLATFORM_WIN32)
39 #define DEFAULT_AUDIO_FRAGMENT_SIZE     AUDIO_FRAGMENT_SIZE_1024
40 #else
41 #define DEFAULT_AUDIO_FRAGMENT_SIZE     AUDIO_FRAGMENT_SIZE_512
42 #endif
43
44 #define NUM_MIXER_CHANNELS              MIX_CHANNELS
45
46 #define MUSIC_CHANNEL                   0
47 #define FIRST_SOUND_CHANNEL             1
48
49
50 // values for PlaySound(), StopSound() and friends
51 #define SND_CTRL_NONE                   (0)
52 #define SND_CTRL_MUSIC                  (1 << 0)
53 #define SND_CTRL_LOOP                   (1 << 1)
54 #define SND_CTRL_FADE                   (1 << 2)
55 #define SND_CTRL_STOP                   (1 << 3)
56 #define SND_CTRL_ALL_SOUNDS             (1 << 4)
57 #define SND_CTRL_RELOAD_SOUNDS          (1 << 5)
58 #define SND_CTRL_RELOAD_MUSIC           (1 << 6)
59 #define SND_CTRL_EXPIRE_LOOPS           (1 << 7)
60
61 #define SND_CTRL_PLAY_SOUND             (SND_CTRL_NONE)
62 #define SND_CTRL_PLAY_LOOP              (SND_CTRL_LOOP)
63 #define SND_CTRL_PLAY_MUSIC             (SND_CTRL_MUSIC)
64 #define SND_CTRL_PLAY_MUSIC_LOOP        (SND_CTRL_MUSIC | SND_CTRL_LOOP)
65
66 #define SND_CTRL_FADE_SOUND             (SND_CTRL_FADE)
67 #define SND_CTRL_FADE_MUSIC             (SND_CTRL_FADE | SND_CTRL_MUSIC)
68 #define SND_CTRL_FADE_ALL               (SND_CTRL_FADE | SND_CTRL_ALL_SOUNDS)
69
70 #define SND_CTRL_STOP_SOUND             (SND_CTRL_STOP)
71 #define SND_CTRL_STOP_MUSIC             (SND_CTRL_STOP | SND_CTRL_MUSIC)
72 #define SND_CTRL_STOP_ALL               (SND_CTRL_STOP | SND_CTRL_ALL_SOUNDS)
73
74 #define IS_MUSIC(x)                     ((x).state & SND_CTRL_MUSIC)
75 #define IS_LOOP(x)                      ((x).state & SND_CTRL_LOOP)
76 #define IS_FADING(x)                    ((x).state & SND_CTRL_FADE)
77 #define IS_STOPPING(x)                  ((x).state & SND_CTRL_STOP)
78 #define IS_RELOADING(x)                 ((x).state & (SND_CTRL_RELOAD_SOUNDS |\
79                                                       SND_CTRL_RELOAD_MUSIC))
80 #define ALL_SOUNDS(x)                   ((x).state & SND_CTRL_ALL_SOUNDS)
81 #define SET_EXPIRE_LOOPS(x)             ((x).state & SND_CTRL_EXPIRE_LOOPS)
82
83 #define MAP_NOCONF_MUSIC(x)             (-((x) + 1))
84 #define UNMAP_NOCONF_MUSIC(x)           MAP_NOCONF_MUSIC(x)
85
86
87 #define SOUND_MIN_VOLUME                0
88 #define SOUND_MAX_VOLUME                SDL_MIX_MAXVOLUME
89
90 #define SOUND_MAX_LEFT                  0
91 #define SOUND_MAX_RIGHT                 255
92 #define SOUND_MAX_LEFT2RIGHT            255
93 #define SOUND_MIDDLE                    (SOUND_MAX_LEFT2RIGHT / 2)
94
95
96 // general sound functions
97 void UnixOpenAudio(void);
98 void UnixCloseAudio(void);
99
100 // mixer functions
101 void Mixer_InitChannels(void);
102 void StartMixer(void);
103
104 // sound client functions
105 void PlayMusic(int);
106 void PlayMusicLoop(int);
107 void PlaySound(int);
108 void PlaySoundStereo(int, int);
109 void PlaySoundLoop(int);
110 void PlaySoundMusic(int);
111 void PlaySoundMusicLoop(int);
112 void PlaySoundExt(int, int, int, int);
113 void FadeMusic(void);
114 void FadeSound(int);
115 void FadeSounds(void);
116 void FadeSoundsAndMusic(void);
117 void StopMusic(void);
118 void StopSound(int);
119 void StopSounds(void);
120 void StopSoundExt(int, int);
121 void ExpireSoundLoops(boolean);
122
123 int getSoundListSize(void);
124 int getMusicListSize(void);
125 struct FileInfo *getSoundListEntry(int);
126 struct FileInfo *getMusicListEntry(int);
127 char *getMusicInfoEntryFilename(int);
128 char *getCurrentlyPlayingMusicFilename(void);
129 int getSoundListPropertyMappingSize(void);
130 int getMusicListPropertyMappingSize(void);
131 struct PropertyMapping *getSoundListPropertyMapping(void);
132 struct PropertyMapping *getMusicListPropertyMapping(void);
133 void InitSoundList(struct ConfigInfo *, int, struct ConfigTypeInfo *,
134                    char **, char **, char **, char **, char **);
135 void InitMusicList(struct ConfigInfo *, int, struct ConfigTypeInfo *,
136                    char **, char **, char **, char **, char **);
137 void InitReloadCustomSounds(char *);
138 void InitReloadCustomMusic(char *);
139 void FreeAllSounds(void);
140 void FreeAllMusic(void);
141
142 #endif