summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Howard2009-09-20 21:25:59 +0000
committerSimon Howard2009-09-20 21:25:59 +0000
commit4b598f3d40e34b5d786c9236f891fbe2337c1b66 (patch)
treecb626e8bd0bad91effc897671fd26e0e6ae91192
parentfcf4a7241a742e7f3d8189c40ad852d48c674612 (diff)
downloadchocolate-doom-4b598f3d40e34b5d786c9236f891fbe2337c1b66.tar.gz
chocolate-doom-4b598f3d40e34b5d786c9236f891fbe2337c1b66.tar.bz2
chocolate-doom-4b598f3d40e34b5d786c9236f891fbe2337c1b66.zip
Implement volume control.
Subversion-branch: /branches/opl-branch Subversion-revision: 1685
-rw-r--r--OPL-TODO1
-rw-r--r--src/i_oplmusic.c16
2 files changed, 15 insertions, 2 deletions
diff --git a/OPL-TODO b/OPL-TODO
index 8ca6a4b5..7b9be01c 100644
--- a/OPL-TODO
+++ b/OPL-TODO
@@ -15,7 +15,6 @@ Bad MIDIs:
Other tasks:
- * Menu volume control
* Pause music
* Add option to select MIDI type in setup tool
diff --git a/src/i_oplmusic.c b/src/i_oplmusic.c
index b8e93534..4ac52754 100644
--- a/src/i_oplmusic.c
+++ b/src/i_oplmusic.c
@@ -651,7 +651,8 @@ static void SetVoiceVolume(opl_voice_t *voice, unsigned int volume)
// Multiply note volume and channel volume to get the actual volume.
full_volume = (volume_mapping_table[voice->note_volume]
- * volume_mapping_table[voice->channel->volume]) / 127;
+ * volume_mapping_table[voice->channel->volume]
+ * volume_mapping_table[current_music_volume]) / (127 * 127);
// The volume of each instrument can be controlled via GENMIDI:
@@ -769,8 +770,21 @@ static boolean I_OPL_InitMusic(void)
static void I_OPL_SetMusicVolume(int volume)
{
+ unsigned int i;
+
// Internal state variable.
+
current_music_volume = volume;
+
+ // Update the volume of all voices.
+
+ for (i=0; i<OPL_NUM_VOICES; ++i)
+ {
+ if (voices[i].channel != NULL)
+ {
+ SetVoiceVolume(&voices[i], voices[i].note_volume);
+ }
+ }
}
static void VoiceKeyOff(opl_voice_t *voice)