SFML community forums

Help => Audio => Topic started by: tcpie on July 31, 2015, 10:15:49 pm

Title: "Failed to open sound file "FOO.wav" (format not supported)" for any format
Post by: tcpie on July 31, 2015, 10:15:49 pm
Hi all,

I'm trying to load an audio file and play it, but whatever I try, I keep getting the error

"Failed to open sound file "FOO.wav" (format not supported)"

So far I have tried the .flac, .wav, .ogg file formats, but none of them work! I am sure my sound file itself is fine (I can play it back with windows media player.) I also tried it out with other sound files, they all fail...

My code is:
 
sf::SoundBuffer buf;
std::cerr << "Load from buffer returns: " <<  buf.loadFromFile("gunshot02.wav") << std::endl;
 

This always returns 0. The sound file is in the same directory as the executable.

I am using SFML 2.3.0. My compile-toolchain is msys2, MinGW64. My linker list is:
-lsfml-system -lsfml-main -lsfml-graphics -lsfml-window -lsfml-audio -lopengl32 -lglu32 -lopenal32 -lflac -lvorbisenc -lvorbisfile -lvorbis -logg

My platform is Windows 7, 64 bit.
Title: AW: "Failed to open sound file "FOO.wav" (format not supported)" for any format
Post by: eXpl0it3r on July 31, 2015, 10:47:55 pm
Do you just change the extension or are they actually wav/flac/ogg files?
Title: Re: "Failed to open sound file "FOO.wav" (format not supported)" for any format
Post by: tcpie on July 31, 2015, 11:31:43 pm
I started out with a .wav file, and I export this to various file formats using Audacity.

But the original .wav should be fine as well; it plays fine. I also get the error for that file.
Title: Re: "Failed to open sound file "FOO.wav" (format not supported)" for any format
Post by: eXpl0it3r on July 31, 2015, 11:40:22 pm
Could you provide the files which give you "format not supported"?
Title: Re: "Failed to open sound file "FOO.wav" (format not supported)" for any format
Post by: tcpie on August 01, 2015, 01:06:37 am
I reckoned you meant the audio files? I attached them to this post.
Title: Re: "Failed to open sound file "FOO.wav" (format not supported)" for any format
Post by: eXpl0it3r on August 01, 2015, 01:38:07 am
All of the work fine for me, not sure what's you're doing on your end. This is the testing code I used:

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

int main()
{
    sf::SoundBuffer buf;
    buf.loadFromFile("gunshot01.ogg");
    sf::Sound sound;
    sound.setBuffer(buf);
    sound.play();

    while(sound.getStatus() == sf::Sound::Playing)
    {
        sf::sleep(sf::seconds(1.f));
    }
}
 
Title: Re: "Failed to open sound file "FOO.wav" (format not supported)" for any format
Post by: tcpie on August 01, 2015, 01:57:55 pm
Well, at least it works with the minimal code example you gave, so that's good news.

I noticed when I run the program without having the file present I get the error of "(format not supported)". So I think the problem is somehow I have working directory set to a wrong value when I run my application, resulting in it not being able to find the file.

The error message is a bit confusing in this regard, instead of saying "format not supported" it should say "file not found".

Anyways, I'll have look to see if I can get it to work in my project...

EDIT:
When I edit the working directory, it loads fine! It still doesn't play, but that's probably due to some unknown bug in my code.
Title: Re: "Failed to open sound file "FOO.wav" (format not supported)" for any format
Post by: Mario on August 02, 2015, 10:21:20 am
You should update your SFML files. 2.3.1 fixes this issue (the audio loader now differentiates between "I couldn't find the file" and "I found the file, but don't understand it").