summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkhokh20012014-10-29 17:03:45 +0900
committerkhokh20012014-10-29 17:03:45 +0900
commit37aae66760717b106acf602c180140096d95d036 (patch)
tree57dcda18fa46c42f481164475f9a62881fdc54e2
parentae20311e3e6b6345db92bcec9f527c0b92c146f7 (diff)
downloadchocolate-doom-37aae66760717b106acf602c180140096d95d036.tar.gz
chocolate-doom-37aae66760717b106acf602c180140096d95d036.tar.bz2
chocolate-doom-37aae66760717b106acf602c180140096d95d036.zip
opl additive voice volume calculation fix
opl additive voice volume calculation fix
-rw-r--r--src/i_oplmusic.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/i_oplmusic.c b/src/i_oplmusic.c
index 39517e3f..128cff18 100644
--- a/src/i_oplmusic.c
+++ b/src/i_oplmusic.c
@@ -507,6 +507,7 @@ static void SetVoiceInstrument(opl_voice_t *voice,
static void SetVoiceVolume(opl_voice_t *voice, unsigned int volume)
{
genmidi_voice_t *opl_voice;
+ unsigned int midi_volume;
unsigned int full_volume;
unsigned int car_volume;
unsigned int mod_volume;
@@ -517,7 +518,10 @@ 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] * (2 * (volume_mapping_table[(voice->channel->volume * current_music_volume) / 127] + 1))) >> 9;
+ midi_volume = 2 * (volume_mapping_table[(voice->channel->volume
+ * current_music_volume) / 127] + 1);
+
+ full_volume = (volume_mapping_table[voice->note_volume] * midi_volume) >> 9;
// The volume value to use in the register:
car_volume = 0x3f - full_volume;
@@ -540,7 +544,8 @@ static void SetVoiceVolume(opl_voice_t *voice, unsigned int volume)
{
mod_volume = car_volume;
}
- OPL_WriteRegister(OPL_REGS_LEVEL + voice->op1, mod_volume | (opl_voice->modulator.scale & 0xc0));
+ OPL_WriteRegister(OPL_REGS_LEVEL + voice->op1,
+ mod_volume | (opl_voice->modulator.scale & 0xc0));
}
}
}