major cleanup of preprocessor hell
[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 //                  http://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
60 #define SND_CTRL_PLAY_SOUND             (SND_CTRL_NONE)
61 #define SND_CTRL_PLAY_LOOP              (SND_CTRL_LOOP)
62 #define SND_CTRL_PLAY_MUSIC             (SND_CTRL_LOOP | SND_CTRL_MUSIC)
63
64 #define SND_CTRL_FADE_SOUND             (SND_CTRL_FADE)
65 #define SND_CTRL_FADE_MUSIC             (SND_CTRL_FADE | SND_CTRL_MUSIC)
66 #define SND_CTRL_FADE_ALL               (SND_CTRL_FADE | SND_CTRL_ALL_SOUNDS)
67
68 #define SND_CTRL_STOP_SOUND             (SND_CTRL_STOP)
69 #define SND_CTRL_STOP_MUSIC             (SND_CTRL_STOP | SND_CTRL_MUSIC)
70 #define SND_CTRL_STOP_ALL               (SND_CTRL_STOP | SND_CTRL_ALL_SOUNDS)
71
72 #define IS_MUSIC(x)                     ((x).state & SND_CTRL_MUSIC)
73 #define IS_LOOP(x)                      ((x).state & SND_CTRL_LOOP)
74 #define IS_FADING(x)                    ((x).state & SND_CTRL_FADE)
75 #define IS_STOPPING(x)                  ((x).state & SND_CTRL_STOP)
76 #define IS_RELOADING(x)                 ((x).state & (SND_CTRL_RELOAD_SOUNDS |\
77                                                       SND_CTRL_RELOAD_MUSIC))
78 #define ALL_SOUNDS(x)                   ((x).state & SND_CTRL_ALL_SOUNDS)
79
80 #define MAP_NOCONF_MUSIC(x)             (-((x) + 1))
81 #define UNMAP_NOCONF_MUSIC(x)           MAP_NOCONF_MUSIC(x)
82
83
84 #define SOUND_MIN_VOLUME                0
85 #define SOUND_MAX_VOLUME                SDL_MIX_MAXVOLUME
86
87 #define SOUND_MAX_LEFT                  0
88 #define SOUND_MAX_RIGHT                 255
89 #define SOUND_MAX_LEFT2RIGHT            255
90 #define SOUND_MIDDLE                    (SOUND_MAX_LEFT2RIGHT / 2)
91
92
93 /* general sound functions */
94 void UnixOpenAudio(void);
95 void UnixCloseAudio(void);
96
97 /* mixer functions */ 
98 void Mixer_InitChannels(void);
99 void StartMixer(void);
100
101 /* sound client functions */
102 void PlayMusic(int);
103 void PlaySound(int);
104 void PlaySoundStereo(int, int);
105 void PlaySoundLoop(int);
106 void PlaySoundMusic(int);
107 void PlaySoundExt(int, int, int, int);
108 void FadeMusic(void);
109 void FadeSound(int);
110 void FadeSounds(void);
111 void FadeSoundsAndMusic(void);
112 void StopMusic(void);
113 void StopSound(int);
114 void StopSounds(void);
115 void StopSoundExt(int, int);
116
117 int getSoundListSize();
118 int getMusicListSize();
119 struct FileInfo *getSoundListEntry(int);
120 struct FileInfo *getMusicListEntry(int);
121 int getSoundListPropertyMappingSize();
122 int getMusicListPropertyMappingSize();
123 struct PropertyMapping *getSoundListPropertyMapping();
124 struct PropertyMapping *getMusicListPropertyMapping();
125 void InitSoundList(struct ConfigInfo *, int, struct ConfigTypeInfo *,
126                    char **, char **, char **, char **, char **);
127 void InitMusicList(struct ConfigInfo *, int, struct ConfigTypeInfo *,
128                    char **, char **, char **, char **, char **);
129 void InitReloadCustomSounds(char *);
130 void InitReloadCustomMusic(char *);
131 void FreeAllSounds(void);
132 void FreeAllMusic(void);
133
134 #endif