Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Problem loading sounds  (Read 4723 times)

0 Members and 1 Guest are viewing this topic.

Dalhai

  • Newbie
  • *
  • Posts: 4
    • View Profile
Problem loading sounds
« 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...

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Problem loading sounds
« Reply #1 on: December 16, 2010, 04:35:51 pm »
Obviously the error comes from the sound file, not from SFML. Try re-encoding it.
Laurent Gomila - SFML developer

Dalhai

  • Newbie
  • *
  • Posts: 4
    • View Profile
Problem loading sounds
« Reply #2 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Problem loading sounds
« Reply #3 on: December 16, 2010, 04:42:19 pm »
Did you try the sound examples provided in the SFML SDK?
Laurent Gomila - SFML developer

Dalhai

  • Newbie
  • *
  • Posts: 4
    • View Profile
Problem loading sounds
« Reply #4 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!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Problem loading sounds
« Reply #5 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.
Laurent Gomila - SFML developer

Dalhai

  • Newbie
  • *
  • Posts: 4
    • View Profile
Problem loading sounds
« Reply #6 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...