RCS file: /cvsroot/scummvm/scummvm/scumm/script_v8.cpp,v
retrieving revision 2.127
diff -u -r2.127 script_v8.cpp
|
|
|
1594 | 1594 | break; |
1595 | 1595 | |
1596 | 1596 | case 0xDA: // lipSyncWidth |
| 1597 | push(_sound->voiceLipSyncWidth()); |
| 1598 | break; |
1597 | 1599 | case 0xDB: // lipSyncHeight |
1598 | | // TODO - get lip sync data for the currently active voice |
1599 | | // HACK - return random values for now, to make things look half decent |
1600 | | push(_rnd.getRandomNumber(255)); |
| 1600 | push(_sound->voiceLipSyncHeight()); |
1601 | 1601 | break; |
1602 | 1602 | case 0xDC: // actorTalkAnimation |
1603 | 1603 | { |
RCS file: /cvsroot/scummvm/scummvm/scumm/sound.cpp,v
retrieving revision 1.74
diff -u -r1.74 sound.cpp
|
|
|
41 | 41 | _musicBundleBufFinal = NULL; |
42 | 42 | _musicBundleBufOutput = NULL; |
43 | 43 | _musicDisk = 0; |
| 44 | _voiceLipSyncData = NULL; |
| 45 | _voiceLipSyncLength = 0; |
44 | 46 | _talkChannel = -1; |
45 | 47 | } |
46 | 48 | |
… |
… |
|
1183 | 1185 | } |
1184 | 1186 | |
1185 | 1187 | ptr += 12; |
| 1188 | _voiceLipSyncLength = 0; |
1186 | 1189 | while(tag != MKID_BE('DATA')) { |
1187 | 1190 | tag = READ_BE_UINT32(ptr); ptr += 4; |
1188 | 1191 | switch(tag) { |
… |
… |
|
1196 | 1199 | case MKID_BE('REGN'): |
1197 | 1200 | case MKID_BE('STOP'): |
1198 | 1201 | case MKID_BE('JUMP'): |
1199 | | case MKID_BE('SYNC'): |
1200 | 1202 | size = READ_BE_UINT32(ptr); ptr += size + 4; |
1201 | 1203 | break; |
1202 | 1204 | |
| 1205 | case MKID_BE('SYNC'): |
| 1206 | size = READ_BE_UINT32(ptr); ptr += 8; |
| 1207 | _voiceLipSyncLength = size / 4 - 1; |
| 1208 | |
| 1209 | // Some voice has up to 426 entries. |
| 1210 | if (_voiceLipSyncData == NULL) |
| 1211 | _voiceLipSyncData = |
| 1212 | new _lipSyncEntry[512]; |
| 1213 | if (_voiceLipSyncLength > 512) |
| 1214 | error("Too much lip sync data: %d entries", |
| 1215 | _voiceLipSyncLength); |
| 1216 | |
| 1217 | for (int i = 0; i < _voiceLipSyncLength; i++) { |
| 1218 | _voiceLipSyncData[i].jiffies = |
| 1219 | READ_BE_UINT16(ptr); |
| 1220 | _voiceLipSyncData[i].width = ptr[2]; |
| 1221 | _voiceLipSyncData[i].height = ptr[3]; |
| 1222 | ptr += 4; |
| 1223 | } |
| 1224 | break; |
| 1225 | |
1203 | 1226 | case MKID_BE('DATA'): |
1204 | 1227 | size = READ_BE_UINT32(ptr); ptr += 4; |
1205 | 1228 | break; |
… |
… |
|
1217 | 1240 | |
1218 | 1241 | byte * final = (byte *)malloc(size); |
1219 | 1242 | memcpy(final, ptr, size); |
| 1243 | |
| 1244 | // Needed for lip sync in COMI |
| 1245 | _voiceBundleStartTime = _scumm->_system->get_msecs(); |
| 1246 | |
1220 | 1247 | if (bits == 8) { |
1221 | 1248 | return _scumm->_mixer->playRaw(NULL, final, size, rate, SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE); |
1222 | 1249 | } else if (bits == 16){ |
… |
… |
|
1225 | 1252 | warning("Sound::playBundleSound() to do more options to playRaw..."); |
1226 | 1253 | return -1; |
1227 | 1254 | } |
| 1255 | } |
| 1256 | |
| 1257 | Sound::_lipSyncEntry *Sound::voiceLipSyncData() { |
| 1258 | int jiffies = (_scumm->_system->get_msecs() - |
| 1259 | _voiceBundleStartTime) / 17; |
| 1260 | |
| 1261 | if (_voiceLipSyncLength == 0) { |
| 1262 | warning("Attempt to get lip sync data from sound with none"); |
| 1263 | if (_voiceLipSyncData == NULL) |
| 1264 | _voiceLipSyncData = new _lipSyncEntry[512]; |
| 1265 | _voiceLipSyncData[0].width = 0; |
| 1266 | _voiceLipSyncData[0].height = 0; |
| 1267 | return _voiceLipSyncData; |
| 1268 | } |
| 1269 | |
| 1270 | // Use a binary search to find the last entry with time |
| 1271 | // <= current time. Invariant: current time is in [left,right) |
| 1272 | int left = 0, right = _voiceLipSyncLength; |
| 1273 | |
| 1274 | while (right - left > 1) { |
| 1275 | int mid = (left + right) / 2; |
| 1276 | if (_voiceLipSyncData[mid].jiffies == jiffies) |
| 1277 | return _voiceLipSyncData + mid; |
| 1278 | else if (_voiceLipSyncData[mid].jiffies > jiffies) |
| 1279 | right = mid; |
| 1280 | else |
| 1281 | left = mid + 1; |
| 1282 | } |
| 1283 | return _voiceLipSyncData + left; |
1228 | 1284 | } |
1229 | 1285 | |
1230 | 1286 | int Sound::playSfxSound(void *sound, uint32 size, uint rate, bool isUnsigned) { |
RCS file: /cvsroot/scummvm/scummvm/scumm/sound.h,v
retrieving revision 1.25
diff -u -r1.25 sound.h
|
|
|
60 | 60 | int32 _outputMixerSize; |
61 | 61 | int32 _bundleSampleChannels; |
62 | 62 | |
| 63 | uint32 _voiceBundleStartTime; |
| 64 | struct _lipSyncEntry { |
| 65 | uint16 jiffies; |
| 66 | uint8 width, height; |
| 67 | }; |
| 68 | _lipSyncEntry *_voiceLipSyncData; |
| 69 | int32 _voiceLipSyncLength; |
| 70 | _lipSyncEntry *voiceLipSyncData(); |
| 71 | |
63 | 72 | File *_sfxFile; |
64 | 73 | uint32 _talk_sound_a1, _talk_sound_a2, _talk_sound_b1, _talk_sound_b2; |
65 | 74 | byte _talk_sound_mode; |
… |
… |
|
167 | 176 | void bundleMusicHandler(Scumm * scumm); |
168 | 177 | void stopBundleMusic(); |
169 | 178 | int playBundleSound(char *sound); |
| 179 | uint8 voiceLipSyncWidth() { |
| 180 | return voiceLipSyncData()->width; |
| 181 | } |
| 182 | uint8 voiceLipSyncHeight() { |
| 183 | return voiceLipSyncData()->height; |
| 184 | } |
| 185 | |
170 | 186 | byte * readCreativeVocFile(byte * ptr, uint32 & size, uint32 & rate, uint32 & loops); |
171 | 187 | int playSfxSound(void *sound, uint32 size, uint rate, bool isUnsigned); |
172 | 188 | int playSfxSound_MP3(void *sound, uint32 size); |