summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkhokh20012014-10-29 16:52:36 +0900
committerkhokh20012014-10-29 16:52:36 +0900
commit0cada1cf6fd7b5cdcf41b5638b35d779b430efb8 (patch)
treea66ae83b5a51d6d9b178ace870867de5328a4d29
parent98e1771a832f0843d1a8be344894c0c77bd5f8fd (diff)
downloadchocolate-doom-0cada1cf6fd7b5cdcf41b5638b35d779b430efb8.tar.gz
chocolate-doom-0cada1cf6fd7b5cdcf41b5638b35d779b430efb8.tar.bz2
chocolate-doom-0cada1cf6fd7b5cdcf41b5638b35d779b430efb8.zip
Update i_oplmusic.c
-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 bb9edcb4..45469dfb 100644
--- a/src/i_oplmusic.c
+++ b/src/i_oplmusic.c
@@ -715,10 +715,10 @@ 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;
+ signed int freq_index;
unsigned int octave;
unsigned int sub_index;
- unsigned int note;
+ signed int note;
note = voice->note;
@@ -754,6 +754,11 @@ static unsigned int FrequencyForVoice(opl_voice_t *voice)
freq_index += (voice->current_instr->fine_tuning / 2) - 64;
}
+ if (freq_index < 0)
+ {
+ freq_index = 0;
+ }
+
// The first 7 notes use the start of the table, while
// consecutive notes loop around the latter part.