Hi,
Recently, I have updated to SFML 2.0. The sf::SoundBuffer works in SFML 1.5 and 1.6 with OGG files and WAV files. But, in 2.0, seems that it plays OGG files wrongly (feels like the sound is over amplified), but works fine with WAV files.
Just to make sure, this is my sound code.
struct Sound
{
sf::Sound *sound;
sf::SoundBuffer *buffer;
ByteArray data;
};
Sound sound;
Sound *sd = &sound;
Malloc(sd->buffer, sf::SoundBuffer);
if(!sd->buffer->LoadFromFile(file.GetFilePath()))
{
Free(sd->buffer); // Free
WriteLog3("Missing audio file: %@1", file.TrimFilePath());
return;
}
Malloc(sd->sound, sf::Sound);
mSoundList.push_back(sound);
// Play sound
sd->sound->SetBuffer(*sd->buffer);
sd->sound->SetVolume(mSoundVol);
if(Math.DistanceSq(pos, mEye) < 1)
{
// 2D
sd->sound->SetRelativeToListener(true);
sd->sound->SetPosition(0, 0, 0);
}
else
{
// 3D
sd->sound->SetPosition(pos.x, pos.y, pos.z);
}
sd->sound->SetMinDistance(mDistance);
sd->sound->SetAttenuation(mAttenuation);
sd->sound->Play();
In case you're wondering, Volume is 100, Distance is 1, Attenuation is 1. DistanceSq() is <1.
Am I doing anything wrong? Or is this a bug?
Cheers!
EDIT:
I reduced the OGG sound dB by a little bit in Audacity and the problem is solved. Seems that a max dB in OGG files would cause this problem.