From d5dfde240dc736790a2ac223769333452fe4521e Mon Sep 17 00:00:00 2001
From: mazmazz <mar.marcoz@outlook.com>
Date: Sun, 19 Aug 2018 09:38:57 -0400
Subject: [PATCH] I_SetInternalMusicVolume implementation

---
 src/i_sound.h         | 2 ++
 src/s_sound.c         | 5 +++++
 src/s_sound.h         | 1 +
 src/sdl/mixer_sound.c | 8 ++++++++
 4 files changed, 16 insertions(+)

diff --git a/src/i_sound.h b/src/i_sound.h
index a88038b39e..4e6a253333 100644
--- a/src/i_sound.h
+++ b/src/i_sound.h
@@ -247,6 +247,8 @@ UINT32 I_GetMusicPosition(void);
 
 boolean I_SetSongTrack(INT32 track);
 
+void I_SetInternalMusicVolume(UINT8 volume);
+
 /**	\brief The I_StartDigSong function
 
 	\param	musicname	music lump name
diff --git a/src/s_sound.c b/src/s_sound.c
index 3b0c87463a..2d4de70b1c 100644
--- a/src/s_sound.c
+++ b/src/s_sound.c
@@ -1476,6 +1476,11 @@ void S_StopMusic(void)
 	}
 }
 
+void S_SetInternalMusicVolume(INT32 volume)
+{
+	I_SetInternalMusicVolume(min(max(volume, 0), 100));
+}
+
 void S_SetDigMusicVolume(INT32 volume)
 {
 	if (volume < 0 || volume > 31)
diff --git a/src/s_sound.h b/src/s_sound.h
index 096a03f1f4..19b616ab24 100644
--- a/src/s_sound.h
+++ b/src/s_sound.h
@@ -180,6 +180,7 @@ void S_UpdateSounds(void);
 
 FUNCMATH fixed_t S_CalculateSoundDistance(fixed_t px1, fixed_t py1, fixed_t pz1, fixed_t px2, fixed_t py2, fixed_t pz2);
 
+void S_SetInternalMusicVolume(INT32 volume);
 void S_SetDigMusicVolume(INT32 volume);
 void S_SetMIDIMusicVolume(INT32 volume);
 void S_SetSfxVolume(INT32 volume);
diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c
index 3b2857a9ee..5de1831ce8 100644
--- a/src/sdl/mixer_sound.c
+++ b/src/sdl/mixer_sound.c
@@ -1160,6 +1160,14 @@ boolean I_SetSongTrack(int track)
 	return false;
 }
 
+void I_SetInternalMusicVolume(UINT8 volume)
+{
+	internal_volume = volume;
+	if (!music)
+		return;
+	Mix_VolumeMusic(get_real_volume(midimode ? midi_volume : music_volume));
+}
+
 void I_StopFadingMusic()
 {
 	if (fading_id)
-- 
GitLab