SFML community forums

Help => Audio => Topic started by: SuperCharger on April 01, 2016, 08:07:26 am

Title: Failed to open sound file "canary.wav" (couldn't open stream)
Post by: SuperCharger on April 01, 2016, 08:07:26 am
Not sure what I have done wrong or what I am missing but when I run this code I get
"Failed to open sound file "canary.wav" (couldn't open stream) message.
My code is:

sf::SoundBuffer music;

   if (!music.loadFromFile("canary.wav"))
   {
      std::cout << "Error" << std::endl;
   }

   sf::Sound buffer(music);
   buffer.play();
Title: AW: Failed to open sound file "canary.wav" (couldn't open stream)
Post by: eXpl0it3r on April 01, 2016, 08:12:33 am
It means the wav file wasn't found. The errorr message is slightly misleading due to a bug that has already been fixed in master.
Title: Re: AW: Failed to open sound file "canary.wav" (couldn't open stream)
Post by: SuperCharger on April 01, 2016, 09:20:28 am
It means the wav file wasn't found. The errorr message is slightly misleading due to a bug that has already been fixed in master.
I currently have it located in my debug folder, where should I move it and what is the correct way to type in a string for loadFromFile(string)?
Title: Re: Failed to open sound file "canary.wav" (couldn't open stream)
Post by: eXpl0it3r on April 01, 2016, 09:28:06 am
It needs to be in the working directory. If you use VS then that's by default next to your vcxprj file. The working directory can usually be changed in the project settings.
Title: Re: Failed to open sound file "canary.wav" (couldn't open stream)
Post by: SuperCharger on April 01, 2016, 09:37:22 am
It needs to be in the working directory. If you use VS then that's by default next to your vcxprj file. The working directory can usually be changed in the project settings.
That worked, just moved the files, thankyou