Mercurial > fife-parpg
diff engine/core/audio/soundemitter.h @ 487:7f1c42b66aa4
Moved the shooter demo Timer() class to helpers.py.
Changed the formula that calculates the length of the audio clip to be correct.
The shooter demo now demonstrates the use of the audio clip callbacks correctly.
Fixed the fife_timer extension to actually work.
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Mon, 03 May 2010 19:58:16 +0000 |
parents | e584b0b8b4a2 |
children | 58c0bbeeeb35 |
line wrap: on
line diff
--- a/engine/core/audio/soundemitter.h Mon May 03 15:56:00 2010 +0000 +++ b/engine/core/audio/soundemitter.h Mon May 03 19:58:16 2010 +0000 @@ -179,11 +179,11 @@ */ unsigned long getDuration() const{ if (m_soundclip) { - float samplerate = static_cast<float>(getSampleRate()); - float bitres = static_cast<float>(getBitResolution()); - float size = static_cast<float>(getDecodedLength()); - float stereo = (isStereo() ? 2.0f : 1.0f); - float time = (( size / samplerate * bitres / 8.0f) * 1000.0f ) / stereo / 2.0f; + double samplerate = static_cast<double>(getSampleRate()) / 1000.0; //convert to milliseconds + double bitres = static_cast<double>(getBitResolution()); + double size = static_cast<double>(getDecodedLength()) * 8.0; //convert to bits + double stereo = (isStereo() ? 2.0 : 1.0); + double time = ( size / (samplerate * bitres) ) / stereo; return static_cast<unsigned long>(time); }