foxygit / doom Log in
commit eb2291030ae0f1e005a6014193fdfeaa796a913a
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Mon Aug 31 22:50:28 2009 +0000
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Mon Aug 31 22:50:28 2009 +0000

    Perform volume mapping on note and channel volumes before multiplying
    them.  This gives voice volume values that are almost identical to
    Doom's.

    Subversion-branch: /branches/opl-branch
    Subversion-revision: 1653
---
 src/i_oplmusic.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/i_oplmusic.c b/src/i_oplmusic.c
index ab64505c..74a76b00 100644
--- a/src/i_oplmusic.c
+++ b/src/i_oplmusic.c
@@ -495,7 +495,7 @@ static void SetOperatorVolume(genmidi_op_t *op, unsigned int volume,

     // The volume value to use in the register:

-    reg_volume = ((op_volume * volume_mapping_table[volume]) / 128);
+    reg_volume = (op_volume * volume) / 128;
     reg_volume = (0x3f - reg_volume) | op->scale;

     // Update the register, if necessary:
@@ -519,7 +519,8 @@ static void SetVoiceVolume(opl_voice_t *voice, unsigned int volume)

     // Multiply note volume and channel volume to get the actual volume.

-    full_volume = (voice->note_volume * voice->channel->volume) / 127;
+    full_volume = (volume_mapping_table[voice->note_volume]
+                   * volume_mapping_table[voice->channel->volume]) / 127;

     SetOperatorVolume(&opl_voice->carrier, full_volume,
                       voice->op2, &voice->carrier_volume);