-
Notifications
You must be signed in to change notification settings - Fork 0
/
audioutils.h
40 lines (33 loc) · 996 Bytes
/
audioutils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef AUDIO_UTILS_H
#define AUDIO_UTILS_H
#include <SDL2/SDL_mixer.h>
#include "hashMap.h"
HASHMAP(SoundMap, const char*, Mix_Chunk*)
HASHMAP(MusicMap, const char*, Mix_Music*)
typedef enum AUDIO_FLAGS{
AUDIO_PLAYING=1,
AUDIO_PAUSED=2
}AUDIO_FLAGS;
typedef struct AudioHandler{
SoundMap sounds;
MusicMap music;
uint32_t audio_rate;
uint32_t audio_channels;
uint32_t audio_buffers;
uint16_t audio_format;
uint8_t flags;
/* music playing
* music paused
*/
}AudioHandler;
void audio_init(AudioHandler* ah);
void add_sound(AudioHandler* ah, const char* source, const char* name);
void add_music(AudioHandler* ah, const char* source, const char* name);
void play_sound(AudioHandler* ah, const char* name);
void play_music(AudioHandler* ah, const char* name);
uint8_t music_paused(AudioHandler* ah);
uint8_t music_playing(AudioHandler* ah);
void music_toggle_paused(AudioHandler* ah);
void music_set_paused(AudioHandler* ah, uint8_t p);
void audio_close(AudioHandler* ah);
#endif