-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsound.cpp
More file actions
47 lines (40 loc) · 1.01 KB
/
sound.cpp
File metadata and controls
47 lines (40 loc) · 1.01 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
/*
* sound.cpp
* StepSeq
*
* Created by Magnus Selin on 2012-05-30.
* Copyright 2012 NR. All rights reserved.
*
*/
#include "sound.h"
void Sound_Handler::load_dir(std::string path){
DIR *dir = opendir(path.c_str()); // open the current directory
if (!dir){
std::cerr << "Cannot open directory!" << std::endl;
return;
}
struct dirent *entry;
while (entry = readdir(dir)){ // notice the single '='
//std::cout << "Found directory entry: "
//<< entry->d_name << std::endl;
f_name_in_path.push_back(entry->d_name);
}
closedir(dir);
}
std::vector<std::string> Sound_Handler::get_file_names(){
return f_name_in_path;
}
bool Sound_Handler::load_sound(int n, std::string f_name){
if(!sound_buffer[n].sound.OpenFromFile(f_name)){
std::cerr << "Could not open " << f_name << "!\n";
return false;
}
std::cout << f_name << " loaded sucessfully!\n";
return true;
}
void Sound_Handler::play(int n){
sound_buffer[n].sound.Play();
}
void Sound_Handler::pause(int n){
sound_buffer[n].sound.Pause();
}