[Scummvm-cvs-logs] CVS: scummvm/scumm/imuse_digi dimuse.cpp,1.18,1.19 dimuse.h,1.12,1.13 dimuse_sndmgr.cpp,1.17,1.18 dimuse_sndmgr.h,1.11,1.12
Pawel Kolodziejski
aquadran at users.sourceforge.net
Fri Jan 9 14:11:02 CET 2004
Update of /cvsroot/scummvm/scummvm/scumm/imuse_digi
In directory sc8-pr-cvs1:/tmp/cvs-serv670/imuse_digi
Modified Files:
dimuse.cpp dimuse.h dimuse_sndmgr.cpp dimuse_sndmgr.h
Log Message:
added lipSync code
Index: dimuse.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/imuse_digi/dimuse.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- dimuse.cpp 9 Jan 2004 13:50:10 -0000 1.18
+++ dimuse.cpp 9 Jan 2004 22:10:32 -0000 1.19
@@ -257,19 +257,16 @@
channels = _sound->getChannels(_track[l].soundHandle);
freq = _sound->getFreq(_track[l].soundHandle);
- _track[l].iteration = freq * channels;
- if ((bits == 12) || (bits == 16))
- _track[l].iteration *= 2;
-
assert(channels == 1 || channels == 2);
- _track[l].pullSize = freq * channels;
- if (channels == 2) {
+
+ _track[l].iteration = _track[l].pullSize = freq * channels;
+
+ if (channels == 2)
mixerFlags = SoundMixer::FLAG_STEREO | SoundMixer::FLAG_REVERSE_STEREO;
- }
if ((bits == 12) || (bits == 16)) {
mixerFlags |= SoundMixer::FLAG_16BITS;
- _track[l].pullSize *= 2;
+ _track[l].iteration = _track[l].pullSize *= 2;
} else if (bits == 8) {
mixerFlags |= SoundMixer::FLAG_UNSIGNED;
} else
@@ -579,6 +576,39 @@
return 0;
}
+void IMuseDigital::getLipSync(int soundId, int syncId, int32 msPos, int32 &width, int32 &height) {
+ int32 param1 = 0, param2 = 0;
+ int32 sync_size;
+ byte *sync_ptr;
+
+ msPos /= 16;
+ if (msPos < 65536) {
+ for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) {
+ if ((_track[l].idSound == soundId) && _track[l].used) {
+ sync_size = _sound->getSyncSizeById(_track[l].soundHandle, syncId);
+ sync_ptr = _sound->getSyncPtrById(_track[l].soundHandle, syncId);
+ if ((sync_size != 0) && (sync_ptr != NULL)) {
+ sync_size /= 4;
+ while (sync_size--) {
+ if (READ_BE_UINT16(sync_ptr) >= msPos)
+ break;
+ sync_ptr += 4;
+ }
+ if (sync_size < 0)
+ sync_ptr -= 4;
+ else
+ if (READ_BE_UINT16(sync_ptr) > msPos)
+ sync_ptr -= 4;
+
+ width = sync_ptr[2];
+ height = sync_ptr[3];
+ return;
+ }
+ }
+ }
+ }
+}
+
int32 IMuseDigital::getPosInMs(int soundId) {
for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) {
if ((_track[l].idSound == soundId) && _track[l].used) {
@@ -596,23 +626,35 @@
}
int32 IMuseDigital::getCurVoiceLipSyncWidth() {
-// int32 pos = getPosInMs(kTalkSoundID);
- return _vm->_rnd.getRandomNumber(255);
+ int32 msPos = getPosInMs(kTalkSoundID) + _vm->VAR(_vm->VAR_SYNC) + 50;
+ int32 width = 0, height = 0;
+
+ getLipSync(kTalkSoundID, 0, msPos, width, height);
+ return width;
}
int32 IMuseDigital::getCurVoiceLipSyncHeight() {
-// int32 pos = getPosInMs(kTalkSoundID);
- return _vm->_rnd.getRandomNumber(255);
+ int32 msPos = getPosInMs(kTalkSoundID) + _vm->VAR(_vm->VAR_SYNC) + 50;
+ int32 width = 0, height = 0;
+
+ getLipSync(kTalkSoundID, 0, msPos, width, height);
+ return height;
}
-int32 IMuseDigital::getCurMusicLipSyncWidth(int32 param) {
-// int32 pos = getPosInMs(_curMusicId);
- return _vm->_rnd.getRandomNumber(255);
+int32 IMuseDigital::getCurMusicLipSyncWidth(int syncId) {
+ int32 msPos = getPosInMs(_curMusicId) + _vm->VAR(_vm->VAR_SYNC) + 50;
+ int32 width = 0, height = 0;
+
+ getLipSync(_curMusicId, syncId, msPos, width, height);
+ return width;
}
-int32 IMuseDigital::getCurMusicLipSyncHeight(int32 param) {
-// int32 pos = getPosInMs(_curMusicId);
- return _vm->_rnd.getRandomNumber(255);
+int32 IMuseDigital::getCurMusicLipSyncHeight(int syncId) {
+ int32 msPos = getPosInMs(_curMusicId) + _vm->VAR(_vm->VAR_SYNC) + 50;
+ int32 width = 0, height = 0;
+
+ getLipSync(_curMusicId, syncId, msPos, width, height);
+ return height;
}
} // End of namespace Scumm
Index: dimuse.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/imuse_digi/dimuse.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- dimuse.h 8 Jan 2004 20:37:26 -0000 1.12
+++ dimuse.h 9 Jan 2004 22:10:32 -0000 1.13
@@ -106,11 +106,12 @@
void parseScriptCmds(int a, int b, int c, int d, int e, int f, int g, int h);
int getSoundStatus(int sound) const;
int32 getPosInMs(int soundId);
+ void getLipSync(int soundId, int syncId, int32 msPos, int32 &width, int32 &height);
int32 getCurMusicPosInMs();
int32 getCurVoiceLipSyncWidth();
int32 getCurVoiceLipSyncHeight();
- int32 getCurMusicLipSyncWidth(int32 param);
- int32 getCurMusicLipSyncHeight(int32 param);
+ int32 getCurMusicLipSyncWidth(int syncId);
+ int32 getCurMusicLipSyncHeight(int syncId);
};
struct imuse_music_table {
Index: dimuse_sndmgr.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/imuse_digi/dimuse_sndmgr.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- dimuse_sndmgr.cpp 9 Jan 2004 20:20:01 -0000 1.17
+++ dimuse_sndmgr.cpp 9 Jan 2004 22:10:32 -0000 1.18
@@ -352,6 +352,20 @@
return -1;
}
+int ImuseDigiSndMgr::getSyncSizeById(soundStruct *soundHandle, int number) {
+ Common::StackLock tmpLock(_mutex);
+ assert(soundHandle && checkForProperHandle(soundHandle));
+ assert(number >= 0 && number < soundHandle->numSyncs);
+ return soundHandle->sync[number].size;
+}
+
+byte *ImuseDigiSndMgr::getSyncPtrById(soundStruct *soundHandle, int number) {
+ Common::StackLock tmpLock(_mutex);
+ assert(soundHandle && checkForProperHandle(soundHandle));
+ assert(number >= 0 && number < soundHandle->numSyncs);
+ return soundHandle->sync[number].ptr;
+}
+
int ImuseDigiSndMgr::getRegionIdByHookId(soundStruct *soundHandle, int number) {
Common::StackLock tmpLock(_mutex);
assert(soundHandle && checkForProperHandle(soundHandle));
Index: dimuse_sndmgr.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/imuse_digi/dimuse_sndmgr.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- dimuse_sndmgr.h 9 Jan 2004 20:20:01 -0000 1.11
+++ dimuse_sndmgr.h 9 Jan 2004 22:10:32 -0000 1.12
@@ -130,6 +130,8 @@
int getJumpHookId(soundStruct *soundHandle, int number);
int getJumpFade(soundStruct *soundHandle, int number);
char *getMarker(soundStruct *soundHandle, int number);
+ int getSyncSizeById(soundStruct *soundHandle, int number);
+ byte *getSyncPtrById(soundStruct *soundHandle, int number);
int32 getDataFromRegion(soundStruct *soundHandle, int region, byte **buf, int32 offset, int32 size);
};
More information about the Scummvm-git-logs
mailing list