From 65ca7359fffd0894f88e4fc3209504b6a680b6a8 Mon Sep 17 00:00:00 2001 From: Vitaly Novichkov Date: Fri, 31 Aug 2018 02:48:22 +0300 Subject: [PATCH] Little fix in the generator --- src/opl/generator.cpp | 12 ++++++++---- src/opl/generator.h | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/opl/generator.cpp b/src/opl/generator.cpp index 480aad6..aca673c 100644 --- a/src/opl/generator.cpp +++ b/src/opl/generator.cpp @@ -195,7 +195,7 @@ Generator::Generator(uint32_t sampleRate, OPL_Chips initialChip) }; m_regBD = 0; memset(m_ins, 0, sizeof(uint16_t)*NUM_OF_CHANNELS); - memset(m_pit, 0, sizeof(uint8_t)*NUM_OF_CHANNELS); + memset(m_keyBlockFNumCache, 0, sizeof(uint8_t)*NUM_OF_CHANNELS); memset(m_four_op_category, 0, NUM_OF_CHANNELS * 2); uint32_t p = 0; @@ -278,7 +278,7 @@ void Generator::NoteOff(uint32_t c) return; } - WriteReg(0xB0 + g_Channels[cc], m_pit[c] & 0xDF); + WriteReg(0xB0 + g_Channels[cc], m_keyBlockFNumCache[c] & 0xDF); } void Generator::NoteOn(uint32_t c1, uint32_t c2, double hertz) // Hertz range: 0..131071 @@ -346,8 +346,12 @@ void Generator::NoteOn(uint32_t c1, uint32_t c2, double hertz) // Hertz range: 0 } } - WriteReg(0xA0 + chn, ftone & 0xFF); - WriteReg(0xB0 + chn, m_pit[c1] = static_cast(ftone >> 8)); + if(chn != 0xFFF) + { + WriteReg(0xA0 + chn, ftone & 0xFF); + WriteReg(0xB0 + chn, (ftone >> 8)); + m_keyBlockFNumCache[c1] = static_cast(ftone >> 8); + } if(cc1 >= OPL3_CHANNELS_RHYTHM_BASE) { diff --git a/src/opl/generator.h b/src/opl/generator.h index dd87173..da8c28c 100644 --- a/src/opl/generator.h +++ b/src/opl/generator.h @@ -225,7 +225,7 @@ class Generator //! index of operators pair, cached, needed by Touch() uint16_t m_ins[NUM_OF_CHANNELS]; //! value poked to B0, cached, needed by NoteOff)( - uint8_t m_pit[NUM_OF_CHANNELS]; + uint8_t m_keyBlockFNumCache[NUM_OF_CHANNELS]; }; #endif // GENERATOR_H