aboutsummaryrefslogtreecommitdiff
path: root/src/sdl
diff options
context:
space:
mode:
authorptitSeb2017-12-16 14:38:00 +0100
committerptitSeb2017-12-16 14:38:00 +0100
commitddd76d59cc4958abb5c42090046bf6781cf75096 (patch)
tree796082296283a5aaec052469bc7d4360184c50ce /src/sdl
parent3638a171bda48dc9a8d264f68dd04a187a433aa6 (diff)
downloadhydracastlelabyrinth-ddd76d59cc4958abb5c42090046bf6781cf75096.tar.gz
hydracastlelabyrinth-ddd76d59cc4958abb5c42090046bf6781cf75096.tar.bz2
hydracastlelabyrinth-ddd76d59cc4958abb5c42090046bf6781cf75096.zip
Added Music Volume option
Diffstat (limited to 'src/sdl')
-rw-r--r--src/sdl/audio.c8
-rw-r--r--src/sdl/audio.h4
2 files changed, 12 insertions, 0 deletions
diff --git a/src/sdl/audio.c b/src/sdl/audio.c
index 8e19bf9..b66ce1e 100644
--- a/src/sdl/audio.c
+++ b/src/sdl/audio.c
@@ -1,11 +1,15 @@
#include "audio.h"
#include <SDL/SDL.h>
+int music_volume = 4;
+
void PHL_AudioInit()
{
SDL_InitSubSystem(SDL_INIT_AUDIO);
Mix_Init(0);
Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 4096);
+
+ PHL_MusicVolume(0.25f * music_volume);
}
void PHL_AudioClose()
@@ -35,6 +39,10 @@ PHL_Sound PHL_LoadSound(char* fname)
return Mix_LoadWAV(buff);
}
+void PHL_MusicVolume(float vol)
+{
+ Mix_VolumeMusic(SDL_MIX_MAXVOLUME*vol);
+}
void PHL_PlayMusic(PHL_Music snd)
{
diff --git a/src/sdl/audio.h b/src/sdl/audio.h
index 2cf30d3..b21cad1 100644
--- a/src/sdl/audio.h
+++ b/src/sdl/audio.h
@@ -12,9 +12,13 @@ typedef struct
} PHL_Music;
+extern int music_volume;
+
void PHL_AudioInit();
void PHL_AudioClose();
+void PHL_MusicVolume(float vol);
+
PHL_Music PHL_LoadMusic(char* fname, int loop); //Same as PHL_LoadSound, but expects a file name without extension
PHL_Sound PHL_LoadSound(char* fname);