48 #ifndef __CU_SOUND_H__
49 #define __CU_SOUND_H__
50 #include <cugl/base/CUBase.h>
53 #pragma mark Sound Class
87 CU_DISALLOW_COPY_AND_ASSIGN(
Sound);
92 impl::AudioBuffer* _buffer;
97 #pragma mark Constructors
105 Sound() : _source(
""), _buffer(nullptr), _volume(1) {}
130 bool init(
const std::string& source);
142 bool init(
const char* source) {
143 return init(std::string(source));
147 #pragma mark Static Constructors
158 static std::shared_ptr<Sound>
alloc(
const std::string& source) {
159 std::shared_ptr<Sound> result = std::make_shared<Sound>();
160 return (result->init(source) ? result :
nullptr);
173 static std::shared_ptr<Sound>
alloc(
const char* source) {
174 std::shared_ptr<Sound> result = std::make_shared<Sound>();
175 return (result->init(source) ? result :
nullptr);
178 #pragma mark Attributes
184 const std::string&
getSource()
const {
return _source; }
195 size_t pos = _source.rfind(
".");
196 return (pos == std::string::npos ?
"" : _source.substr(pos));
std::string getSuffix() const
Definition: CUSound.h:194
double getSampleRate() const
Sound()
Definition: CUSound.h:105
const std::string & getSource() const
Definition: CUSound.h:184
friend class SoundChannel
Definition: CUSound.h:259
bool init(const std::string &source)
void setVolume(float volume)
double getDuration() const
~Sound()
Definition: CUSound.h:110
static std::shared_ptr< Sound > alloc(const char *source)
Definition: CUSound.h:173
static std::shared_ptr< Sound > alloc(const std::string &source)
Definition: CUSound.h:158
Uint32 getChannels() const
bool init(const char *source)
Definition: CUSound.h:142
float getVolume() const
Definition: CUSound.h:245
Definition: CUAnimationNode.h:52