mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 17:35:34 -04:00
changed get_time()
This commit is contained in:
parent
31ebf3bd31
commit
328ba938c0
@ -36,6 +36,9 @@ PUBLISHED:
|
|||||||
// volume, and balance, prior to calling play(). You may
|
// volume, and balance, prior to calling play(). You may
|
||||||
// set them while they're playing, but it's implementation
|
// set them while they're playing, but it's implementation
|
||||||
// specific whether you get the results.
|
// 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 play() = 0;
|
||||||
virtual void stop() = 0;
|
virtual void stop() = 0;
|
||||||
|
|
||||||
@ -49,8 +52,17 @@ PUBLISHED:
|
|||||||
virtual void set_loop_count(unsigned long loop_count=1) = 0;
|
virtual void set_loop_count(unsigned long loop_count=1) = 0;
|
||||||
virtual unsigned long get_loop_count() const = 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.
|
// 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 void set_time(float start_time=0.0) = 0;
|
||||||
virtual float get_time() const = 0;
|
virtual float get_time() const = 0;
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ MilesAudioSound::
|
|||||||
MilesAudioSound(MilesAudioManager* manager,
|
MilesAudioSound(MilesAudioManager* manager,
|
||||||
HAUDIO audio, string file_name, float length)
|
HAUDIO audio, string file_name, float length)
|
||||||
: _manager(manager), _file_name(file_name),
|
: _manager(manager), _file_name(file_name),
|
||||||
_start_time(0), _volume(1.0f), _balance(0),
|
_volume(1.0f), _balance(0),
|
||||||
_loop_count(1), _length(length),
|
_loop_count(1), _length(length),
|
||||||
_active(true), _paused(false) {
|
_active(true), _paused(false) {
|
||||||
nassertv(audio);
|
nassertv(audio);
|
||||||
@ -90,7 +90,6 @@ play() {
|
|||||||
// stop any other sound that parent mgr is playing
|
// stop any other sound that parent mgr is playing
|
||||||
_manager->stop_all_sounds();
|
_manager->stop_all_sounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start playing:
|
// Start playing:
|
||||||
if (AIL_quick_play(_audio, _loop_count)) {
|
if (AIL_quick_play(_audio, _loop_count)) {
|
||||||
audio_debug(" started sound " << _file_name );
|
audio_debug(" started sound " << _file_name );
|
||||||
@ -170,15 +169,16 @@ get_loop_count() const {
|
|||||||
void MilesAudioSound::
|
void MilesAudioSound::
|
||||||
set_time(float start_time) {
|
set_time(float start_time) {
|
||||||
miles_audio_debug("set_time(start_time="<<start_time<<")");
|
miles_audio_debug("set_time(start_time="<<start_time<<")");
|
||||||
_start_time=start_time;
|
S32 milisecond_start_time=S32(1000*start_time);
|
||||||
S32 milisecond_start_time=S32(1000*_start_time);
|
|
||||||
AIL_quick_set_ms_position(_audio, milisecond_start_time);
|
AIL_quick_set_ms_position(_audio, milisecond_start_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
float MilesAudioSound::
|
float MilesAudioSound::
|
||||||
get_time() const {
|
get_time() const {
|
||||||
miles_audio_debug("get_time() returning "<<_start_time);
|
S32 milisecond_start_time=AIL_quick_ms_position(_audio);
|
||||||
return _start_time;
|
float start_time=float(milisecond_start_time*.001);
|
||||||
|
miles_audio_debug("get_time() returning "<<start_time);
|
||||||
|
return start_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MilesAudioSound::
|
void MilesAudioSound::
|
||||||
|
@ -35,6 +35,9 @@ public:
|
|||||||
// volume, and balance, prior to calling play(). You may
|
// volume, and balance, prior to calling play(). You may
|
||||||
// set them while they're playing, but it's implementation
|
// set them while they're playing, but it's implementation
|
||||||
// specific whether you get the results.
|
// 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).
|
||||||
void play();
|
void play();
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
@ -48,8 +51,17 @@ public:
|
|||||||
void set_loop_count(unsigned long loop_count=1);
|
void set_loop_count(unsigned long loop_count=1);
|
||||||
unsigned long get_loop_count() const;
|
unsigned long get_loop_count() const;
|
||||||
|
|
||||||
// 0 = begining; length() = end.
|
// start_time in seconds: 0 = beginning; length() = end.
|
||||||
// inits to 0.0.
|
// 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();
|
||||||
void set_time(float start_time=0.0f);
|
void set_time(float start_time=0.0f);
|
||||||
float get_time() const;
|
float get_time() const;
|
||||||
|
|
||||||
@ -85,7 +97,6 @@ protected:
|
|||||||
private:
|
private:
|
||||||
HAUDIO _audio;
|
HAUDIO _audio;
|
||||||
PT(MilesAudioManager) _manager;
|
PT(MilesAudioManager) _manager;
|
||||||
float _start_time; // 0..length()
|
|
||||||
float _volume; // 0..1.0
|
float _volume; // 0..1.0
|
||||||
float _balance; // -1..1
|
float _balance; // -1..1
|
||||||
mutable float _length; // in seconds.
|
mutable float _length; // in seconds.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user