cmdfx 0.3.0
Lightweight game engine for your terminal
Loading...
Searching...
No Matches
sound.hpp
1
11#pragma once
12
13extern "C" {
14 #include "sound.h"
15}
16
17#include <string>
18
19namespace CmdFX {
20
24 namespace Sound {
25 bool play(std::string soundFile) {
26 return Sound_play(soundFile.c_str()) != 0;
27 }
28
29 bool playLooped(std::string soundFile, int loopCount) {
30 return Sound_playLooped(soundFile.c_str(), loopCount) != 0;
31 }
32
33 bool pause(std::string soundFile) {
34 return Sound_pause(soundFile.c_str()) != 0;
35 }
36
37 bool pauseAll() {
38 return Sound_pauseAll() != 0;
39 }
40
41 bool resume(std::string soundFile) {
42 return Sound_resume(soundFile.c_str()) != 0;
43 }
44
45 bool resumeAll() {
46 return Sound_resumeAll() != 0;
47 }
48
49 bool stop(std::string soundFile) {
50 return Sound_stop(soundFile.c_str()) != 0;
51 }
52
53 bool stopAll() {
54 return Sound_stopAll() != 0;
55 }
56
57 double getVolume(std::string soundFile) {
58 double volume = 0.0;
59 if (Sound_getVolume(soundFile.c_str(), &volume) != 0) {
60 return -1.0;
61 }
62
63 return volume;
64 }
65
66 double getVolumeAll() {
67 double volume = 0.0;
68 if (Sound_getVolumeAll(&volume) != 0) {
69 return -1.0;
70 }
71
72 return volume;
73 }
74
75 void setVolume(std::string soundFile, double volume) {
76 Sound_setVolume(soundFile.c_str(), volume);
77 }
78
79 void setVolumeAll(double volume) {
80 Sound_setVolumeAll(volume);
81 }
82
83 }
84
85}
A C++ Wrapper around the sound engine declarations.
Definition sound.hpp:24
Primary namespace for CmdFX.
Definition cmdfx.hpp:25
Primary sound engine declarations.
int Sound_getVolumeAll(double *volume)
Get the volume of all sound files.
int Sound_setVolumeAll(double volume)
Set the volume of all sound files.
int Sound_play(const char *soundFile)
Play a sound file.
int Sound_resumeAll()
Resume all sound files.
int Sound_setVolume(const char *soundFile, double volume)
Set the volume of a sound file.
int Sound_pause(const char *soundFile)
Pause a sound file.
int Sound_resume(const char *soundFile)
Resume a sound file.
int Sound_pauseAll()
Pause all sound files.
int Sound_stop(const char *soundFile)
Stop a sound file.
int Sound_stopAll()
Stop all sound files.
int Sound_getVolume(const char *soundFile, double *volume)
Get the volume of a sound file.
int Sound_playLooped(const char *soundFile, int loopCount)
Play a sound file in a loop.