-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSound.cpp
More file actions
53 lines (41 loc) · 836 Bytes
/
Sound.cpp
File metadata and controls
53 lines (41 loc) · 836 Bytes
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
#include "Sound.h"
df::Sound::Sound(){
sound = sf::Sound();
}
df::Sound::~Sound(){
}
// Load sound buffer from file.
// Retrun 0 if ok, else -1.
int df::Sound::loadSound(std::string filename){
if (sound_buffer.loadFromFile(filename)){
sound = sf::Sound(sound_buffer);
return 0;
}
return -1;
}
// Set label associated with sound.
void df::Sound::setLabel(std::string new_label){
label = new_label;
}
// Get label associated with sound.
std::string df::Sound::getLabel() const{
return label;
}
//Play sound.
// If loop is true, repeat play when done.
void df::Sound::play(bool loop){
sound.setLoop(loop);
sound.play();
}
// Stop sound.
void df::Sound::stop(){
sound.stop();
}
// Pause sound.
void df::Sound::pause(){
sound.pause();
}
// Return sfml sound.
sf::Sound df::Sound::getSound() const{
return sound;
}