per-sample volume
This commit is contained in:
@@ -77,6 +77,7 @@ RageSound::RageSound():
|
|||||||
databuf.reserve(internal_buffer_size);
|
databuf.reserve(internal_buffer_size);
|
||||||
m_StartSample = 0;
|
m_StartSample = 0;
|
||||||
m_LengthSamples = -1;
|
m_LengthSamples = -1;
|
||||||
|
m_Volume = -1.0f; // use SOUNDMAN->GetMixVolume()
|
||||||
AccurateSync = false;
|
AccurateSync = false;
|
||||||
fade_length = 0;
|
fade_length = 0;
|
||||||
/* Register ourselves, so we receive Update()s. */
|
/* Register ourselves, so we receive Update()s. */
|
||||||
@@ -109,6 +110,7 @@ RageSound::RageSound(const RageSound &cpy):
|
|||||||
original = cpy.original;
|
original = cpy.original;
|
||||||
m_StartSample = cpy.m_StartSample;
|
m_StartSample = cpy.m_StartSample;
|
||||||
m_LengthSamples = cpy.m_LengthSamples;
|
m_LengthSamples = cpy.m_LengthSamples;
|
||||||
|
m_Volume = cpy.m_Volume;
|
||||||
StopMode = cpy.StopMode;
|
StopMode = cpy.StopMode;
|
||||||
position = cpy.position;
|
position = cpy.position;
|
||||||
playing = false;
|
playing = false;
|
||||||
@@ -513,6 +515,11 @@ int RageSound::GetPCM( char *buffer, int size, int64_t frameno )
|
|||||||
void RageSound::StartPlaying()
|
void RageSound::StartPlaying()
|
||||||
{
|
{
|
||||||
LockMut(SOUNDMAN->lock);
|
LockMut(SOUNDMAN->lock);
|
||||||
|
|
||||||
|
// If no volume is set, use the default.
|
||||||
|
if( GetVolume() == -1 )
|
||||||
|
SetVolume( SOUNDMAN->GetMixVolume() );
|
||||||
|
|
||||||
stopped_position = -1;
|
stopped_position = -1;
|
||||||
|
|
||||||
ASSERT(!playing);
|
ASSERT(!playing);
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ public:
|
|||||||
virtual int GetPCM( char *buffer, int size, int64_t sampleno ) = 0;
|
virtual int GetPCM( char *buffer, int size, int64_t sampleno ) = 0;
|
||||||
virtual int GetSampleRate() const = 0;
|
virtual int GetSampleRate() const = 0;
|
||||||
virtual RageTimer GetStartTime() const { return RageZeroTimer; }
|
virtual RageTimer GetStartTime() const { return RageZeroTimer; }
|
||||||
|
virtual float GetVolume() const = 0;
|
||||||
virtual CString GetLoadedFilePath() const = 0;
|
virtual CString GetLoadedFilePath() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -75,6 +76,8 @@ public:
|
|||||||
void SetPlaybackRate( float fScale );
|
void SetPlaybackRate( float fScale );
|
||||||
void SetFadeLength( float fSeconds );
|
void SetFadeLength( float fSeconds );
|
||||||
void SetNoFade() { SetFadeLength(0); }
|
void SetNoFade() { SetFadeLength(0); }
|
||||||
|
void SetVolume( float fVolume ) { m_Volume = fVolume; }
|
||||||
|
float GetVolume() const { return m_Volume; }
|
||||||
float GetPlaybackRate() const { return float(speed_input_samples) / speed_output_samples; }
|
float GetPlaybackRate() const { return float(speed_input_samples) / speed_output_samples; }
|
||||||
bool IsPlaying() const { return playing; }
|
bool IsPlaying() const { return playing; }
|
||||||
CString GetLoadedFilePath() const { return m_sFilePath; }
|
CString GetLoadedFilePath() const { return m_sFilePath; }
|
||||||
@@ -120,6 +123,8 @@ private:
|
|||||||
/* Amount of time to fade out at the end. */
|
/* Amount of time to fade out at the end. */
|
||||||
float fade_length;
|
float fade_length;
|
||||||
|
|
||||||
|
float m_Volume;
|
||||||
|
|
||||||
/* Hack: When we stop a playing sound, we can't ask the driver the position
|
/* Hack: When we stop a playing sound, we can't ask the driver the position
|
||||||
* (we're not playing); and we can't seek back to the current playing position
|
* (we're not playing); and we can't seek back to the current playing position
|
||||||
* when we stop (too slow), but we want to be able to report the position we
|
* when we stop (too slow), but we want to be able to report the position we
|
||||||
|
|||||||
Reference in New Issue
Block a user