summaryrefslogtreecommitdiff
path: root/src/i_oplmusic.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/i_oplmusic.c')
-rw-r--r--src/i_oplmusic.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/i_oplmusic.c b/src/i_oplmusic.c
index de126c63..aa079614 100644
--- a/src/i_oplmusic.c
+++ b/src/i_oplmusic.c
@@ -934,6 +934,13 @@ static unsigned int FrequencyForVoice(opl_voice_t *voice)
gm_voice = &voice->current_instr->voices[voice->current_instr_voice];
note += (signed short) SHORT(gm_voice->base_note_offset);
+ // Avoid possible overflow due to base note offset:
+
+ if (note > 0x7f)
+ {
+ note = voice->note;
+ }
+
freq_index = 64 + 32 * note + voice->channel->bend;
// If this is the second voice of a double voice instrument, the