SFML community forums

Help => Audio => Topic started by: Dalhai on December 16, 2010, 04:32:50 pm

Title: Problem loading sounds
Post by: Dalhai on December 16, 2010, 04:32:50 pm
Hey,

I already searched the forum and read many threads about problems with loading sounds and libsndfile-1.dll, but they didn't help me

The problem is, that the following code:

Code: [Select]

#include <SFML/Audio.hpp>
#include <iostream>

using std::cout;
using std::endl;

int main()
{
sf::SoundBuffer sb;
if(sb.LoadFromFile("boing_2.wav"))
{
sf::Sound sound;
sound.SetBuffer(sb);

sound.Play();
}
else
{
cout << "Error!" << endl;
system("pause");
}
}


Prodcues the Error:

Quote
Failed to read sound file "boing_2.wav" (Error in WAV/W64/RF64 file. Malformed ' fmt ' chunk.)
Error!



I'm on Windows 7 x86-64, using the libsndfile-1.dll from the extlibs folder of the snapshot i'm using. I recompiled SFML2 with Visual Studio 2010 Ultimate and linked the static libraries with -d suffix in debug mode, the ones without -d in release mode. I also set the SFML_STATIC preprocessor value. Updating the libsndfile-1.dll to the actual one you can get on the official homepage, doesn't change anything.
We also tried to run the code on Linux (OpenSuse 11.3, same snapshot).
There we don't get any Errors, but the sound also doesn't play.
We tried about 10 different .wav files from different sources, always the same error.

Can someone help us? :)


Edit: I tried both the 32bit and 64bit versions of libsndfile. Obviously the 64bit version produced an error...
Title: Problem loading sounds
Post by: Laurent on December 16, 2010, 04:35:51 pm
Obviously the error comes from the sound file, not from SFML. Try re-encoding it.
Title: Problem loading sounds
Post by: Dalhai on December 16, 2010, 04:36:46 pm
Thanks for your fast reply Laurent.
I just edited my post.

We tried about 10 different .wav files from different sources. None of them worked.
Title: Problem loading sounds
Post by: Laurent on December 16, 2010, 04:42:19 pm
Did you try the sound examples provided in the SFML SDK?
Title: Problem loading sounds
Post by: Dalhai on December 16, 2010, 04:46:07 pm
Hey Laurent.

We figured out the problem was that the sounds play with a annoying delay.
Adding this line:
Code: [Select]

while(sound.GetStatus() == sf::Sound::Status::Playing)
{}


Solved the first problem. Now we wonder, where the delay comes from.

Thanks anyway :) Keep up the good work!
Title: Problem loading sounds
Post by: Laurent on December 16, 2010, 04:47:42 pm
And you still have this error??
Quote
Failed to read sound file "boing_2.wav" (Error in WAV/W64/RF64 file. Malformed ' fmt ' chunk.)
Error!


Quote
Now we wonder, where the delay comes from.

In your example, the sound instance is destroyed immediately after Play() so it can't play.
Title: Problem loading sounds
Post by: Dalhai on December 16, 2010, 04:57:26 pm
Solved. Thanks Laurent.

Seems like we really got lots of broken files... :S We didn't expect that so many files in a row were broken...