diff options
Diffstat (limited to 'engines/titanic/sound')
-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 |
3 files changed, 17 insertions, 6 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 |