Properly change volume

This commit is contained in:
2024-01-29 12:50:36 +01:00
parent 6e848cf239
commit ed1815eddc
6 changed files with 30 additions and 1 deletions

View File

@@ -1,5 +1,17 @@
#include "sounds.h"
void soundsApplyVolume(SoundState *sounds, f32 master, f32 music, f32 sound) {
SetMasterVolume(master);
if (sounds->musicLoaded)
SetMusicVolume(sounds->music, music);
if (IsSoundPlaying(sounds->playing))
SetSoundVolume(sounds->playing, sound);
sounds->masterVolume = master;
sounds->musicVolume = music;
sounds->soundVolume = sound;
}
void soundsLoad(SoundState *sounds, SoundType type, f32 interval, const char *path) {
Sound newSound = LoadSound(path);
sounds->sounds[type] = newSound;
@@ -8,6 +20,7 @@ void soundsLoad(SoundState *sounds, SoundType type, f32 interval, const char *pa
}
void soundsPlay(SoundState *sounds, SoundType type) {
PlaySound(sounds->playing);
SetSoundVolume(sounds->playing, sounds->soundVolume);
}
void soundsUnloadAll(SoundState *sounds) {
@@ -29,6 +42,7 @@ void soundsLoadMusicStream(SoundState *sounds, const char *path) {
void soundsPlayMusicStream(SoundState *sounds) {
if (sounds->musicLoaded == false) return;
PlayMusicStream(sounds->music);
SetMusicVolume(sounds->music, sounds->musicVolume);
}
void soundsPauseMusicStream(SoundState *sounds) {
if (sounds->musicLoaded == false) return;