1 // ============================================================================
2 // Artsoft Retro-Game Library
3 // ----------------------------------------------------------------------------
4 // (c) 1995-2014 by Artsoft Entertainment
7 // https://www.artsoft.org/
8 // ----------------------------------------------------------------------------
10 // ============================================================================
18 // values for platform specific sound initialization
19 #define AUDIO_SAMPLE_RATE_22050 22050
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
27 #define AUDIO_NUM_CHANNELS_MONO 1
28 #define AUDIO_NUM_CHANNELS_STEREO 2
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)
36 #define DEFAULT_AUDIO_SAMPLE_RATE AUDIO_SAMPLE_RATE_22050
38 #if defined(PLATFORM_WIN32)
39 #define DEFAULT_AUDIO_FRAGMENT_SIZE AUDIO_FRAGMENT_SIZE_1024
41 #define DEFAULT_AUDIO_FRAGMENT_SIZE AUDIO_FRAGMENT_SIZE_512
44 #define NUM_MIXER_CHANNELS MIX_CHANNELS
46 #define MUSIC_CHANNEL 0
47 #define FIRST_SOUND_CHANNEL 1
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)
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)
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)
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)
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)
83 #define MAP_NOCONF_MUSIC(x) (-((x) + 1))
84 #define UNMAP_NOCONF_MUSIC(x) MAP_NOCONF_MUSIC(x)
87 #define SOUND_MIN_VOLUME 0
88 #define SOUND_MAX_VOLUME SDL_MIX_MAXVOLUME
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)
96 // general sound functions
97 void UnixOpenAudio(void);
98 void UnixCloseAudio(void);
101 void Mixer_InitChannels(void);
102 void StartMixer(void);
104 // sound client functions
106 void PlayMusicLoop(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);
115 void FadeSounds(void);
116 void FadeSoundsAndMusic(void);
117 void StopMusic(void);
119 void StopSounds(void);
120 void StopSoundExt(int, int);
121 void ExpireSoundLoops(boolean);
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);