diff options
author | Simon Howard | 2009-09-20 20:47:17 +0000 |
---|---|---|
committer | Simon Howard | 2009-09-20 20:47:17 +0000 |
commit | dd03cbbe2b688eac26011ac0ea0ada4047e5beb0 (patch) | |
tree | 170470452e5f6f045fc009008fdcc612461c1905 | |
parent | 13314576f8d5d8eec8bf413ca4b49255b9e1a6a2 (diff) | |
download | chocolate-doom-dd03cbbe2b688eac26011ac0ea0ada4047e5beb0.tar.gz chocolate-doom-dd03cbbe2b688eac26011ac0ea0ada4047e5beb0.tar.bz2 chocolate-doom-dd03cbbe2b688eac26011ac0ea0ada4047e5beb0.zip |
Use the base note offset field to offset notes, not a fixed lookup table
of instruments to offset.
Subversion-branch: /branches/opl-branch
Subversion-revision: 1680
-rw-r--r-- | src/i_oplmusic.c | 42 |
1 files changed, 5 insertions, 37 deletions
diff --git a/src/i_oplmusic.c b/src/i_oplmusic.c index 09d2ae42..de126c63 100644 --- a/src/i_oplmusic.c +++ b/src/i_oplmusic.c @@ -34,6 +34,7 @@ #include "mus2mid.h" #include "deh_main.h" +#include "i_swap.h" #include "m_misc.h" #include "s_sound.h" #include "w_wad.h" @@ -304,31 +305,6 @@ static const unsigned int volume_mapping_table[] = { 124, 124, 125, 125, 126, 126, 127, 127 }; -// For octave offset table: - -static const unsigned int octave_offset_table[2][128] = { - { - 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, // 0-15 - 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 16-31 - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, // 32-47 - 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, // 48-63 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, // 64-79 - 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, // 80-95 - 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, // 96-111 - 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, // 112-127 - }, - { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0-15 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 16-31 - 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, // 32-47 - 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, // 48-63 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 64-79 - 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 80-95 - 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 96-111 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 112-127 - } -}; - static boolean music_initialised = false; //static boolean musicpaused = false; @@ -945,26 +921,18 @@ static opl_voice_t *ReplaceExistingVoice(opl_channel_data_t *channel) static unsigned int FrequencyForVoice(opl_voice_t *voice) { + genmidi_voice_t *gm_voice; unsigned int freq_index; unsigned int octave; unsigned int sub_index; - unsigned int instr_num; unsigned int note; note = voice->note; - // What instrument number is this? - // Certain instruments have all notes offset down by one octave. - // Use the octave offset table to work out if this voice should - // be offset. - - instr_num = voice->current_instr - main_instrs; + // Apply note offset: - if (instr_num < 128 && note >= 12 - && octave_offset_table[voice->current_instr_voice][instr_num]) - { - note -= 12; - } + gm_voice = &voice->current_instr->voices[voice->current_instr_voice]; + note += (signed short) SHORT(gm_voice->base_note_offset); freq_index = 64 + 32 * note + voice->channel->bend; |