Mercurial > fife-parpg
comparison 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 |
comparison
equal
deleted
inserted
replaced
486:2aaa22475acd | 487:7f1c42b66aa4 |
---|---|
177 | 177 |
178 /** Returns the duration of the sound clip in milliseconds | 178 /** Returns the duration of the sound clip in milliseconds |
179 */ | 179 */ |
180 unsigned long getDuration() const{ | 180 unsigned long getDuration() const{ |
181 if (m_soundclip) { | 181 if (m_soundclip) { |
182 float samplerate = static_cast<float>(getSampleRate()); | 182 double samplerate = static_cast<double>(getSampleRate()) / 1000.0; //convert to milliseconds |
183 float bitres = static_cast<float>(getBitResolution()); | 183 double bitres = static_cast<double>(getBitResolution()); |
184 float size = static_cast<float>(getDecodedLength()); | 184 double size = static_cast<double>(getDecodedLength()) * 8.0; //convert to bits |
185 float stereo = (isStereo() ? 2.0f : 1.0f); | 185 double stereo = (isStereo() ? 2.0 : 1.0); |
186 float time = (( size / samplerate * bitres / 8.0f) * 1000.0f ) / stereo / 2.0f; | 186 double time = ( size / (samplerate * bitres) ) / stereo; |
187 | 187 |
188 return static_cast<unsigned long>(time); | 188 return static_cast<unsigned long>(time); |
189 } | 189 } |
190 return 0; | 190 return 0; |
191 } | 191 } |