diff options
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) { |