From ddd76d59cc4958abb5c42090046bf6781cf75096 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Sat, 16 Dec 2017 14:38:00 +0100 Subject: Added Music Volume option --- src/sdl/audio.c | 8 ++++++++ src/sdl/audio.h | 4 ++++ 2 files changed, 12 insertions(+) (limited to 'src/sdl') 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 +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); -- cgit v1.2.3