Files
letnik3koncni-prap/include/object/sound.hpp
2026-03-13 14:28:08 +01:00

37 lines
858 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;
int mVolume;
};
}