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.
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));
}
}