Added "gain" option to the .music files.

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@2644 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
stevo14
2008-12-12 22:16:11 +00:00
parent b30fa50775
commit d588703cf2
5 changed files with 10 additions and 5 deletions

View File

@@ -25,7 +25,8 @@
class Music
{
public:
virtual bool load (const std::string& filename) = 0;
virtual bool load (const std::string& filename,
float gain ) = 0;
virtual bool playMusic () = 0;
virtual bool stopMusic () = 0;
virtual bool pauseMusic () = 0;

View File

@@ -45,6 +45,7 @@ MusicInformation::MusicInformation(const std::string& filename)
m_fast_music = NULL;
m_faster_time = 1.0f;
m_max_pitch = 0.1f;
m_gain = 1.0f;
if(StringUtils::extension(filename)!="music")
{
@@ -84,6 +85,7 @@ MusicInformation::MusicInformation(const std::string& filename)
LISP->get ("faster-time", m_faster_time );
LISP->get ("max-pitch", m_max_pitch );
LISP->getVector("tracks", m_all_tracks );
LISP->get ("gain", m_gain );
// Get the path from the filename and add it to the ogg filename
std::string path=StringUtils::path(filename);
@@ -127,7 +129,7 @@ void MusicInformation::startMusic()
}
m_normal_music = new MusicOggStream();
if((m_normal_music->load(m_normal_filename)) == false)
if((m_normal_music->load(m_normal_filename, m_gain)) == false)
{
delete m_normal_music;
m_normal_music=0;
@@ -154,7 +156,7 @@ void MusicInformation::startMusic()
}
m_fast_music= new MusicOggStream();
if((m_fast_music->load(m_fast_filename)) == false)
if((m_fast_music->load(m_fast_filename, m_gain)) == false)
{
delete m_fast_music;
m_fast_music=0;

View File

@@ -34,6 +34,7 @@ private:
std::string m_fast_filename;
std::vector<std::string> m_all_tracks;
int m_numLoops;
float m_gain;
float m_faster_time; // Either time for fading faster
// music in, or time to change pitch
float m_max_pitch; // maximum pitch for faster music

View File

@@ -49,7 +49,7 @@ MusicOggStream::~MusicOggStream()
} // ~MusicOggStream
//-----------------------------------------------------------------------------
bool MusicOggStream::load(const std::string& filename)
bool MusicOggStream::load(const std::string& filename, float gain)
{
m_error = true;
m_fileName = filename;
@@ -94,6 +94,7 @@ bool MusicOggStream::load(const std::string& filename)
alSource3f(m_soundSource, AL_VELOCITY, 0.0, 0.0, 0.0);
alSource3f(m_soundSource, AL_DIRECTION, 0.0, 0.0, 0.0);
alSourcef (m_soundSource, AL_ROLLOFF_FACTOR, 0.0 );
alSourcef (m_soundSource, AL_GAIN, gain );
alSourcei (m_soundSource, AL_SOURCE_RELATIVE, AL_TRUE );
m_error=false;

View File

@@ -49,7 +49,7 @@ public:
virtual void updateFading(float percent);
virtual void updateFaster(float percent, float max_pitch);
virtual bool load(const std::string& filename);
virtual bool load(const std::string& filename, float gain);
virtual bool playMusic();
virtual bool stopMusic();