cmdfx 0.3.1
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{
21
25namespace Sound
26{
27bool play(std::string soundFile) {
28 return Sound_play(soundFile.c_str()) != 0;
29}
30
31bool playLooped(std::string soundFile, int loopCount) {
32 return Sound_playLooped(soundFile.c_str(), loopCount) != 0;
33}
34
35bool pause(std::string soundFile) {
36 return Sound_pause(soundFile.c_str()) != 0;
37}
38
39bool pauseAll() {
40 return Sound_pauseAll() != 0;
41}
42
43bool resume(std::string soundFile) {
44 return Sound_resume(soundFile.c_str()) != 0;
45}
46
47bool resumeAll() {
48 return Sound_resumeAll() != 0;
49}
50
51bool stop(std::string soundFile) {
52 return Sound_stop(soundFile.c_str()) != 0;
53}
54
55bool stopAll() {
56 return Sound_stopAll() != 0;
57}
58
59double getVolume(std::string soundFile) {
60 double volume = 0.0;
61 if (Sound_getVolume(soundFile.c_str(), &volume) != 0) {
62 return -1.0;
63 }
64
65 return volume;
66}
67
68double getVolumeAll() {
69 double volume = 0.0;
70 if (Sound_getVolumeAll(&volume) != 0) {
71 return -1.0;
72 }
73
74 return volume;
75}
76
77void setVolume(std::string soundFile, double volume) {
78 Sound_setVolume(soundFile.c_str(), volume);
79}
80
81void setVolumeAll(double volume) {
82 Sound_setVolumeAll(volume);
83}
84
85} // namespace Sound
86
87} // namespace CmdFX
A C++ Wrapper around the sound engine declarations.
Definition sound.hpp:26
Primary namespace for CmdFX.
Definition cmdfx.hpp:26
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.