[Scummvm-cvs-logs] scummvm master -> 8f551202f6c0029773524fe4686c1147f51b4ee6

bluegr bluegr at gmail.com
Mon Jan 26 01:12:53 CET 2015


This automated email contains information about 6 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
d67727a7a4 ZVISION: Fix sound bug #6767 by making pan_track code similar to original
ad2ab98474 ZVISION: Use correct int type for volume
0bc61d3c21 ZVISION: Volume is not linear value, use dB map to linear for -100...0dB
9b498d576e ZVISION: Correct value for attenuate
568c13b115 ZVISION: Use correct virtual class type instead of MusicNode
8f551202f6 Merge pull request #568 from Marisa-Chan/master


Commit: d67727a7a452354587fb49e58ac3a61cd4ac1fec
    https://github.com/scummvm/scummvm/commit/d67727a7a452354587fb49e58ac3a61cd4ac1fec
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2015-01-23T11:13:06+06:00

Commit Message:
ZVISION: Fix sound bug #6767 by making pan_track code similar to original

Changed paths:
    engines/zvision/scripting/effects/music_effect.cpp
    engines/zvision/scripting/effects/music_effect.h



diff --git a/engines/zvision/scripting/effects/music_effect.cpp b/engines/zvision/scripting/effects/music_effect.cpp
index 102f330..3d3fc88 100644
--- a/engines/zvision/scripting/effects/music_effect.cpp
+++ b/engines/zvision/scripting/effects/music_effect.cpp
@@ -40,12 +40,11 @@ MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool
 	: MusicNodeBASE(engine, key, SCRIPTING_EFFECT_AUDIO) {
 	_loop = loop;
 	_volume = volume;
+	_deltaVolume = 0;
+	_balance = 0;
 	_crossfade = false;
 	_crossfadeTarget = 0;
 	_crossfadeTime = 0;
-	_attenuate = 0;
-	_pantrack = false;
-	_pantrackPosition = 0;
 	_sub = NULL;
 	_stereo = false;
 	_loaded = false;
@@ -97,17 +96,14 @@ MusicNode::~MusicNode() {
 	debug(1, "MusicNode: %d destroyed\n", _key);
 }
 
-void MusicNode::setPanTrack(int16 pos) {
-	if (!_stereo) {
-		_pantrack = true;
-		_pantrackPosition = pos;
-		setVolume(_volume);
-	}
+void MusicNode::setDeltaVolume(uint8 volume) {
+	_deltaVolume = volume;
+	setVolume(_volume);
 }
 
-void MusicNode::unsetPanTrack() {
-	_pantrack = false;
-	setVolume(_volume);
+void MusicNode::setBalance(int8 balance) {
+	_balance = balance;
+	_engine->_mixer->setChannelBalance(_handle, _balance);
 }
 
 void MusicNode::setFade(int32 time, uint8 target) {
@@ -134,7 +130,7 @@ bool MusicNode::process(uint32 deltaTimeInMillis) {
 			}
 		}
 
-		if (_pantrack || _volume != _newvol)
+		if (_volume != _newvol)
 			setVolume(_newvol);
 
 		if (_sub && _engine->getScriptManager()->getStateValue(StateKey_Subtitles) == 1)
@@ -146,55 +142,86 @@ bool MusicNode::process(uint32 deltaTimeInMillis) {
 void MusicNode::setVolume(uint8 newVolume) {
 	if (!_loaded)
 		return;
-	if (_pantrack) {
-		int curX = _engine->getScriptManager()->getStateValue(StateKey_ViewPos);
-		curX -= _pantrackPosition;
-		int32 _width = _engine->getRenderManager()->getBkgSize().x;
-		if (curX < (-_width) / 2)
-			curX += _width;
-		else if (curX >= _width / 2)
-			curX -= _width;
-
-		float norm = (float)curX / ((float)_width / 2.0);
-		float lvl = fabs(norm);
-		if (lvl > 0.5)
-			lvl = (lvl - 0.5) * 1.7;
-		else
-			lvl = 1.0;
 
-		float bal = sin(-norm * 3.1415926) * 127.0;
+	_volume = newVolume;
 
-		if (_engine->_mixer->isSoundHandleActive(_handle)) {
-			_engine->_mixer->setChannelBalance(_handle, bal);
-			_engine->_mixer->setChannelVolume(_handle, newVolume * lvl);
-		}
-	} else {
-		if (_engine->_mixer->isSoundHandleActive(_handle)) {
-			_engine->_mixer->setChannelBalance(_handle, 0);
-			_engine->_mixer->setChannelVolume(_handle, newVolume);
-		}
-	}
+	if (_deltaVolume >= _volume)
+		_engine->_mixer->setChannelVolume(_handle, 0);
+	else
+		_engine->_mixer->setChannelVolume(_handle, _volume - _deltaVolume);
+}
 
-	_volume = newVolume;
+uint8 MusicNode::getVolume() {
+	return _volume;
 }
 
 PanTrackNode::PanTrackNode(ZVision *engine, uint32 key, uint32 slot, int16 pos)
 	: ScriptingEffect(engine, key, SCRIPTING_EFFECT_PANTRACK) {
 	_slot = slot;
+	_position = pos;
 
-	ScriptingEffect *fx = _engine->getScriptManager()->getSideFX(slot);
-	if (fx && fx->getType() == SCRIPTING_EFFECT_AUDIO) {
-		MusicNodeBASE *mus = (MusicNodeBASE *)fx;
-		mus->setPanTrack(pos);
-	}
+	// Try to set pan value for music node immediately
+	process(0);
 }
 
 PanTrackNode::~PanTrackNode() {
-	ScriptingEffect *fx = _engine->getScriptManager()->getSideFX(_slot);
+}
+
+bool PanTrackNode::process(uint32 deltaTimeInMillis) {
+	ScriptManager * scriptManager = _engine->getScriptManager();
+	ScriptingEffect *fx = scriptManager->getSideFX(_slot);
 	if (fx && fx->getType() == SCRIPTING_EFFECT_AUDIO) {
 		MusicNodeBASE *mus = (MusicNodeBASE *)fx;
-		mus->unsetPanTrack();
+
+		int curPos = scriptManager->getStateValue(StateKey_ViewPos);
+		int16 _width = _engine->getRenderManager()->getBkgSize().x;
+		int16 _halfWidth = _width / 2;
+		int16 _quarterWidth = _width / 4;
+
+		int tmp = 0;
+		if (curPos <= _position)
+			tmp = _position - curPos;
+		else
+			tmp = _position - curPos + _width;
+
+		int balance = 0;
+
+		if (tmp > _halfWidth)
+			tmp -= _width;
+
+		if (tmp > _quarterWidth) {
+			balance = 1;
+			tmp = _halfWidth - tmp;
+		} else if (tmp < -_quarterWidth) {
+			balance = -1;
+			tmp = -_halfWidth - tmp;
+		}
+
+		// Originally it's value -90...90 but we use -127...127 and therefore 360 replaced by 508
+		mus->setBalance( (508 * tmp) / _width );
+
+		tmp = (360 * tmp) / _width;
+
+		int deltaVol = balance;
+
+		// This value sets how fast volume goes off than sound source back of you
+		// By this value we can hack some "bugs" have place in originall game engine like beat sound in ZGI-dc10
+		int volumeCorrection = 2;
+
+		if (_engine->getGameId() == GID_GRANDINQUISITOR) {
+			Location loc = scriptManager->getCurrentLocation();
+			if (loc.world == 'd' && loc.room == 'c' && loc.node == '1' && loc.view == '0')
+				volumeCorrection = 5;
+		}
+
+		if (deltaVol != 0)
+			deltaVol = (mus->getVolume() * volumeCorrection) * (90 - tmp * balance) / 90;
+		if (deltaVol > 255)
+			deltaVol = 255;
+
+		mus->setDeltaVolume(deltaVol);
 	}
+	return false;
 }
 
 MusicMidiNode::MusicMidiNode(ZVision *engine, uint32 key, int8 program, int8 note, int8 volume)
@@ -225,10 +252,10 @@ MusicMidiNode::~MusicMidiNode() {
 		_engine->getScriptManager()->setStateValue(_key, 2);
 }
 
-void MusicMidiNode::setPanTrack(int16 pos) {
+void MusicMidiNode::setDeltaVolume(uint8 volume) {
 }
 
-void MusicMidiNode::unsetPanTrack() {
+void MusicMidiNode::setBalance(int8 balance) {
 }
 
 void MusicMidiNode::setFade(int32 time, uint8 target) {
@@ -245,4 +272,8 @@ void MusicMidiNode::setVolume(uint8 newVolume) {
 	_volume = newVolume;
 }
 
+uint8 MusicMidiNode::getVolume() {
+	return _volume;
+}
+
 } // End of namespace ZVision
diff --git a/engines/zvision/scripting/effects/music_effect.h b/engines/zvision/scripting/effects/music_effect.h
index 31d538f..f6cb4a5 100644
--- a/engines/zvision/scripting/effects/music_effect.h
+++ b/engines/zvision/scripting/effects/music_effect.h
@@ -48,9 +48,9 @@ public:
 	virtual bool process(uint32 deltaTimeInMillis) = 0;
 
 	virtual void setVolume(uint8 volume) = 0;
-
-	virtual void setPanTrack(int16 pos) = 0;
-	virtual void unsetPanTrack() = 0;
+	virtual uint8 getVolume() = 0;
+	virtual void setDeltaVolume(uint8 volume) = 0;
+	virtual void setBalance(int8 balance) = 0;
 
 	virtual void setFade(int32 time, uint8 target) = 0;
 };
@@ -70,17 +70,16 @@ public:
 	bool process(uint32 deltaTimeInMillis);
 
 	void setVolume(uint8 volume);
-
-	void setPanTrack(int16 pos);
-	void unsetPanTrack();
+	uint8 getVolume();
+	void setDeltaVolume(uint8 volume);
+	void setBalance(int8 balance);
 
 	void setFade(int32 time, uint8 target);
 
 private:
-	bool _pantrack;
-	int32 _pantrackPosition;
-	int32 _attenuate;
 	uint8 _volume;
+	uint8 _deltaVolume;
+	int8 _balance;
 	bool _loop;
 	bool _crossfade;
 	uint8 _crossfadeTarget;
@@ -107,9 +106,9 @@ public:
 	bool process(uint32 deltaTimeInMillis);
 
 	void setVolume(uint8 volume);
-
-	void setPanTrack(int16 pos);
-	void unsetPanTrack();
+	uint8 getVolume();
+	void setDeltaVolume(uint8 volume);
+	void setBalance(int8 balance);
 
 	void setFade(int32 time, uint8 target);
 
@@ -126,8 +125,11 @@ public:
 	PanTrackNode(ZVision *engine, uint32 key, uint32 slot, int16 pos);
 	~PanTrackNode();
 
+	bool process(uint32 deltaTimeInMillis);
+
 private:
 	uint32 _slot;
+	int16 _position;
 };
 
 } // End of namespace ZVision


Commit: ad2ab98474cecc8f8764697b3aa2acc16912368f
    https://github.com/scummvm/scummvm/commit/ad2ab98474cecc8f8764697b3aa2acc16912368f
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2015-01-23T16:20:59+06:00

Commit Message:
ZVISION: Use correct int type for volume

Changed paths:
    engines/zvision/scripting/effects/music_effect.cpp
    engines/zvision/scripting/effects/music_effect.h



diff --git a/engines/zvision/scripting/effects/music_effect.cpp b/engines/zvision/scripting/effects/music_effect.cpp
index 3d3fc88..6c1a5f7 100644
--- a/engines/zvision/scripting/effects/music_effect.cpp
+++ b/engines/zvision/scripting/effects/music_effect.cpp
@@ -36,7 +36,7 @@
 
 namespace ZVision {
 
-MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool loop, int8 volume)
+MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool loop, uint8 volume)
 	: MusicNodeBASE(engine, key, SCRIPTING_EFFECT_AUDIO) {
 	_loop = loop;
 	_volume = volume;
diff --git a/engines/zvision/scripting/effects/music_effect.h b/engines/zvision/scripting/effects/music_effect.h
index f6cb4a5..7657be8 100644
--- a/engines/zvision/scripting/effects/music_effect.h
+++ b/engines/zvision/scripting/effects/music_effect.h
@@ -57,7 +57,7 @@ public:
 
 class MusicNode : public MusicNodeBASE {
 public:
-	MusicNode(ZVision *engine, uint32 key, Common::String &file, bool loop, int8 volume);
+	MusicNode(ZVision *engine, uint32 key, Common::String &file, bool loop, uint8 volume);
 	~MusicNode();
 
 	/**


Commit: 0bc61d3c2130981e06199b60fe553b2095af287a
    https://github.com/scummvm/scummvm/commit/0bc61d3c2130981e06199b60fe553b2095af287a
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2015-01-23T16:25:21+06:00

Commit Message:
ZVISION: Volume is not linear value, use dB map to linear for -100...0dB

Changed paths:
    engines/zvision/scripting/effects/music_effect.cpp



diff --git a/engines/zvision/scripting/effects/music_effect.cpp b/engines/zvision/scripting/effects/music_effect.cpp
index 6c1a5f7..ee2232d 100644
--- a/engines/zvision/scripting/effects/music_effect.cpp
+++ b/engines/zvision/scripting/effects/music_effect.cpp
@@ -36,6 +36,24 @@
 
 namespace ZVision {
 
+static const uint8 dbMapLinear[256] =
+{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2,
+2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4,
+4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7,
+8, 8, 8, 9, 9, 9, 10, 10, 11, 11, 11, 12, 12, 13, 13, 14,
+14, 15, 15, 16, 16, 17, 18, 18, 19, 20, 21, 21, 22, 23, 24, 25,
+26, 27, 28, 29, 30, 31, 32, 33, 34, 36, 37, 38, 40, 41, 43, 45,
+46, 48, 50, 52, 53, 55, 57, 60, 62, 64, 67, 69, 72, 74, 77, 80,
+83, 86, 89, 92, 96, 99, 103, 107, 111, 115, 119, 123, 128, 133, 137, 143,
+148, 153, 159, 165, 171, 177, 184, 191, 198, 205, 212, 220, 228, 237, 245, 255};
+
 MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool loop, uint8 volume)
 	: MusicNodeBASE(engine, key, SCRIPTING_EFFECT_AUDIO) {
 	_loop = loop;
@@ -65,9 +83,9 @@ MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool
 
 		if (_loop) {
 			Audio::LoopingAudioStream *loopingAudioStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES);
-			_engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, loopingAudioStream, -1, _volume);
+			_engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, loopingAudioStream, -1, dbMapLinear[_volume]);
 		} else {
-			_engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, audioStream, -1, _volume);
+			_engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, audioStream, -1, dbMapLinear[_volume]);
 		}
 
 		if (_key != StateKey_NotSet)
@@ -148,7 +166,7 @@ void MusicNode::setVolume(uint8 newVolume) {
 	if (_deltaVolume >= _volume)
 		_engine->_mixer->setChannelVolume(_handle, 0);
 	else
-		_engine->_mixer->setChannelVolume(_handle, _volume - _deltaVolume);
+		_engine->_mixer->setChannelVolume(_handle, dbMapLinear[_volume - _deltaVolume]);
 }
 
 uint8 MusicNode::getVolume() {


Commit: 9b498d576ed9b922ef61175310a6b369e4d30e3f
    https://github.com/scummvm/scummvm/commit/9b498d576ed9b922ef61175310a6b369e4d30e3f
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2015-01-23T16:26:17+06:00

Commit Message:
ZVISION: Correct value for attenuate

Changed paths:
    engines/zvision/scripting/actions.cpp



diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp
index 7581588..b12ecf6 100644
--- a/engines/zvision/scripting/actions.cpp
+++ b/engines/zvision/scripting/actions.cpp
@@ -104,7 +104,7 @@ bool ActionAttenuate::execute() {
 	ScriptingEffect *fx = _engine->getScriptManager()->getSideFX(_key);
 	if (fx && fx->getType() == ScriptingEffect::SCRIPTING_EFFECT_AUDIO) {
 		MusicNode *mus = (MusicNode *)fx;
-		mus->setVolume(255 - (abs(_attenuation) >> 7));
+		mus->setVolume(255 * (10000 - abs(_attenuation)) / 10000 );
 	}
 	return true;
 }


Commit: 568c13b11531fcfb10b53bbc84d723e6fd1d0e40
    https://github.com/scummvm/scummvm/commit/568c13b11531fcfb10b53bbc84d723e6fd1d0e40
Author: Marisa-Chan (thunder_8888 at mail.ru)
Date: 2015-01-23T16:31:10+06:00

Commit Message:
ZVISION: Use correct virtual class type instead of MusicNode

Changed paths:
    engines/zvision/scripting/actions.cpp



diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp
index b12ecf6..9a2f1d1 100644
--- a/engines/zvision/scripting/actions.cpp
+++ b/engines/zvision/scripting/actions.cpp
@@ -103,7 +103,7 @@ ActionAttenuate::ActionAttenuate(ZVision *engine, int32 slotkey, const Common::S
 bool ActionAttenuate::execute() {
 	ScriptingEffect *fx = _engine->getScriptManager()->getSideFX(_key);
 	if (fx && fx->getType() == ScriptingEffect::SCRIPTING_EFFECT_AUDIO) {
-		MusicNode *mus = (MusicNode *)fx;
+		MusicNodeBASE *mus = (MusicNodeBASE *)fx;
 		mus->setVolume(255 * (10000 - abs(_attenuation)) / 10000 );
 	}
 	return true;
@@ -154,7 +154,7 @@ bool ActionCrossfade::execute() {
 	if (_keyOne) {
 		ScriptingEffect *fx = _engine->getScriptManager()->getSideFX(_keyOne);
 		if (fx && fx->getType() == ScriptingEffect::SCRIPTING_EFFECT_AUDIO) {
-			MusicNode *mus = (MusicNode *)fx;
+			MusicNodeBASE *mus = (MusicNodeBASE *)fx;
 			if (_oneStartVolume >= 0)
 				mus->setVolume((_oneStartVolume * 255) / 100);
 
@@ -165,7 +165,7 @@ bool ActionCrossfade::execute() {
 	if (_keyTwo) {
 		ScriptingEffect *fx = _engine->getScriptManager()->getSideFX(_keyTwo);
 		if (fx && fx->getType() == ScriptingEffect::SCRIPTING_EFFECT_AUDIO) {
-			MusicNode *mus = (MusicNode *)fx;
+			MusicNodeBASE *mus = (MusicNodeBASE *)fx;
 			if (_twoStartVolume >= 0)
 				mus->setVolume((_twoStartVolume * 255) / 100);
 


Commit: 8f551202f6c0029773524fe4686c1147f51b4ee6
    https://github.com/scummvm/scummvm/commit/8f551202f6c0029773524fe4686c1147f51b4ee6
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-01-26T02:11:52+02:00

Commit Message:
Merge pull request #568 from Marisa-Chan/master

ZVISION: Fix sound bug #6767 by making pan_track code similar to origina...

Changed paths:
    engines/zvision/scripting/actions.cpp
    engines/zvision/scripting/effects/music_effect.cpp
    engines/zvision/scripting/effects/music_effect.h









More information about the Scummvm-git-logs mailing list