aboutsummaryrefslogtreecommitdiff
path: root/engines/zvision/music_node.cpp
diff options
context:
space:
mode:
authorMarisa-Chan2014-01-17 11:10:17 +0700
committerMarisa-Chan2014-01-17 11:10:17 +0700
commit7b7ae43f7fe30782201fba691beee1bad18db60a (patch)
treee7cb90d67ccbde9dc7a55d61977dc9f50ea9a754 /engines/zvision/music_node.cpp
parentd973b1fb1bde603b3b2436a58afcf043b178c407 (diff)
downloadscummvm-rg350-7b7ae43f7fe30782201fba691beee1bad18db60a.tar.gz
scummvm-rg350-7b7ae43f7fe30782201fba691beee1bad18db60a.tar.bz2
scummvm-rg350-7b7ae43f7fe30782201fba691beee1bad18db60a.zip
ZVISION: Implement crossfade.
Diffstat (limited to 'engines/zvision/music_node.cpp')
-rw-r--r--engines/zvision/music_node.cpp19
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);
}