This commit is contained in:
Glenn Maynard
2002-12-19 04:08:38 +00:00
parent ea528c863c
commit ead9944ac6
2 changed files with 14 additions and 4 deletions
+9 -2
View File
@@ -79,7 +79,7 @@ RageSound::RageSound()
stream.buf.reserve(internal_buffer_size); stream.buf.reserve(internal_buffer_size);
m_StartSeconds = 0; m_StartSeconds = 0;
m_LengthSeconds = -1; m_LengthSeconds = -1;
AccurateSync = false;
/* Register ourselves, so we receive Update()s. */ /* Register ourselves, so we receive Update()s. */
SOUNDMAN->all_sounds.insert(this); SOUNDMAN->all_sounds.insert(this);
} }
@@ -101,7 +101,6 @@ RageSound::RageSound(const RageSound &cpy)
full_buf = cpy.full_buf; full_buf = cpy.full_buf;
big = cpy.big; big = cpy.big;
AutoStop = cpy.AutoStop;
m_sFilePath = cpy.m_sFilePath; m_sFilePath = cpy.m_sFilePath;
m_StartSeconds = cpy.m_StartSeconds; m_StartSeconds = cpy.m_StartSeconds;
m_LengthSeconds = cpy.m_LengthSeconds; m_LengthSeconds = cpy.m_LengthSeconds;
@@ -109,6 +108,8 @@ RageSound::RageSound(const RageSound &cpy)
position = cpy.position; position = cpy.position;
playing = false; playing = false;
speed = cpy.speed; speed = cpy.speed;
AccurateSync = cpy.AccurateSync;
AutoStop = cpy.AutoStop;
if(big) if(big)
{ {
@@ -560,7 +561,10 @@ void RageSound::SetPositionSeconds( float fSeconds )
if(big) { if(big) {
ASSERT(stream.Sample); ASSERT(stream.Sample);
if(AccurateSync)
Sound_AccurateSeek(stream.Sample, int(fSeconds * 1000)); Sound_AccurateSeek(stream.Sample, int(fSeconds * 1000));
else
Sound_FastSeek(stream.Sample, int(fSeconds * 1000));
stream.buf.clear(); stream.buf.clear();
} }
} }
@@ -580,6 +584,9 @@ void RageSound::LoadAndPlayIfNotAlready( CString sSoundFilePath )
return; // do nothing return; // do nothing
Load( sSoundFilePath ); Load( sSoundFilePath );
SetPositionSeconds(0);
SetStartSeconds(0);
SetLengthSeconds();
SetLooping(); SetLooping();
Play(); Play();
} }
+3
View File
@@ -68,6 +68,8 @@ class RageSound
float speed; float speed;
bool AccurateSync;
/* If true, the sound will stop when it reaches the end; otherwise it'll /* If true, the sound will stop when it reaches the end; otherwise it'll
* continue to move forward, feeding silence, which is useful to continue * continue to move forward, feeding silence, which is useful to continue
* timing longer than the actual sound. (However, if this is false, the * timing longer than the actual sound. (However, if this is false, the
@@ -99,6 +101,7 @@ public:
float GetLengthSeconds(); float GetLengthSeconds();
float GetPositionSeconds() const; float GetPositionSeconds() const;
void SetPositionSeconds( float fSeconds ); void SetPositionSeconds( float fSeconds );
void SetAccurateSync(bool yes=true) { AccurateSync = yes; }
void SetPlaybackRate( float fScale ); void SetPlaybackRate( float fScale );
float GetPlaybackRate() const { return speed; } float GetPlaybackRate() const { return speed; }
bool IsPlaying() const { return playing; } bool IsPlaying() const { return playing; }