comparison engine/core/audio/soundemitter.h @ 484:e584b0b8b4a2

Added SoundEmitter::getDecodedLength and SoundEmitter::getDuration. The getDuration function will allow a timer to be registered to fire after the sound has been played. This is not a callback as requested but it does provide the functionality if required. I will be committing an example of it in the shooter demo shortly. [t:346]
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Fri, 30 Apr 2010 15:33:27 +0000
parents 64738befdf3b
children 7f1c42b66aa4
comparison
equal deleted inserted replaced
483:82d44c471959 484:e584b0b8b4a2
163 return m_soundclip->getDecoder()->getSampleRate(); 163 return m_soundclip->getDecoder()->getSampleRate();
164 } 164 }
165 return 0; 165 return 0;
166 } 166 }
167 167
168 /** Returns the length of the decoded length in bytes
169 */
170 unsigned long getDecodedLength() const{
171 if (m_soundclip) {
172 return m_soundclip->getDecoder()->getDecodedLength();
173
174 }
175 return 0;
176 }
177
178 /** Returns the duration of the sound clip in milliseconds
179 */
180 unsigned long getDuration() const{
181 if (m_soundclip) {
182 float samplerate = static_cast<float>(getSampleRate());
183 float bitres = static_cast<float>(getBitResolution());
184 float size = static_cast<float>(getDecodedLength());
185 float stereo = (isStereo() ? 2.0f : 1.0f);
186 float time = (( size / samplerate * bitres / 8.0f) * 1000.0f ) / stereo / 2.0f;
187
188 return static_cast<unsigned long>(time);
189 }
190 return 0;
191 }
192
168 /** Sets the cursor position in the audio file 193 /** Sets the cursor position in the audio file
169 */ 194 */
170 void setCursor(SoundPositionType type, float value); 195 void setCursor(SoundPositionType type, float value);
171 196
172 /** Returns the cursor position in the audio file 197 /** Returns the cursor position in the audio file