aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVitaly Novichkov <admin@wohlnet.ru>2018-08-22 01:02:30 +0300
committerVitaly Novichkov <admin@wohlnet.ru>2018-08-22 01:02:30 +0300
commitf4e9ee87c1972ad06757812fdf373e694c0385ad (patch)
treebbdb552565d736348daa5453dd6516fc60dae4da /src
parent1ab34e88a326c396fbb42c503eb4ffa56fa0a148 (diff)
parente8882d58c9c4db8992b0620565e671979cd6a696 (diff)
downloadlibADLMIDI-f4e9ee87c1972ad06757812fdf373e694c0385ad.tar.gz
libADLMIDI-f4e9ee87c1972ad06757812fdf373e694c0385ad.tar.bz2
libADLMIDI-f4e9ee87c1972ad06757812fdf373e694c0385ad.zip
Merge branch 'master' into stable
Diffstat (limited to 'src')
-rw-r--r--src/adlmidi_opl3.cpp22
-rw-r--r--src/adlmidi_private.hpp4
2 files changed, 15 insertions, 11 deletions
diff --git a/src/adlmidi_opl3.cpp b/src/adlmidi_opl3.cpp
index 94602ba..5ea2053 100644
--- a/src/adlmidi_opl3.cpp
+++ b/src/adlmidi_opl3.cpp
@@ -266,33 +266,37 @@ void OPL3::noteOff(size_t c)
void OPL3::noteOn(size_t c, double hertz) // Hertz range: 0..131071
{
size_t chip = c / 23, cc = c % 23;
- uint32_t x = 0x2000;
+ uint32_t octave = 0;
- if(hertz < 0 || hertz > 131071) // Avoid infinite loop
+ if(hertz < 0)
return;
while(hertz >= 1023.5)
{
- hertz /= 2.0; // Calculate octave
- x += 0x400;
+ hertz /= 2.0; // Calculate octave
+ if(octave < 0x1C00)
+ octave += 0x400;
}
- x += static_cast<uint32_t>(hertz + 0.5);
+ octave += static_cast<uint32_t>(hertz + 0.5);
uint32_t chn = g_channelsMap[cc];
if(cc >= 18)
{
m_regBD[chip ] |= (0x10 >> (cc - 18));
writeRegI(chip , 0x0BD, m_regBD[chip ]);
- x &= ~0x2000u;
//x |= 0x800; // for test
}
+ else
+ {
+ octave += 0x2000u; /* Key-ON [KON] */
+ }
if(chn != 0xFFF)
{
- writeRegI(chip , 0xA0 + chn, (x & 0xFF));
- writeRegI(chip , 0xB0 + chn, (x >> 8));
- m_keyBlockFNumCache[c] = (x >> 8);
+ writeRegI(chip , 0xA0 + chn, (octave & 0xFF));
+ writeRegI(chip , 0xB0 + chn, (octave >> 8));
+ m_keyBlockFNumCache[c] = (octave >> 8);
}
}
diff --git a/src/adlmidi_private.hpp b/src/adlmidi_private.hpp
index 6bb1dcf..f719f01 100644
--- a/src/adlmidi_private.hpp
+++ b/src/adlmidi_private.hpp
@@ -1492,8 +1492,8 @@ extern bool adl_isEmulatorAvailable(int emulator);
extern int adl_getHighestEmulator();
/**
- * @brief Find lowerest emulator
- * @return The ADL_Emulator enum value which contains ID of lowerest emulator
+ * @brief Find lowest emulator
+ * @return The ADL_Emulator enum value which contains ID of lowest emulator
*/
extern int adl_getLowestEmulator();