2012-10-13 18:29:53 +00:00
|
|
|
#ifndef _SOUND_H_
|
|
|
|
#define _SOUND_H_
|
|
|
|
|
|
|
|
#include <string>
|
2013-05-14 19:31:39 +00:00
|
|
|
#include "SDL_audio.h"
|
|
|
|
|
2012-10-13 18:29:53 +00:00
|
|
|
|
|
|
|
class Sound
|
|
|
|
{
|
2013-05-14 19:31:39 +00:00
|
|
|
std::string mPath;
|
|
|
|
SDL_AudioSpec mSampleFormat;
|
|
|
|
Uint8 * mSampleData;
|
|
|
|
Uint32 mSamplePos;
|
|
|
|
Uint32 mSampleLength;
|
|
|
|
bool playing;
|
|
|
|
|
2012-10-13 18:29:53 +00:00
|
|
|
public:
|
2013-05-14 19:31:39 +00:00
|
|
|
Sound(const std::string & path = "");
|
2012-10-13 18:29:53 +00:00
|
|
|
~Sound();
|
|
|
|
|
|
|
|
void init();
|
|
|
|
void deinit();
|
|
|
|
|
2013-05-14 19:31:39 +00:00
|
|
|
void loadFile(const std::string & path);
|
2012-10-13 18:29:53 +00:00
|
|
|
|
|
|
|
void play();
|
2013-05-14 19:31:39 +00:00
|
|
|
bool isPlaying() const;
|
|
|
|
void stop();
|
|
|
|
|
|
|
|
const Uint8 * getData() const;
|
|
|
|
Uint32 getPosition() const;
|
|
|
|
void setPosition(Uint32 newPosition);
|
|
|
|
Uint32 getLength() const;
|
2013-08-06 13:15:20 +00:00
|
|
|
Uint32 getLengthMS() const;
|
2012-10-13 18:29:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|