Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/GEngine/libdev/components/driver/output/Sound.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ struct Sound : public gengine::Component<Sound> {
struct Music : public gengine::Component<Music> {
bool pause = false;
std::uint64_t musicId;
float volume;
uint16_t volume;

Music(std::uint64_t musicId, float volume = 1)
Music(std::uint64_t musicId, uint16_t volume = UINT16_MAX)
: musicId(musicId)
, volume(volume) {
}
Expand Down
9 changes: 4 additions & 5 deletions include/GEngine/libdev/systems/driver/output/AudioManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,12 @@ class AudioManager
void onMusic(gengine::system::event::driver::output::Music &e) {
auto &musics = getComponents<gengine::component::driver::output::Music>();
auto &netSends = getComponents<geg::component::network::NetSend>();

if (!musics.size())
spawnEntity(gengine::component::driver::output::Music(getMusicIdByPath(e.path)),
if (!musics.size()) {
spawnEntity(gengine::component::driver::output::Music(getMusicIdByPath(e.path), e.volume * UINT16_MAX),
geg::component::network::NetSend());
else {
} else {
getMusicComponent().musicId = getMusicIdByPath(e.path);
getMusicComponent().volume = e.volume;
getMusicComponent().volume = e.volume * UINT16_MAX;
for (auto [e, _unused, netSend] : gengine::Zip(musics, netSends)) {
netSend.update();
break;
Expand Down
6 changes: 3 additions & 3 deletions source/GEngine/libdev/systems/driver/output/AudioManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void AudioManager::onMainLoop(geg::event::RenderLoop &e) {
StopMusicStream(getMusicById(m_currentMusicId));
m_currentMusicId = music.musicId;
PlayMusicStream(getMusicById(m_currentMusicId));
SetMusicVolume(getMusicById(m_currentMusicId), music.volume);
SetMusicVolume(getMusicById(m_currentMusicId), float(music.volume) / UINT16_MAX);
}
}

Expand All @@ -95,10 +95,10 @@ void AudioManager::onMainLoop(geg::event::RenderLoop &e) {
gengine::component::driver::output::Music &AudioManager::getMusicComponent(void) {
auto &musics = getComponents<gengine::component::driver::output::Music>();

if (!musics.size())
THROW_WARNING("Music component not initilazed");
for (auto &[_, m] : musics)
return m;

THROW_WARNING("Music component not initilazed");
}

void AudioManager::onSoundPlayed(
Expand Down