Fixed broken music gain property in music files

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5803 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2010-08-28 18:38:10 +00:00
parent c12963ffc4
commit 1ac59260eb
2 changed files with 18 additions and 4 deletions

View File

@ -63,7 +63,7 @@ MusicInformation::MusicInformation(const std::string& filename) throw (std::runt
{
throw std::runtime_error("Can open music XML file");
}
const int amount = root->getNumNodes();
for (int i=0; i<amount; i++)
{
@ -103,7 +103,8 @@ MusicInformation::MusicInformation(const std::string& filename) throw (std::runt
}
else if (node->getName() == "gain")
{
node->get("gain", &m_gain);
node->get("value", &m_gain);
m_adjustedGain = m_gain;
}
else
{
@ -180,8 +181,8 @@ void MusicInformation::startMusic()
m_time_since_faster = 0.0f;
m_mode = SOUND_NORMAL;
std::cout << "startMusic : m_normal_filename=<" << m_normal_filename.c_str() << ">\n";
std::cout << "startMusic : m_normal_filename=<" << m_normal_filename.c_str() << ">, gain="
<< m_adjustedGain << "\n";
if (m_normal_filename== "") return;
@ -317,6 +318,8 @@ void MusicInformation::resumeMusic()
//-----------------------------------------------------------------------------
void MusicInformation::volumeMusic(float gain)
{
// printf("Setting master volume %f\n", gain);
m_adjustedGain = m_gain * gain;
if (m_normal_music != NULL) m_normal_music->volumeMusic(m_adjustedGain);
if (m_fast_music != NULL) m_fast_music->volumeMusic(m_adjustedGain);

View File

@ -246,6 +246,17 @@ bool MusicOggStream::resumeMusic()
//-----------------------------------------------------------------------------
void MusicOggStream::volumeMusic(float gain)
{
if (gain > 1.0f)
{
gain = 1.0f;
fprintf(stderr, "WARNING: MusicOggStream::volumeMusic(%f) is out of acceptable [0, 1] range\n", gain);
}
if (gain < 0.0f)
{
gain = 0.0f;
fprintf(stderr, "WARNING: MusicOggStream::volumeMusic(%f) is out of acceptable [0, 1] range\n", gain);
}
alSourcef(m_soundSource, AL_GAIN, gain);
} // volumeMusic