-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathaudio.cpp
More file actions
52 lines (40 loc) · 1.33 KB
/
Copy pathaudio.cpp
File metadata and controls
52 lines (40 loc) · 1.33 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 "audio.h"
/***************************************************************/
/** \file audio.cpp
\brief The CAudio implementation */
/***************************************************************/
/** The CAudio class constructor
****************************************************************/
CAudio::CAudio() {
sound = NULL;
channel = -1;
}
/***************************************************************/
/** The CAudio class destructor
****************************************************************/
CAudio::~CAudio() {
if (sound)
Mix_FreeChunk(sound);
sound = NULL;
}
/***************************************************************/
/** Set the new buffer for sound data
(and free the old buffer if it is not NULL).
\param s Pointer to the new sound data buffer
****************************************************************/
void CAudio::SetSound(Mix_Chunk * s) {
if (sound)
Mix_FreeChunk(sound);
sound = s;
}
/***************************************************************/
/** \param volume number between 0 and MIX_MAX_VOLUME (128)
****************************************************************/
void CAudio::SetVolume(float volume)
{
int v = int(volume);
if (sound)
Mix_VolumeChunk(sound, v);
if (channel != -1)
Mix_Volume(channel, v);
}