diff options
author | Joseph-Eugene Winzer | 2018-01-08 03:10:53 +0100 |
---|---|---|
committer | Thierry Crozat | 2018-01-21 23:03:12 +0000 |
commit | eef9e18340b1e9c0f9c2ee66f7f2f97edf220d48 (patch) | |
tree | 3a65cfec0c9257171190fe82df4f89f59b8f7808 /audio | |
parent | f30fb59385266e515f605455e243f1f8e1a42765 (diff) | |
download | scummvm-rg350-eef9e18340b1e9c0f9c2ee66f7f2f97edf220d48.tar.gz scummvm-rg350-eef9e18340b1e9c0f9c2ee66f7f2f97edf220d48.tar.bz2 scummvm-rg350-eef9e18340b1e9c0f9c2ee66f7f2f97edf220d48.zip |
AUDIO: Fixes Protracker Portamento effect
.period overflowed if .portaToNoteSpeed > .period in the else if case
Diffstat (limited to 'audio')
-rw-r--r-- | audio/mods/protracker.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/audio/mods/protracker.cpp b/audio/mods/protracker.cpp index ce52b61e04..d486f02e89 100644 --- a/audio/mods/protracker.cpp +++ b/audio/mods/protracker.cpp @@ -101,15 +101,13 @@ private: void doPorta(int track) { if (_track[track].portaToNote && _track[track].portaToNoteSpeed) { - if (_track[track].period < _track[track].portaToNote) { - _track[track].period += _track[track].portaToNoteSpeed; - if (_track[track].period > _track[track].portaToNote) - _track[track].period = _track[track].portaToNote; - } else if (_track[track].period > _track[track].portaToNote) { - _track[track].period -= _track[track].portaToNoteSpeed; - if (_track[track].period < _track[track].portaToNote) - _track[track].period = _track[track].portaToNote; - } + int distance = _track[track].period - _track[track].portaToNote; + int sign = distance > 0 ? 1 : -1; + + if ((sign * distance) > _track[track].portaToNoteSpeed) + _track[track].period -= sign * _track[track].portaToNoteSpeed; + else + _track[track].period = _track[track].portaToNote; } } void doVibrato(int track) { |