-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaudio.hh
More file actions
51 lines (38 loc) · 1.17 KB
/
audio.hh
File metadata and controls
51 lines (38 loc) · 1.17 KB
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
41
42
43
44
45
46
47
48
49
50
51
#include <SDL.h>
#include <functional>
namespace SDL {
class AudioInstance;
class Audio {
bool paused;
SDL_AudioSpec audio_spec;
Uint8* audio_buffer;
Uint32 audio_length;
std::function<void(Uint8*)> free;
public:
unsigned char volume;
Audio(
const SDL_AudioSpec audio_spec,
Uint8* audio_buffer,
const Uint32 audio_length,
std::function<void(Uint8*)> free,
unsigned char volume=SDL_MIX_MAXVOLUME // 0 - 128
);
AudioInstance play(const bool start_automatically=true);
AudioInstance loop(const size_t times, const bool start_automatically=true);
AudioInstance loop(const bool start_automatically=true);
static Audio load_wav(const std::string file);
~Audio();
friend class AudioInstance;
};
class AudioInstance {
Audio& source;
size_t loop;
SDL_AudioDeviceID device;
void new_device();
public:
AudioInstance(Audio&, const size_t loop, const bool start_automatically=true);
void pause();
void stop();
void play();
};
}