Skip to content

Commit 3b7fa79

Browse files
committed
Fixed tone distortion bug after going high
When going higher than chip supports, and when frequency multiplication factor got been increased, it should be properly reset back when going down
1 parent 221a19d commit 3b7fa79

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/adlmidi_opl3.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,7 @@ void OPL3::noteOn(size_t c1, size_t c2, double tone)
523523
uint16_t ftone = 0;
524524
const OplTimbre *patch1 = m_insCache[c1];
525525
const OplTimbre *patch2 = m_insCache[chan2];
526+
bool cacheModded[2] = {m_insCacheModified[c1], m_insCacheModified[chan2]};
526527

527528
if(tone < 0.0)
528529
tone = 0.0; // Lower than 0 is impossible!
@@ -570,7 +571,7 @@ void OPL3::noteOn(size_t c1, size_t c2, double tone)
570571
writeRegI(chip, 0x20 + op_addr[op], (dt | (mul + mul_offset)) & 0xFF);
571572
m_insCacheModified[modIdx] = true;
572573
}
573-
else if(m_insCacheModified[modIdx])
574+
else if(cacheModded[op > 1 ? 1 : 0])
574575
{
575576
writeRegI(chip, 0x20 + op_addr[op], ops[op] & 0xFF);
576577
m_insCacheModified[modIdx] = false;

0 commit comments

Comments
 (0)