From 8040cdd4ff609bfd30ec4214e2d1923c29e8d030 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Wed, 30 Apr 2008 00:44:45 +0000 Subject: [PATCH] - Fixed a copy-and-paste error in win32/i_main.cpp for 64-bit mode. - Tweaked OPL centering a little. SVN r950 (trunk) --- docs/rh-log.txt | 4 ++++ src/oplsynth/opl_mus_player.cpp | 25 ++++++++++++++++--------- src/win32/i_main.cpp | 2 +- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 19c0dcfc7..03cd7257b 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,7 @@ +April 29, 2008 +- Fixed a copy-and-paste error in win32/i_main.cpp for 64-bit mode. +- Tweaked OPL centering a little. + April 28, 2008 - Added dynamic recentering for the OPL synth. The chip has four basic waveforms, and three of them are non-negative. This can cause a tendency diff --git a/src/oplsynth/opl_mus_player.cpp b/src/oplsynth/opl_mus_player.cpp index 40324c882..0139d2ff9 100644 --- a/src/oplsynth/opl_mus_player.cpp +++ b/src/oplsynth/opl_mus_player.cpp @@ -270,7 +270,7 @@ void OPLmusicBlock::OffsetSamples(float *buff, int count) // data back to around the [-1.0, 1.0] range. double max = -1e10, min = 1e10, offset, step; - int i, ramp; + int i, ramp, largest_at = 0; // Find max and min values for this segment of the waveform. for (i = 0; i < count; ++i) @@ -278,19 +278,18 @@ void OPLmusicBlock::OffsetSamples(float *buff, int count) if (buff[i] > max) { max = buff[i]; + largest_at = i; } if (buff[i] < min) { min = buff[i]; + largest_at = i; } } - // Don't slide if we don't have to, because doing so introduces noise. - // However, if the amplitude is low, we do want to slide so that when - // the song ends, the wave will be around 0 and not click when the song - // starts over. - if (min - LastOffset > -0.5 && max - LastOffset < 0.5 && max - min > 0.5) + // Prefer to keep the offset at 0, even if it means a little clipping. + if (LastOffset == 0 && min >= -1.1 && max <= 1.1) { - offset = LastOffset; + offset = 0; } else { @@ -305,8 +304,16 @@ void OPLmusicBlock::OffsetSamples(float *buff, int count) // Ramp the offset change so there aren't any abrupt clicks in the output. // If the ramp is too short, it can sound scratchy. cblood2.mid is // particularly unforgiving of short ramps. - ramp = MIN(512, count); - step = (offset - LastOffset) / 512; + if (count >= 512) + { + ramp = 512; + step = (offset - LastOffset) / 512; + } + else + { + ramp = MIN(count, MAX(196, largest_at)); + step = (offset - LastOffset) / ramp; + } offset = LastOffset; i = 0; if (step != 0) diff --git a/src/win32/i_main.cpp b/src/win32/i_main.cpp index d97bf302a..4585006ad 100644 --- a/src/win32/i_main.cpp +++ b/src/win32/i_main.cpp @@ -1111,7 +1111,7 @@ LONG WINAPI CatchAllExceptions (LPEXCEPTION_POINTERS info) #ifndef _M_X64 info->ContextRecord->Eip = (DWORD_PTR)SleepForever; #else - info->ContextRecord->Rip = (DWORD_PTR)ExitFatally; + info->ContextRecord->Rip = (DWORD_PTR)SleepForever; #endif QueueUserAPC (ExitFatally, MainThread, 0); }