From 1461b257ccc6ab7976f8bcf4178b4101af8c809a Mon Sep 17 00:00:00 2001 From: Wohlstand Date: Thu, 10 Apr 2025 04:51:11 +0300 Subject: adlmidi_opl3: Fixed the dead loop when tone comes lower than zero --- README.md | 1 + src/adlmidi_opl3.cpp | 3 +++ 2 files changed, 4 insertions(+) diff --git a/README.md b/README.md index d390d0d..f6a3541 100644 --- a/README.md +++ b/README.md @@ -198,6 +198,7 @@ To build that example you will need to have installed SDL2 library. * Added an ability to manually specify the chip type (OPL2 or OPL3) at the DOS version of MIDI player. * Added an automatical detection of OPL2 or OPL3 chip depending on the BLASTER environment variable's value at the DOS version of MIDI player. * Added Nuked OPL2 and OPL3 Low-Level emulators (Kept disabled by default because they are too heavy for ordinary processors). + * Fixed a dead loop that might happen when final tone gets lower than zero. ## 1.5.1 2022-10-31 * Added an ability to disable the automatical arpeggio diff --git a/src/adlmidi_opl3.cpp b/src/adlmidi_opl3.cpp index be84203..5690721 100644 --- a/src/adlmidi_opl3.cpp +++ b/src/adlmidi_opl3.cpp @@ -1058,6 +1058,9 @@ void OPL3::noteOn(size_t c1, size_t c2, double tone) // Hertz range: 0..131071 double hertz; + if(tone < 0.0) + tone = 0.0; // Lower than 0 is impossible! + // Use different frequency formulas in depend on a volume model switch(m_volumeScale) { -- cgit v1.2.3