-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCSound.cpp
More file actions
90 lines (62 loc) · 1.47 KB
/
Copy pathCSound.cpp
File metadata and controls
90 lines (62 loc) · 1.47 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include "CSound.h"
FMOD_SYSTEM* CSound::g_sound_system;
CSound::CSound(const char* path, bool loop) {
if (loop) {
FMOD_System_CreateSound(g_sound_system, path, FMOD_LOOP_NORMAL, 0, &m_sound);
}
else {
FMOD_System_CreateSound(g_sound_system, path, FMOD_DEFAULT, 0, &m_sound);
}
m_channel = nullptr;
m_volume = SOUND_DEFAULT;
}
CSound::~CSound() {
FMOD_Sound_Release(m_sound);
}
int CSound::Init() {
FMOD_System_Create(&g_sound_system);
FMOD_System_Init(g_sound_system, 32, FMOD_INIT_NORMAL, NULL);
return 0;
}
int CSound::Release() {
FMOD_System_Close(g_sound_system);
FMOD_System_Release(g_sound_system);
return 0;
}
int CSound::play() {
FMOD_System_PlaySound(g_sound_system, m_sound, NULL, false, &m_channel);
return 0;
}
int CSound::pause() {
FMOD_Channel_SetPaused(m_channel, true);
return 0;
}
int CSound::resume() {
FMOD_Channel_SetPaused(m_channel, false);
return 0;
}
int CSound::stop() {
FMOD_Channel_Stop(m_channel);
return 0;
}
int CSound::volumeUp() {
if (m_volume < SOUND_MAX) {
m_volume += SOUND_WEIGHT;
}
FMOD_Channel_SetVolume(m_channel, m_volume);
return 0;
}
int CSound::volumeDown() {
if (m_volume > SOUND_MIN) {
m_volume -= SOUND_WEIGHT;
}
FMOD_Channel_SetVolume(m_channel, m_volume);
return 0;
}
int CSound::Update() {
FMOD_Channel_IsPlaying(m_channel, &m_bool);
if (m_bool) {
FMOD_System_Update(g_sound_system);
}
return 0;
}