-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsound.h
57 lines (49 loc) · 1.36 KB
/
sound.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <vector>
#include <SDL.h>
#include <SDL/SDL_mixer.h>
// In this demo, we use Mix_Music *Mix_LoadMUS(const char *file)
// Where file is the name of the music file to use.
//
// SDL_mixer supports music and sound samples from the following formats:
// - WAVE/RIFF (.wav)
// - AIFF (.aiff)
// - VOC (.voc)
// - MOD (.mod .xm .s3m .669 .it .med and more) using included mikmod
// - MIDI (.mid) using timidity or native midi hardware
// - OggVorbis (.ogg) requiring ogg/vorbis libraries on system
// - MP3 (.mp3) requiring SMPEG library on system
// - also any command-line player, which is not mixed by SDL_mixer...
// that requires a command to play with.
class GameSound {
public:
GameSound();
~GameSound();
void operator[](int); // play the indexed sound
private:
int volume;
int currentSound;
int audioRate;
int audioChannels;
int audioBuffers;
std::vector<Mix_Chunk*> sounds;
std::vector<int> channels;
GameSound(const GameSound&);
GameSound& operator=(const GameSound&);
};
class GameMusic {
public:
GameMusic();
~GameMusic();
void startMusic();
void stopMusic(); // stop all sounds
void toggleMusic(); // toggle music on/off
private:
int volume;
Mix_Music *music;
int audioRate;
int audioChannels;
int audioBuffers;
std::vector<int> channels;
GameMusic(const GameMusic&);
GameMusic& operator=(const GameMusic&);
};