[Scummvm-cvs-logs] CVS: residual actor.cpp,1.36,1.37 actor.h,1.18,1.19 costume.cpp,1.22,1.23 lipsynch.cpp,1.5,1.6 lipsynch.h,1.5,1.6 lua.cpp,1.89,1.90 main.cpp,1.42,1.43 resource.cpp,1.20,1.21

Pawel Kolodziejski aquadran at users.sourceforge.net
Sat Jan 1 13:09:04 CET 2005


Update of /cvsroot/scummvm/residual
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29605

Modified Files:
	actor.cpp actor.h costume.cpp lipsynch.cpp lipsynch.h lua.cpp 
	main.cpp resource.cpp 
Log Message:
handle sfx and voice by imuse

Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/actor.cpp,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- actor.cpp	1 Jan 2005 12:27:55 -0000	1.36
+++ actor.cpp	1 Jan 2005 21:07:47 -0000	1.37
@@ -25,13 +25,15 @@
 
 #include "mixer/mixer.h"
 
+#include "imuse/imuse.h"
+
 #include <cmath>
 #include <cstring>
 
 Actor::Actor(const char *name) :
 		_name(name), _talkColor(255, 255, 255), _pos(0, 0, 0),
 		_pitch(0), _yaw(0), _roll(0), _walkRate(0), _turnRate(0),
-		_visible(true),/* _talkSound(NULL),*/ _lipSynch(NULL), _turning(false), _walking(false),
+		_visible(true), _lipSynch(NULL), _turning(false), _walking(false),
 		_restCostume(NULL), _restChore(-1),
 		_walkCostume(NULL), _walkChore(-1), _walkedLast(false), _walkedCur(false),
 		_turnCostume(NULL), _leftTurnChore(-1), _rightTurnChore(-1),
@@ -220,53 +222,33 @@
 	if (secondSlash == NULL)
 		return;
 
-//	if (_talkSound) // Only one line at a time, please :)
-//		shutUp();
-
 	std::string msgText = g_localizer->localize(secondSlash + 1);
  	std::string msgId(msg + 1, secondSlash);
 
-//	_talkSound = g_resourceloader->loadSound((msgId + ".wav").c_str());
-	_lipSynch = g_resourceloader->loadLipSynch((msgId + ".lip").c_str());
+	if (_talkSoundName == (msgId + ".wav"))
+		return;
 
-/*	if (_talkSound != NULL) {
-		Mixer::instance()->playVoice(_talkSound);
+	if (g_imuse->getSoundStatus(_talkSoundName.c_str()))
+		shutUp();
 
-		// Sometimes actors speak offscreen before they, including their 
-		// talk chores are initialized.
-		// For example, when reading the work order (a LIP file exists for no reason).
-		// Also, some lip synch files have no entries
-		// In these case, revert to using the mumble chore.
-		if (_lipSynch != NULL && _lipSynch->getStatus()) {
-			_talkAnim = _lipSynch->getCurrEntry().anim;
-		    if (_talkChore[_talkAnim] >= 0) {
-				_talkCostume[_talkAnim]->playChoreLooping(_talkChore[_talkAnim]);
-				_lipSynch->advanceEntry();
-			}			
-		} else {
-		    _lipSynch = NULL;
-      		if (_mumbleChore >= 0)
-      			_mumbleCostume->playChoreLooping(_mumbleChore);
-		}		
-	}*/
+	_lipSynch = g_resourceloader->loadLipSynch((msgId + ".lip").c_str());
+	_talkSoundName = msgId + ".wav";
+	g_imuse->startVoice(_talkSoundName.c_str());
+	_talkAnim = -1;
 }
 
 bool Actor::talking() {
-//	return (_talkSound != NULL && !_talkSound->done());
-	return false;
+	return g_imuse->getSoundStatus(_talkSoundName.c_str());
 }
 
 void Actor::shutUp() {
-/*	if (_talkSound) {
-		Mixer::instance()->stopVoice(_talkSound);
-		if (_lipSynch != NULL) {
-			if (_talkChore[_talkAnim] >= 0)
-				_talkCostume[_talkAnim]->stopChore(_talkChore[_talkAnim]);
-			_lipSynch = NULL;
-		} else if (_mumbleChore >= 0)
-			_mumbleCostume->stopChore(_mumbleChore);
-		_talkSound = NULL;
-	}*/
+	if (_lipSynch != NULL) {
+		g_imuse->stopSound(_talkSoundName.c_str());
+		if (_talkChore[_talkAnim] >= 0)
+			_talkCostume[_talkAnim]->stopChore(_talkChore[_talkAnim]);
+		_lipSynch = NULL;
+	} else if (_mumbleChore >= 0)
+		_mumbleCostume->stopChore(_mumbleChore);
 }
 
 void Actor::pushCostume(const char *name) {
@@ -396,27 +378,26 @@
 	_currTurnDir = 0;
 
 	// Update lip synching
-/*	if (_lipSynch != NULL && _talkSound != NULL &&
-			_talkSound->hasReachedPos(_lipSynch->getCurrEntry().frame * g_mixer->getOutputRate() / 60)) {
-
-		//printf("Reached beyond frame %d (=pos %d). Playing anim %d\n",
-  				//_lipSynch->getCurrEntry().frame, _lipSynch->getCurrEntry().frame * 
-				//g_mixer->getOutputRate() / 60, _lipSynch->getCurrEntry().anim);
-
-		if (_talkChore[_talkAnim] >= 0)
-			_talkCostume[_talkAnim]->stopChore(_talkChore[_talkAnim]);
-
-		_talkAnim = _lipSynch->getCurrEntry().anim;
-
-		if (_talkChore[_talkAnim] >= 0)
-			_talkCostume[_talkAnim]->playChoreLooping(_talkChore[_talkAnim]);
-
-		_lipSynch->advanceEntry();
+	if (_lipSynch != NULL) {
+		int posSound = g_imuse->getPosIn60HzTicks(_talkSoundName.c_str());
+		if (posSound != -1) {
+			int anim = _lipSynch->getAnim(posSound);
+			if (_talkAnim != anim) {
+				if (_talkAnim != -1 && _talkChore[_talkAnim] >= 0)
+					_talkCostume[_talkAnim]->stopChore(_talkChore[_talkAnim]);
+				if (anim != -1) {
+					_talkAnim = anim;
+					if (_talkChore[_talkAnim] >= 0) {
+						_talkCostume[_talkAnim]->playChoreLooping(_talkChore[_talkAnim]);
+					}
+				}
+			}
+		}
 	}
 
-	if (_talkSound != NULL && _talkSound->done())
+	if (!g_imuse->isVoicePlaying())
 		shutUp();
-*/
+
 	for (std::list<Costume *>::iterator i = _costumeStack.begin(); i != _costumeStack.end(); i++) {
 		(*i)->setPosRotate(_pos, _pitch, _yaw, _roll);
 		(*i)->update();

Index: actor.h
===================================================================
RCS file: /cvsroot/scummvm/residual/actor.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- actor.h	1 Jan 2005 12:27:55 -0000	1.18
+++ actor.h	1 Jan 2005 21:07:52 -0000	1.19
@@ -25,7 +25,6 @@
 #include <string>
 #include <list>
 
-class Sound;
 class Costume;
 class LipSynch;
 
@@ -126,7 +125,7 @@
 	bool _constrain;	// Constrain to walkboxes
 	bool _visible;
 	bool _lookingMode;
-//	ResPtr<Sound> _talkSound;
+	std::string _talkSoundName;
 	ResPtr<LipSynch> _lipSynch;
 	std::list<Costume *> _costumeStack;
 

Index: costume.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/costume.cpp,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- costume.cpp	1 Jan 2005 12:27:55 -0000	1.22
+++ costume.cpp	1 Jan 2005 21:07:52 -0000	1.23
@@ -26,6 +26,8 @@
 #include "model.h"
 #include "lua.h"
 
+#include "imuse/imuse.h"
+
 #include <string>
 #include <cstdio>
 #include <map>
@@ -480,35 +482,37 @@
 	~SoundComponent() { }
 
 private:
-//	ResPtr<Sound> _sound;
+	std::string _soundName;
 };
 
 SoundComponent::SoundComponent(Costume::Component *parent, int parentID, const char *filename) :
 		Costume::Component(parent, parentID) {
 	const char *comma = std::strchr(filename, ',');
 	if (comma != NULL) {
-		std::string realName(filename, comma);
-//		_sound = g_resourceloader->loadSound(realName.c_str());
+		_soundName = std::string(filename, comma);
 	} else {
-//		_sound = g_resourceloader->loadSound(filename);
+		_soundName = filename;
 	}
 }
 
 void SoundComponent::setKey(int val) {
-/*	switch (val) {
+	switch (val) {
 	case 0:
-		Mixer::instance()->playSfx(_sound);
+		g_imuse->startSfx(_soundName.c_str(), 127);
+		break;
+	case 1:
+		g_imuse->stopSound(_soundName.c_str());
 		break;
 	case 2:
-		Mixer::instance()->stopSfx(_sound);
+		g_imuse->stopSound(_soundName.c_str());
 		break;
 	default:
-		warning("Unknown key %d for sound %s\n", val, _sound->filename());
-	}*/
+		warning("Unknown key %d for sound %s\n", val, _soundName);
+	}
 }
 
 void SoundComponent::reset() {
-//	Mixer::instance()->stopSfx(_sound);
+	g_imuse->stopSound(_soundName.c_str());
 }
 
 Costume::Costume(const char *filename, const char *data, int len, Costume *prevCost) :

Index: lipsynch.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/lipsynch.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- lipsynch.cpp	1 Jan 2005 12:27:55 -0000	1.5
+++ lipsynch.cpp	1 Jan 2005 21:07:52 -0000	1.6
@@ -38,11 +38,9 @@
 
 		// There are cases where the lipsync file has no entries
 		if (_numEntries == 0) {
-			_status = false;
 			_entries = NULL;
 		}
 		else {
-		    _status = true;
 			data += 8;
 #ifdef DEBUG_VERBOSE
 			printf("Reading LipSynch %s, %d entries\n", filename, _numEntries);
@@ -65,8 +63,7 @@
 				for (int j = 0; j < _numEntries; j++)
 					printf("LIP %d) frame %d, anim %d\n", j, _entries[j].frame, _entries[j].anim);
 #endif
-		    _currEntry = 0;
-		}    
+		}
 	}
 }
 
@@ -74,13 +71,26 @@
 	delete[] _entries;
 }
 
-LipSynch::LipEntry LipSynch::getCurrEntry() {
-	return _entries[_currEntry];
-}
+int LipSynch::getAnim(int pos) {
+	int frame1, frame2;
 
-void LipSynch::advanceEntry() {
-	if (_currEntry < _numEntries)
-		_currEntry++;
+	// tune a bit to prevent internal imuse drift
+	pos += 15;
+
+	for (int i = 0; i < _numEntries; i++) {
+		frame1 = _entries[i].frame;
+		if ((i + 1) < _numEntries) {
+			frame2 = _entries[i + 1].frame;
+		} else {
+			frame2 = (unsigned int)-1L;
+		}
+		if ((pos >= frame1) && (pos < frame2)) {
+			//printf("frame1: %d, frame2: %d, pos: %d, i: %d, num: %d\n", frame1, frame2, pos, i, _numEntries -1);
+			return _entries[i].anim;
+		}
+	}
+
+	return -1;
 }
 
 const LipSynch::PhonemeAnim LipSynch::_animTable[] = {

Index: lipsynch.h
===================================================================
RCS file: /cvsroot/scummvm/residual/lipsynch.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- lipsynch.h	1 Jan 2005 12:27:55 -0000	1.5
+++ lipsynch.h	1 Jan 2005 21:07:52 -0000	1.6
@@ -33,20 +33,17 @@
 		uint16 anim;
 	};
 
-	LipEntry getCurrEntry();
-	void advanceEntry();
-	bool getStatus() const { return _status; }
+	int getAnim(int pos);
 
 private:
 	LipEntry *_entries;
 	int _numEntries;
-	int _currEntry;
-	bool _status;
 
 	struct PhonemeAnim {
 		uint16 phoneme;
 		uint16 anim;
 	};
+
 	static const PhonemeAnim _animTable[];
 	static const int _animTableSize;
 };

Index: lua.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/lua.cpp,v
retrieving revision 1.89
retrieving revision 1.90
diff -u -d -r1.89 -r1.90
--- lua.cpp	1 Jan 2005 15:23:13 -0000	1.89
+++ lua.cpp	1 Jan 2005 21:07:52 -0000	1.90
@@ -677,10 +677,9 @@
 
 static void IsMessageGoing() {
 	Actor *act;
-	if (lua_getparam(1) == LUA_NOOBJECT)
-//		pushbool(Mixer::instance()->voicePlaying());
-		pushbool(false);
-	else {
+	if (lua_getparam(1) == LUA_NOOBJECT) {
+		pushbool(g_imuse->isVoicePlaying());
+	} else {
 		act = check_actor(1);
 		pushbool(act->talking());
 	}

Index: main.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/main.cpp,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- main.cpp	1 Jan 2005 12:27:56 -0000	1.42
+++ main.cpp	1 Jan 2005 21:07:52 -0000	1.43
@@ -90,7 +90,7 @@
 	g_timer = new Timer();
 	g_smush = new Smush();
 	g_driver = new Driver(640, 480, 24);
-	g_imuse = new Imuse(10);
+	g_imuse = new Imuse(20);
 
 	// Parse command line
 	ZBUFFER_GLOBAL = parseBoolStr(g_registry->get("zbuffer"));

Index: resource.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/resource.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- resource.cpp	1 Jan 2005 12:27:56 -0000	1.20
+++ resource.cpp	1 Jan 2005 21:07:52 -0000	1.21
@@ -46,8 +46,7 @@
 
 #ifdef _MSC_VER
 	WIN32_FIND_DATAA find_file_data;
-	std::string dir_strWin32 = dir_str;
-	dir_strWin32 += '*';
+	std::string dir_strWin32 = dir_str + '*';
 	HANDLE d = FindFirstFile(dir_strWin32.c_str(), &find_file_data);
 #else
 	DIR *d = opendir(dir_str.c_str());
@@ -59,7 +58,6 @@
 	if (d == NULL)
 		error("Cannot open DataDir (%s)- check configuration file", dir_str.c_str());
 
-	printf("dir open\n");
 #ifdef _MSC_VER
 	do {
 		int namelen = strlen(find_file_data.cFileName);





More information about the Scummvm-git-logs mailing list