[Scummvm-git-logs] scummvm master -> 6e5072e1b253038d1eb05e66937637069a3a84f8

dreammaster dreammaster at scummvm.org
Sat Sep 3 02:10:53 CEST 2016


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

Summary:
6e5072e1b2 TITANIC: Figured out sound durations for speeches & SFX


Commit: 6e5072e1b253038d1eb05e66937637069a3a84f8
    https://github.com/scummvm/scummvm/commit/6e5072e1b253038d1eb05e66937637069a3a84f8
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-09-02T20:10:48-04:00

Commit Message:
TITANIC: Figured out sound durations for speeches & SFX

Changed paths:
    engines/titanic/messages/messages.h
    engines/titanic/npcs/true_talk_npc.cpp
    engines/titanic/npcs/true_talk_npc.h
    engines/titanic/sound/proximity.cpp
    engines/titanic/sound/proximity.h
    engines/titanic/sound/sound.cpp
    engines/titanic/sound/wave_file.cpp
    engines/titanic/sound/wave_file.h
    engines/titanic/true_talk/true_talk_manager.cpp
    engines/titanic/true_talk/true_talk_manager.h
    engines/titanic/true_talk/tt_talker.cpp
    engines/titanic/true_talk/tt_talker.h



diff --git a/engines/titanic/messages/messages.h b/engines/titanic/messages/messages.h
index b70bc5e..e77804c 100644
--- a/engines/titanic/messages/messages.h
+++ b/engines/titanic/messages/messages.h
@@ -254,7 +254,7 @@ MESSAGE0(CMusicHasStoppedMsg);
 MESSAGE0(CMusicSettingChangedMsg);
 MESSAGE2(CNPCPlayAnimationMsg, const char *const *, names, nullptr, int, maxDuration, 0);
 MESSAGE1(CNPCPlayIdleAnimationMsg, const char *const *, names, 0);
-MESSAGE3(CNPCPlayTalkingAnimationMsg, int, value1, 0, int, value2, 0, const char *const *, names, nullptr);
+MESSAGE3(CNPCPlayTalkingAnimationMsg, uint, speechDuration, 0, int, value2, 0, const char *const *, names, nullptr);
 MESSAGE0(CNPCQueueIdleAnimMsg);
 MESSAGE1(CNutPuzzleMsg, CString, value, "");
 MESSAGE1(COnSummonBotMsg, int, value, 0);
@@ -328,7 +328,7 @@ MESSAGE4(CTrueTalkGetAnimSetMsg, int, value1, 0, uint, index, 0, uint, startFram
 MESSAGE2(CTrueTalkGetAssetDetailsMsg, CString, filename, "", int, numValue, 0);
 MESSAGE2(CTrueTalkGetStateValueMsg, int, stateNum, 0, int, stateVal, -1000);
 MESSAGE2(CTrueTalkNotifySpeechEndedMsg, int, value1, 0, int, dialogueId, 0);
-MESSAGE3(CTrueTalkNotifySpeechStartedMsg, uint, soundId, 0, uint, dialogueId, 0, int, value, 0);
+MESSAGE3(CTrueTalkNotifySpeechStartedMsg, uint, speechDuration, 0, uint, dialogueId, 0, int, value, 0);
 MESSAGE1(CTrueTalkQueueUpAnimSetMsg, int, value, 0);
 MESSAGE0(CTrueTalkSelfQueueAnimSetMsg);
 MESSAGE3(CTrueTalkTriggerActionMsg, int, action, 0, int, param1, 0, int, param2, 0);
diff --git a/engines/titanic/npcs/true_talk_npc.cpp b/engines/titanic/npcs/true_talk_npc.cpp
index 97913df..c677687 100644
--- a/engines/titanic/npcs/true_talk_npc.cpp
+++ b/engines/titanic/npcs/true_talk_npc.cpp
@@ -40,7 +40,7 @@ BEGIN_MESSAGE_MAP(CTrueTalkNPC, CCharacter)
 END_MESSAGE_MAP()
 
 CTrueTalkNPC::CTrueTalkNPC() : _assetName("z451.dlg"),
-	_assetNumber(0x11170), _fieldE4(0), _npcFlags(0), _soundId(0), _fieldF0(0),
+	_assetNumber(0x11170), _fieldE4(0), _npcFlags(0), _speechDuration(0), _startTicks(0),
 	_fieldF4(0), _fieldF8(0), _speechTimerId(0), _field100(0), _field104(0) {
 }
 
@@ -50,8 +50,8 @@ void CTrueTalkNPC::save(SimpleFile *file, int indent) {
 	file->writeQuotedLine(_assetName, indent);
 	file->writeNumberLine(_fieldE4, indent);
 	file->writeNumberLine(_npcFlags, indent);
-	file->writeNumberLine(_soundId, indent);
-	file->writeNumberLine(_fieldF0, indent);
+	file->writeNumberLine(_speechDuration, indent);
+	file->writeNumberLine(_startTicks, indent);
 	file->writeNumberLine(_fieldF4, indent);
 	file->writeNumberLine(_fieldF8, indent);
 	file->writeNumberLine(_speechTimerId, indent);
@@ -67,8 +67,8 @@ void CTrueTalkNPC::load(SimpleFile *file) {
 	_assetName = file->readString();
 	_fieldE4 = file->readNumber();
 	_npcFlags = file->readNumber();
-	_soundId = file->readNumber();
-	_fieldF0 = file->readNumber();
+	_speechDuration = file->readNumber();
+	_startTicks = file->readNumber();
 	_fieldF4 = file->readNumber();
 	_fieldF8 = file->readNumber();
 	_speechTimerId = file->readNumber();
@@ -102,18 +102,18 @@ bool CTrueTalkNPC::TrueTalkNotifySpeechStartedMsg(CTrueTalkNotifySpeechStartedMs
 		if (_speechTimerId)
 			stopTimer(_speechTimerId);
 
-		_soundId = msg->_soundId;
-		_fieldF0 = getTicksCount();
+		_speechDuration = msg->_speechDuration;
+		_startTicks = getTicksCount();
 
 		if (hasActiveMovie() || (_npcFlags & NPCFLAG_2)) {
 			_npcFlags &= ~NPCFLAG_2;
 			stopMovie();
 
-			CNPCPlayTalkingAnimationMsg msg1(_soundId, 0, 0);
+			CNPCPlayTalkingAnimationMsg msg1(_speechDuration, 0, 0);
 			msg1.execute(this);
 
 			if (msg1._names) {
-				CNPCPlayAnimationMsg msg2(msg1._names, msg1._value1);
+				CNPCPlayAnimationMsg msg2(msg1._names, msg1._speechDuration);
 				msg2.execute(this);
 			}
 		}
@@ -125,7 +125,7 @@ bool CTrueTalkNPC::TrueTalkNotifySpeechStartedMsg(CTrueTalkNotifySpeechStartedMs
 bool CTrueTalkNPC::TrueTalkNotifySpeechEndedMsg(CTrueTalkNotifySpeechEndedMsg *msg) {
 	_npcFlags &= ~NPCFLAG_SPEAKING;
 	--_field100;
-	_soundId = 0;
+	_speechDuration = 0;
 
 	if (!(_npcFlags & NPCFLAG_8)) {
 		CNPCPlayTalkingAnimationMsg msg1(0, 2, 0);
@@ -147,13 +147,13 @@ bool CTrueTalkNPC::MovieEndMsg(CMovieEndMsg *msg) {
 		return false;
 	}
 
-	int diff = getTicksCount() - _fieldF0;
-	int ticks = MAX((int)_soundId - diff, 0);
+	int diff = getTicksCount() - _startTicks;
+	int ticks = MAX((int)_speechDuration - diff, 0);
 	CNPCPlayTalkingAnimationMsg msg1(ticks, ticks > 1000 ? 2 : 1, 0);
 	msg1.execute(this);
 
 	if (msg1._names) {
-		CNPCPlayAnimationMsg msg2(msg1._names, msg1._value1);
+		CNPCPlayAnimationMsg msg2(msg1._names, ticks);
 		msg2.execute(this);
 	}
 
diff --git a/engines/titanic/npcs/true_talk_npc.h b/engines/titanic/npcs/true_talk_npc.h
index 5254eaf..1e06e9c 100644
--- a/engines/titanic/npcs/true_talk_npc.h
+++ b/engines/titanic/npcs/true_talk_npc.h
@@ -57,8 +57,8 @@ protected:
 	CString _assetName;
 	int _fieldE4;
 	uint _npcFlags;
-	uint _soundId;
-	int _fieldF0;
+	uint _speechDuration;
+	uint _startTicks;
 	int _fieldF4;
 	int _fieldF8;
 	int _speechTimerId;
diff --git a/engines/titanic/sound/proximity.cpp b/engines/titanic/sound/proximity.cpp
index 9e70722..59639fd 100644
--- a/engines/titanic/sound/proximity.cpp
+++ b/engines/titanic/sound/proximity.cpp
@@ -31,7 +31,7 @@ CProximity::CProximity() : _field4(0), _channelVolume(100), _fieldC(0),
 		_range(0.5), _elevation(0), _posX(0.0), _posY(0.0), _posZ(0.0),
 		_hasVelocity(false), _velocityX(0), _velocityY(0), _velocityZ(0),
 		_field54(0), _field58(0), _field5C(0), _freeSoundFlag(false), _endTalkerFn(nullptr),
-		_talker(nullptr), _field6C(0), _soundType(Audio::Mixer::kPlainSoundType) {
+		_talker(nullptr), _soundDuration(0), _soundType(Audio::Mixer::kPlainSoundType) {
 }
 
 } // End of namespace Titanic
diff --git a/engines/titanic/sound/proximity.h b/engines/titanic/sound/proximity.h
index 41c2268..adad97d 100644
--- a/engines/titanic/sound/proximity.h
+++ b/engines/titanic/sound/proximity.h
@@ -62,7 +62,7 @@ public:
 	bool _freeSoundFlag;
 	CEndTalkerFn _endTalkerFn;
 	TTtalker *_talker;
-	int _field6C;
+	uint _soundDuration;
 	Audio::Mixer::SoundType _soundType;
 public:
 	CProximity();
diff --git a/engines/titanic/sound/sound.cpp b/engines/titanic/sound/sound.cpp
index 6d27d1d..39c8d04 100644
--- a/engines/titanic/sound/sound.cpp
+++ b/engines/titanic/sound/sound.cpp
@@ -158,7 +158,7 @@ int CSound::playSound(const CString &name, CProximity &prox) {
 	if (!waveFile)
 		return -1;
 
-	prox._field6C = waveFile->fn1();
+	prox._soundDuration = waveFile->getDuration();
 	if (prox._soundType != Audio::Mixer::kPlainSoundType)
 		waveFile->_soundType = prox._soundType;
 
@@ -208,7 +208,7 @@ int CSound::playSpeech(CDialogueFile *dialogueFile, int speechId, CProximity &pr
 	if (!waveFile)
 		return -1;
 
-	prox._field6C = waveFile->fn1();
+	prox._soundDuration = waveFile->getDuration();
 	activateSound(waveFile, prox._freeSoundFlag);
 
 	return _soundManager.playSound(*waveFile, prox);
diff --git a/engines/titanic/sound/wave_file.cpp b/engines/titanic/sound/wave_file.cpp
index 8c00637..3f855cd 100644
--- a/engines/titanic/sound/wave_file.cpp
+++ b/engines/titanic/sound/wave_file.cpp
@@ -43,9 +43,8 @@ CWaveFile::~CWaveFile() {
 	}
 }
 
-int CWaveFile::fn1() {
-	// TODO
-	return 0;
+uint CWaveFile::getDuration() const {
+	return _stream ? _stream->getLength().secs() : 0;
 }
 
 bool CWaveFile::loadSound(const CString &name) {
diff --git a/engines/titanic/sound/wave_file.h b/engines/titanic/sound/wave_file.h
index aede0c9..4237f1a 100644
--- a/engines/titanic/sound/wave_file.h
+++ b/engines/titanic/sound/wave_file.h
@@ -45,7 +45,10 @@ public:
 	CWaveFile(QSoundManager *owner);
 	~CWaveFile();
 
-	int fn1();
+	/**
+	 * Returns the duration of the wave file in seconds
+	 */
+	uint getDuration() const;
 
 	/**
 	 * Return the size of the wave file
diff --git a/engines/titanic/true_talk/true_talk_manager.cpp b/engines/titanic/true_talk/true_talk_manager.cpp
index 085f0bd..be9ca66 100644
--- a/engines/titanic/true_talk/true_talk_manager.cpp
+++ b/engines/titanic/true_talk/true_talk_manager.cpp
@@ -347,14 +347,14 @@ void CTrueTalkManager::setDialogue(CTrueTalkNPC *npc, TTroomScript *roomScript,
 	if (dialogueStr.empty())
 		return;
 
-	int soundId = readDialogSound();
+	uint speechDuration = readDialogueSpeech();
 	TTtalker *talker = new TTtalker(this, npc);
 	_talkers.push_back(talker);
 
 	bool isParrot = npc->getName().contains("parrot");
 	triggerNPC(npc);
 	playSpeech(talker, roomScript, view, isParrot);
-	talker->speechStarted(dialogueStr, _titleEngine._indexes[0], soundId);
+	talker->speechStarted(dialogueStr, _titleEngine._indexes[0], speechDuration);
 }
 
 #define STRING_BUFFER_SIZE 2048
@@ -400,30 +400,30 @@ CString CTrueTalkManager::readDialogueString() {
 	return result;
 }
 
-int CTrueTalkManager::readDialogSound() {
-	_field18 = 0;
+uint CTrueTalkManager::readDialogueSpeech() {
+	_speechDuration = 0;
 
 	for (uint idx = 0; idx < _titleEngine._indexes.size(); ++idx) {
 		CWaveFile *waveFile = _gameManager->_sound.getTrueTalkSound(
 			_dialogueFile, _titleEngine._indexes[idx] - _dialogueId);
 		if (waveFile) {			
-			_field18 = waveFile->fn1();
+			_speechDuration += waveFile->getDuration();
 		}
 	}
 
-	return _field18;
+	return _speechDuration;
 }
 
 void CTrueTalkManager::triggerNPC(CTrueTalkNPC *npc) {
 	CTrueTalkSelfQueueAnimSetMsg queueSetMsg;
 	if (queueSetMsg.execute(npc)) {
-		if (_field18 > 300) {
-			CTrueTalkQueueUpAnimSetMsg upMsg(_field18);
+		if (_speechDuration > 300) {
+			CTrueTalkQueueUpAnimSetMsg upMsg(_speechDuration);
 			upMsg.execute(npc);
 		}
 	} else {
 		CTrueTalkGetAnimSetMsg getAnimMsg;
-		if (_field18 > 300) {
+		if (_speechDuration > 300) {
 			do {
 				getAnimMsg.execute(npc);
 				if (!getAnimMsg._endFrame)
@@ -435,10 +435,10 @@ void CTrueTalkManager::triggerNPC(CTrueTalkNPC *npc) {
 				uint numFrames = getAnimMsg._endFrame - getAnimMsg._startFrame;
 				int64 val = (numFrames * 1000) * 0x88888889;
 				uint diff = (val >> (32 + 5)) - 500;
-				_field18 += diff;
+				_speechDuration += diff;
 
 				getAnimMsg._index++;
-			} while (_field18 > 0);
+			} while (_speechDuration > 0);
 		}
 	}
 }
diff --git a/engines/titanic/true_talk/true_talk_manager.h b/engines/titanic/true_talk/true_talk_manager.h
index e891f61..3abf4c1 100644
--- a/engines/titanic/true_talk/true_talk_manager.h
+++ b/engines/titanic/true_talk/true_talk_manager.h
@@ -50,7 +50,7 @@ private:
 	int _currentCharId;
 	CDialogueFile *_dialogueFile;
 	int _dialogueId;
-	int _field18;
+	uint _speechDuration;
 	TTtalkerList _talkers;
 private:
 	/**
@@ -96,9 +96,10 @@ private:
 	CString readDialogueString();
 
 	/**
-	 * Read in the sound from the dialogue file
+	 * Read in the speech from the dialogue file
+	 * @returns		Duration of the speech in seconds
 	 */
-	int readDialogSound();
+	uint readDialogueSpeech();
 
 	/**
 	 * Triggers animation for the NPC
diff --git a/engines/titanic/true_talk/tt_talker.cpp b/engines/titanic/true_talk/tt_talker.cpp
index 61443a4..9bb9986 100644
--- a/engines/titanic/true_talk/tt_talker.cpp
+++ b/engines/titanic/true_talk/tt_talker.cpp
@@ -26,10 +26,10 @@
 
 namespace Titanic {
 
-void TTtalker::speechStarted(const CString &dialogueStr, uint dialogueId, uint soundId) {
+void TTtalker::speechStarted(const CString &dialogueStr, uint dialogueId, uint speechHandle) {
 	_dialogueId = dialogueId;
 
-	CTrueTalkNotifySpeechStartedMsg msg(soundId, dialogueId, 0);
+	CTrueTalkNotifySpeechStartedMsg msg(speechHandle, dialogueId, 0);
 	msg.execute(_npc, nullptr, MSGFLAG_BREAK_IF_HANDLED);
 }
 
diff --git a/engines/titanic/true_talk/tt_talker.h b/engines/titanic/true_talk/tt_talker.h
index 636eb0c..bc1687e 100644
--- a/engines/titanic/true_talk/tt_talker.h
+++ b/engines/titanic/true_talk/tt_talker.h
@@ -49,7 +49,7 @@ public:
 	/**
 	 * Start a new speech
 	 */
-	void speechStarted(const CString &dialogueStr, uint dialogueId, uint soundId);
+	void speechStarted(const CString &dialogueStr, uint dialogueId, uint speechHandle);
 
 	/**
 	 * End the speech





More information about the Scummvm-git-logs mailing list