diff options
author | Paul Gilbert | 2016-10-23 20:11:30 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-10-23 20:11:30 -0400 |
commit | 3852d1406111253a0cf335c49699d862940e0323 (patch) | |
tree | befd7cf49bad6b2e5d104e0a5ce76934a268eab7 | |
parent | 588aaeac393293dd5c9a2b44f48ce6644416b96b (diff) | |
download | scummvm-rg350-3852d1406111253a0cf335c49699d862940e0323.tar.gz scummvm-rg350-3852d1406111253a0cf335c49699d862940e0323.tar.bz2 scummvm-rg350-3852d1406111253a0cf335c49699d862940e0323.zip |
TITANIC: Match the CWaveFile duration method closer to original
-rw-r--r-- | engines/titanic/sound/sound.cpp | 4 | ||||
-rw-r--r-- | engines/titanic/sound/wave_file.cpp | 13 | ||||
-rw-r--r-- | engines/titanic/sound/wave_file.h | 6 | ||||
-rw-r--r-- | engines/titanic/true_talk/true_talk_manager.cpp | 2 |
4 files changed, 18 insertions, 7 deletions
diff --git a/engines/titanic/sound/sound.cpp b/engines/titanic/sound/sound.cpp index a8c4849f2b..e48c8760c5 100644 --- a/engines/titanic/sound/sound.cpp +++ b/engines/titanic/sound/sound.cpp @@ -159,7 +159,7 @@ int CSound::playSound(const CString &name, CProximity &prox) { if (!waveFile) return -1; - prox._soundDuration = waveFile->getDuration(); + prox._soundDuration = waveFile->getDurationTicks(); if (prox._soundType != Audio::Mixer::kPlainSoundType) waveFile->_soundType = prox._soundType; @@ -209,7 +209,7 @@ int CSound::playSpeech(CDialogueFile *dialogueFile, int speechId, CProximity &pr if (!waveFile) return -1; - prox._soundDuration = waveFile->getDuration(); + prox._soundDuration = waveFile->getDurationTicks(); activateSound(waveFile, prox._disposeAfterUse); return _soundManager.playSound(*waveFile, prox); diff --git a/engines/titanic/sound/wave_file.cpp b/engines/titanic/sound/wave_file.cpp index 3f855cd053..ade94aad50 100644 --- a/engines/titanic/sound/wave_file.cpp +++ b/engines/titanic/sound/wave_file.cpp @@ -43,8 +43,17 @@ CWaveFile::~CWaveFile() { } } -uint CWaveFile::getDuration() const { - return _stream ? _stream->getLength().secs() : 0; +uint CWaveFile::getDurationTicks() const { + if (!_stream) + return 0; + + // FIXME: The original uses acmStreamSize to calculate + // a desired size. Since I have no idea how the system API + // method works, for now I'm using a simple ratio of a + // sample output to input value + uint size = _size - 0x46; + double newSize = (double)size * (1475712.0 / 199836.0); + return newSize * 1000.0 / _stream->getRate(); } bool CWaveFile::loadSound(const CString &name) { diff --git a/engines/titanic/sound/wave_file.h b/engines/titanic/sound/wave_file.h index 4237f1a203..19d367936f 100644 --- a/engines/titanic/sound/wave_file.h +++ b/engines/titanic/sound/wave_file.h @@ -46,9 +46,11 @@ public: ~CWaveFile(); /** - * Returns the duration of the wave file in seconds + * Returns the duration of the wave file + * @returns Total ticks. Not really sure how ticks + * map to real time */ - uint getDuration() const; + uint getDurationTicks() 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 a3f9523fa2..0e90676eef 100644 --- a/engines/titanic/true_talk/true_talk_manager.cpp +++ b/engines/titanic/true_talk/true_talk_manager.cpp @@ -407,7 +407,7 @@ uint CTrueTalkManager::readDialogueSpeech() { CWaveFile *waveFile = _gameManager->_sound.getTrueTalkSound( _dialogueFile, _titleEngine._indexes[idx] - _dialogueId); if (waveFile) { - _speechDuration += waveFile->getDuration(); + _speechDuration += waveFile->getDurationTicks(); } } |