From 328ba938c041831922e202673b72c2376ac58271 Mon Sep 17 00:00:00 2001 From: Dave Schuyler Date: Wed, 29 Jan 2003 04:14:22 +0000 Subject: [PATCH] changed get_time() --- panda/src/audio/audioSound.h | 14 +++++++++++++- panda/src/audiotraits/milesAudioSound.cxx | 12 ++++++------ panda/src/audiotraits/milesAudioSound.h | 15 +++++++++++++-- 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/panda/src/audio/audioSound.h b/panda/src/audio/audioSound.h index 981a913320..4dce748392 100644 --- a/panda/src/audio/audioSound.h +++ b/panda/src/audio/audioSound.h @@ -36,6 +36,9 @@ PUBLISHED: // volume, and balance, prior to calling play(). You may // set them while they're playing, but it's implementation // specific whether you get the results. + // - Calling play() a second time on the same sound before it is + // finished will start the sound again (creating a skipping or + // stuttering effect). virtual void play() = 0; virtual void stop() = 0; @@ -49,8 +52,17 @@ PUBLISHED: virtual void set_loop_count(unsigned long loop_count=1) = 0; virtual unsigned long get_loop_count() const = 0; - // start_time: 0 = begining; length() = end. + // start_time in seconds: 0 = beginning; length() = end. // inits to 0.0. + // - Unlike the other get_* and set_* calls for a sound, the + // current time position will change while the sound is playing. + // To play the same sound from a time offset a second time, + // explicitly set the time position again. When looping, the + // second and later loops will start from the beginning of the + // sound. + // - If a sound is playing, calling get_time() repeatedly will + // return different results over time. e.g.: + // float percent_complete = s.get_time() / s.length(); virtual void set_time(float start_time=0.0) = 0; virtual float get_time() const = 0; diff --git a/panda/src/audiotraits/milesAudioSound.cxx b/panda/src/audiotraits/milesAudioSound.cxx index 4f06ac7a7a..933e82c7ad 100644 --- a/panda/src/audiotraits/milesAudioSound.cxx +++ b/panda/src/audiotraits/milesAudioSound.cxx @@ -58,7 +58,7 @@ MilesAudioSound:: MilesAudioSound(MilesAudioManager* manager, HAUDIO audio, string file_name, float length) : _manager(manager), _file_name(file_name), - _start_time(0), _volume(1.0f), _balance(0), + _volume(1.0f), _balance(0), _loop_count(1), _length(length), _active(true), _paused(false) { nassertv(audio); @@ -90,7 +90,6 @@ play() { // stop any other sound that parent mgr is playing _manager->stop_all_sounds(); } - // Start playing: if (AIL_quick_play(_audio, _loop_count)) { audio_debug(" started sound " << _file_name ); @@ -170,15 +169,16 @@ get_loop_count() const { void MilesAudioSound:: set_time(float start_time) { miles_audio_debug("set_time(start_time="<