cleanup of BD style game elements in level editor
[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 #define AUDIO_SAMPLE_RATE_44100         44100
21
22 #define AUDIO_FRAGMENT_SIZE_512         512
23 #define AUDIO_FRAGMENT_SIZE_1024        1024
24 #define AUDIO_FRAGMENT_SIZE_2048        2048
25 #define AUDIO_FRAGMENT_SIZE_4096        4096
26 #define AUDIO_FRAGMENT_SIZE_32768       32768
27
28 #define AUDIO_NUM_CHANNELS_MONO         1
29 #define AUDIO_NUM_CHANNELS_STEREO       2
30
31 #define AUDIO_FORMAT_UNKNOWN            (0)
32 #define AUDIO_FORMAT_U8                 (1 << 0)
33 #define AUDIO_FORMAT_S16                (1 << 1)
34 #define AUDIO_FORMAT_LE                 (1 << 2)
35 #define AUDIO_FORMAT_BE                 (1 << 3)
36
37 #define DEFAULT_AUDIO_SAMPLE_RATE       AUDIO_SAMPLE_RATE_22050
38
39 #if defined(PLATFORM_WINDOWS)
40 #define DEFAULT_AUDIO_FRAGMENT_SIZE     AUDIO_FRAGMENT_SIZE_1024
41 #else
42 #define DEFAULT_AUDIO_FRAGMENT_SIZE     AUDIO_FRAGMENT_SIZE_512
43 #endif
44
45 #define NUM_MIXER_CHANNELS              MIX_CHANNELS
46
47 #define MUSIC_CHANNEL                   0
48 #define FIRST_SOUND_CHANNEL             1
49
50
51 // values for PlaySound(), StopSound() and friends
52 #define SND_CTRL_NONE                   (0)
53 #define SND_CTRL_MUSIC                  (1 << 0)
54 #define SND_CTRL_LOOP                   (1 << 1)
55 #define SND_CTRL_FADE                   (1 << 2)
56 #define SND_CTRL_STOP                   (1 << 3)
57 #define SND_CTRL_ALL_SOUNDS             (1 << 4)
58 #define SND_CTRL_RELOAD_SOUNDS          (1 << 5)
59 #define SND_CTRL_RELOAD_MUSIC           (1 << 6)
60 #define SND_CTRL_EXPIRE_LOOPS           (1 << 7)
61
62 #define SND_CTRL_PLAY_SOUND             (SND_CTRL_NONE)
63 #define SND_CTRL_PLAY_LOOP              (SND_CTRL_LOOP)
64 #define SND_CTRL_PLAY_MUSIC             (SND_CTRL_MUSIC)
65 #define SND_CTRL_PLAY_MUSIC_LOOP        (SND_CTRL_MUSIC | SND_CTRL_LOOP)
66
67 #define SND_CTRL_FADE_SOUND             (SND_CTRL_FADE)
68 #define SND_CTRL_FADE_MUSIC             (SND_CTRL_FADE | SND_CTRL_MUSIC)
69 #define SND_CTRL_FADE_ALL               (SND_CTRL_FADE | SND_CTRL_ALL_SOUNDS)
70
71 #define SND_CTRL_STOP_SOUND             (SND_CTRL_STOP)
72 #define SND_CTRL_STOP_MUSIC             (SND_CTRL_STOP | SND_CTRL_MUSIC)
73 #define SND_CTRL_STOP_ALL               (SND_CTRL_STOP | SND_CTRL_ALL_SOUNDS)
74
75 #define IS_MUSIC(x)                     ((x).state & SND_CTRL_MUSIC)
76 #define IS_LOOP(x)                      ((x).state & SND_CTRL_LOOP)
77 #define IS_FADING(x)                    ((x).state & SND_CTRL_FADE)
78 #define IS_STOPPING(x)                  ((x).state & SND_CTRL_STOP)
79 #define IS_RELOADING(x)                 ((x).state & (SND_CTRL_RELOAD_SOUNDS |\
80                                                       SND_CTRL_RELOAD_MUSIC))
81 #define ALL_SOUNDS(x)                   ((x).state & SND_CTRL_ALL_SOUNDS)
82 #define SET_EXPIRE_LOOPS(x)             ((x).state & SND_CTRL_EXPIRE_LOOPS)
83
84 #define MAP_NOCONF_MUSIC(x)             (-((x) + 1))
85 #define UNMAP_NOCONF_MUSIC(x)           MAP_NOCONF_MUSIC(x)
86
87
88 #define SOUND_MIN_VOLUME                0
89 #define SOUND_MAX_VOLUME                SDL_MIX_MAXVOLUME
90
91 #define SOUND_MAX_LEFT                  0
92 #define SOUND_MAX_RIGHT                 255
93 #define SOUND_MAX_LEFT2RIGHT            255
94 #define SOUND_MIDDLE                    (SOUND_MAX_LEFT2RIGHT / 2)
95
96
97 // general sound functions
98 void UnixOpenAudio(void);
99 void UnixCloseAudio(void);
100
101 // mixer functions
102 void Mixer_InitChannels(void);
103 void StartMixer(void);
104
105 boolean isSoundPlaying(int);
106
107 // sound client functions
108 void PlayMusic(int);
109 void PlayMusicLoop(int);
110 void PlaySound(int);
111 void PlaySoundStereo(int, int);
112 void PlaySoundLoop(int);
113 void PlaySoundMusic(int);
114 void PlaySoundMusicLoop(int);
115 void PlaySoundExt(int, int, int, int);
116 void FadeMusic(void);
117 void FadeSound(int);
118 void FadeSounds(void);
119 void FadeSoundsAndMusic(void);
120 void StopMusic(void);
121 void StopSound(int);
122 void StopSounds(void);
123 void StopSoundExt(int, int);
124 void ExpireSoundLoops(boolean);
125
126 int getSoundListSize(void);
127 int getMusicListSize(void);
128 int getMusicListSize_NoConf(void);
129 struct FileInfo *getSoundListEntry(int);
130 struct FileInfo *getMusicListEntry(int);
131 char *getSoundInfoEntryFilename(int);
132 char *getMusicInfoEntryFilename(int);
133 char *getCurrentlyPlayingMusicFilename(void);
134 int getSoundListPropertyMappingSize(void);
135 int getMusicListPropertyMappingSize(void);
136 struct PropertyMapping *getSoundListPropertyMapping(void);
137 struct PropertyMapping *getMusicListPropertyMapping(void);
138 void InitSoundList(struct ConfigInfo *, int, struct ConfigTypeInfo *,
139                    char **, char **, char **, char **, char **);
140 void InitMusicList(struct ConfigInfo *, int, struct ConfigTypeInfo *,
141                    char **, char **, char **, char **, char **);
142 void InitReloadCustomSounds(void);
143 void InitReloadCustomMusic(void);
144 void FreeAllSounds(void);
145 void FreeAllMusic(void);
146
147 #endif