-
Notifications
You must be signed in to change notification settings - Fork 0
/
SoundManager.h
58 lines (44 loc) · 1.21 KB
/
SoundManager.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
56
57
58
//
// SoundManager.h
// SDL Game Programming Book
//
// Created by shaun mitchell on 26/03/2013.
// Copyright (c) 2013 shaun mitchell. All rights reserved.
//
#ifndef __SDL_Game_Programming_Book__SoundManager__
#define __SDL_Game_Programming_Book__SoundManager__
#include <iostream>
#include <map>
#include <string>
#include "SDL_mixer.h"
enum sound_type
{
SOUND_MUSIC = 0,
SOUND_SFX = 1
};
class SoundManager
{
public:
static SoundManager* Instance()
{
if(s_pInstance == 0)
{
s_pInstance = new SoundManager();
return s_pInstance;
}
return s_pInstance;
}
bool load(std::string fileName, std::string const &id, sound_type type);
void playSound(std::string const &id, int loop);
void playMusic(std::string const &id, int loop);
private:
static SoundManager* s_pInstance;
std::map<std::string, Mix_Chunk*> m_sfxs;
std::map<std::string, Mix_Music*> m_music;
SoundManager();
~SoundManager();
SoundManager(const SoundManager&);
SoundManager& operator=(const SoundManager&);
};
typedef SoundManager TheSoundManager;
#endif /* defined(__SDL_Game_Programming_Book__SoundManager__) */