38 lines
899 B
C++
38 lines
899 B
C++
#pragma once
|
|
|
|
#include <SDL3/SDL.h>
|
|
#include <SDL3_mixer/SDL_mixer.h>
|
|
#include <utils.hpp>
|
|
#include <audio/audio.hpp>
|
|
|
|
namespace Game::Object {
|
|
enum class Format {
|
|
WAV,
|
|
OGG,
|
|
MP3,
|
|
UNKNOWN
|
|
};
|
|
|
|
class Sound {
|
|
public:
|
|
Sound() = default;
|
|
Sound(std::string path, Format format, int volume = 128);
|
|
Sound(const Sound&);
|
|
Sound& operator=(const Sound&);
|
|
Sound(Sound&&);
|
|
Sound& operator=(Sound&&);
|
|
~Sound();
|
|
|
|
void setVolume(int volume) { mVolume = volume; }
|
|
int getVolume() const { return mVolume; }
|
|
|
|
void play();
|
|
|
|
private:
|
|
Uint8* mAudioBuffer = nullptr;
|
|
Uint32 mAudioLength = 0;
|
|
SDL_AudioStream* mAudioStream = nullptr;
|
|
SDL_AudioSpec mSourceSpec{};
|
|
int mVolume;
|
|
};
|
|
} |