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

Author Topic: "Failed to open sound file "FOO.wav" (format not supported)" for any format  (Read 10935 times)

0 Members and 3 Guests are viewing this topic.

tcpie

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

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11033
    • View Profile
    • development blog
    • Email
Do you just change the extension or are they actually wav/flac/ogg files?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

tcpie

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

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11033
    • View Profile
    • development blog
    • Email
Could you provide the files which give you "format not supported"?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

tcpie

  • Newbie
  • *
  • Posts: 4
    • View Profile
I reckoned you meant the audio files? I attached them to this post.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11033
    • View Profile
    • development blog
    • Email
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));
    }
}
 
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

tcpie

  • Newbie
  • *
  • Posts: 4
    • View Profile
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.
« Last Edit: August 01, 2015, 02:07:12 pm by tcpie »

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
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").

 

anything