Audio Abstrakcija - WIP

This commit is contained in:
2026-03-13 14:28:08 +01:00
parent 8ae713ba8a
commit 52df67da09
13 changed files with 324 additions and 43 deletions

37
include/object/sound.hpp Normal file
View File

@@ -0,0 +1,37 @@
#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;
};
}