diff options
Diffstat (limited to 'engines/zvision/music_node.cpp')
-rw-r--r-- | engines/zvision/music_node.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/engines/zvision/music_node.cpp b/engines/zvision/music_node.cpp index 081c9dbcca..30271480c1 100644 --- a/engines/zvision/music_node.cpp +++ b/engines/zvision/music_node.cpp @@ -91,12 +91,31 @@ void MusicNode::unsetPanTrack() { setVolume(_volume); } +void MusicNode::setFade(int32 time, uint8 target) { + _crossfade_target = target; + _crossfade_time = time; + _crossfade = true; +} + bool MusicNode::process(uint32 deltaTimeInMillis) { if (! _engine->_mixer->isSoundHandleActive(_handle)) return stop(); else { uint8 _newvol = _volume; + if (_crossfade) { + if (_crossfade_time > 0) { + if ((int32)deltaTimeInMillis > _crossfade_time) + deltaTimeInMillis = _crossfade_time; + _newvol += floor(((float)(_crossfade_target - _newvol) / (float)_crossfade_time)) * (float)deltaTimeInMillis; + _crossfade_time -= deltaTimeInMillis; + } + else { + _crossfade = false; + _newvol = _crossfade_target; + } + } + if (_pantrack || _volume != _newvol) setVolume(_newvol); } |