[Scummvm-cvs-logs] SF.net SVN: scummvm:[45001] scummvm/trunk/engines/draci
spalek at users.sourceforge.net
spalek at users.sourceforge.net
Tue Oct 13 06:44:23 CEST 2009
Revision: 45001
http://scummvm.svn.sourceforge.net/scummvm/?rev=45001&view=rev
Author: spalek
Date: 2009-10-13 04:44:22 +0000 (Tue, 13 Oct 2009)
Log Message:
-----------
Dubbing is played.
I haven't implemented switching dubbing and subtitles on/off according to
the config manager nor the speed of the subtitles, yet.
Modified Paths:
--------------
scummvm/trunk/engines/draci/game.cpp
scummvm/trunk/engines/draci/game.h
scummvm/trunk/engines/draci/script.cpp
scummvm/trunk/engines/draci/sound.cpp
scummvm/trunk/engines/draci/sound.h
Modified: scummvm/trunk/engines/draci/game.cpp
===================================================================
--- scummvm/trunk/engines/draci/game.cpp 2009-10-12 22:27:23 UTC (rev 45000)
+++ scummvm/trunk/engines/draci/game.cpp 2009-10-13 04:44:22 UTC (rev 45001)
@@ -414,18 +414,11 @@
// Handle character talking (if there is any)
if (_loopSubstatus == kSubstatusTalk) {
- Animation *speechAnim = _vm->_anims->getAnimation(kSpeechText);
- Text *speechFrame = reinterpret_cast<Text *>(speechAnim->getFrame());
-
- uint speechDuration = kBaseSpeechDuration +
- speechFrame->getLength() * kSpeechTimeUnit /
- (128 / 16 + 1);
-
// If the current speech text has expired or the user clicked a mouse button,
// advance to the next line of text
if (_vm->_mouse->lButtonPressed() ||
_vm->_mouse->rButtonPressed() ||
- (_vm->_system->getMillis() - _speechTick) >= speechDuration) {
+ (_vm->_system->getMillis() - _speechTick) >= _speechDuration) {
_shouldExitLoop = true;
_vm->_mouse->lButtonSet(false);
@@ -1508,8 +1501,9 @@
return &_persons[personID];
}
-void Game::setSpeechTick(uint tick) {
+void Game::setSpeechTiming(uint tick, uint duration) {
_speechTick = tick;
+ _speechDuration = duration;
}
int Game::getEscRoom() const {
Modified: scummvm/trunk/engines/draci/game.h
===================================================================
--- scummvm/trunk/engines/draci/game.h 2009-10-12 22:27:23 UTC (rev 45000)
+++ scummvm/trunk/engines/draci/game.h 2009-10-13 04:44:22 UTC (rev 45001)
@@ -324,7 +324,7 @@
int shouldExitLoop() const { return _shouldExitLoop; }
void setExitLoop(int exit) { _shouldExitLoop = exit; }
- void setSpeechTick(uint tick);
+ void setSpeechTiming(uint tick, uint duration);
void updateTitle();
void updateCursor();
@@ -408,6 +408,7 @@
int _shouldExitLoop; // 0=false and 1=true are normal, 2=immediate exit after loading
uint _speechTick;
+ uint _speechDuration;
int _objUnderCursor;
int _oldObjUnderCursor;
Modified: scummvm/trunk/engines/draci/script.cpp
===================================================================
--- scummvm/trunk/engines/draci/script.cpp 2009-10-12 22:27:23 UTC (rev 45000)
+++ scummvm/trunk/engines/draci/script.cpp 2009-10-13 04:44:22 UTC (rev 45001)
@@ -713,8 +713,23 @@
// Set the loop substatus to an appropriate value
_vm->_game->setLoopSubstatus(kSubstatusTalk);
+ // Speak the dubbing if possible
+ SoundSample *sample = _vm->_dubbingArchive->getSample(sentenceID, 0);
+ uint dubbingDuration = 0;
+ if (sample) {
+ dubbingDuration = (uint) (1000.0 * sample->_length / sample->_frequency + 500.0);
+ debugC(3, kDraciSoundDebugLevel, "Playing sentence %d: %d+%d with duration %dms",
+ sentenceID, sample->_offset, sample->_length, dubbingDuration);
+ _vm->_sound->playVoice(sample);
+ }
+
// Record time
- _vm->_game->setSpeechTick(_vm->_system->getMillis());
+ const uint subtitleDuration = kBaseSpeechDuration +
+ speechFrame->getLength() * kSpeechTimeUnit /
+ (128 / 16 + 1);
+ const uint duration = subtitleDuration >= dubbingDuration ?
+ subtitleDuration : dubbingDuration;
+ _vm->_game->setSpeechTiming(_vm->_system->getMillis(), duration);
// TODO: Implement inventory part
@@ -737,6 +752,13 @@
_vm->_screen->getSurface()->markDirtyRect(speechFrame->getRect());
speechFrame->setText("");
+ // Stop the playing sample and deallocate it. Stopping should only be
+ // necessary if the user interrupts the playback.
+ if (sample) {
+ _vm->_sound->stopVoice();
+ sample->close();
+ }
+
// Revert to "normal" loop status
_vm->_game->setLoopSubstatus(kSubstatusOrdinary);
_vm->_game->setExitLoop(false);
Modified: scummvm/trunk/engines/draci/sound.cpp
===================================================================
--- scummvm/trunk/engines/draci/sound.cpp 2009-10-12 22:27:23 UTC (rev 45000)
+++ scummvm/trunk/engines/draci/sound.cpp 2009-10-13 04:44:22 UTC (rev 45001)
@@ -133,7 +133,7 @@
*
* Loads individual samples from an archive to memory on demand.
*/
-const SoundSample *SoundArchive::getSample(int i, uint freq) {
+SoundSample *SoundArchive::getSample(int i, uint freq) {
// Check whether requested file exists
if (i < 0 || i >= (int) _sampleCount) {
return NULL;
Modified: scummvm/trunk/engines/draci/sound.h
===================================================================
--- scummvm/trunk/engines/draci/sound.h 2009-10-12 22:27:23 UTC (rev 45000)
+++ scummvm/trunk/engines/draci/sound.h 2009-10-13 04:44:22 UTC (rev 45001)
@@ -68,7 +68,7 @@
void clearCache();
- const SoundSample *getSample(int i, uint freq);
+ SoundSample *getSample(int i, uint freq);
private:
Common::String _path; ///< Path to file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list