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

Author Topic: Error loading audio file  (Read 10406 times)

0 Members and 1 Guest are viewing this topic.

TeGeek

  • Newbie
  • *
  • Posts: 13
    • View Profile
Error loading audio file
« on: January 12, 2020, 12:55:28 am »
So i have an issue where when im trying to load my wav sound file into the soundbuffer it just doesnt work i have tried with multiple files and different types of file paths but i keep getting error while trying to link the file.

 
Code: [Select]
if (!buffer.loadFromFile("sample.wav"))
{
cout << "error loading the sound file" << endl;
}
deathSound.setBuffer(this->buffer);

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Error loading audio file
« Reply #1 on: January 12, 2020, 09:04:52 am »
What errors are you getting?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

TeGeek

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Error loading audio file
« Reply #2 on: January 12, 2020, 09:18:09 am »
i get the error i wrote to get when it fails to load which is "error loading the sound file"

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Error loading audio file
« Reply #3 on: January 12, 2020, 12:22:18 pm »
SFML will print out more error information to the console if fails to load a file.

Most common error is: wrong relative path (e.g. not in working directory).
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

TeGeek

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Error loading audio file
« Reply #4 on: January 12, 2020, 12:48:25 pm »
ive tried several different types of pathing and what im expecting to be default would be in my x64 folder inside my bin.

is there any way to get it to show more info when it fails?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Error loading audio file
« Reply #5 on: January 12, 2020, 04:50:16 pm »
Quote
ive tried several different types of pathing and what im expecting to be default would be in my x64 folder inside my bin.
If run from the IDE, it's "Project properties" > "Debugging" > "Working directory". This is usually set to $(ProjectDir) by default, I personnally replace it with $(TargetDir) so that it's the same directory as the created executable.

Quote
is there any way to get it to show more info when it fails?
As already said, SFML prints error details to the standard error output (so it shows in the console by default).
Laurent Gomila - SFML developer

TeGeek

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Error loading audio file
« Reply #6 on: January 12, 2020, 05:06:44 pm »
so i changed the working directory and put the sound file in that folder but im still unable to load the file

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Error loading audio file
« Reply #7 on: January 13, 2020, 08:17:24 am »
How many times do we have to ask for the what SFML prints to the standard error output? ;D
Laurent Gomila - SFML developer

TeGeek

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Error loading audio file
« Reply #8 on: January 13, 2020, 02:59:36 pm »
i dont know how to get sfml error to show since i currently am not getting any error apart from the error message i added to show when the file fails to load.

tried some stuff with sf::err() but im not sure if im using it properly currently have it like this

Code: [Select]
if (!buffer.loadFromFile("death.wav"))
{
std::ofstream file("sfml-log.txt");
std::streambuf* previous = sf::err().rdbuf(file.rdbuf());
}

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Error loading audio file
« Reply #9 on: January 16, 2020, 01:55:02 am »
Does the file work with a simple program that only loads the file and sets that buffer to a sound?

Does "buffer" and "this->buffer" refer to the same thing?
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

TeGeek

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Error loading audio file
« Reply #10 on: January 16, 2020, 08:01:11 am »
im not able to get any sound file to work even in a program that just plays the sound

and yes they refer to the same thing

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Error loading audio file
« Reply #11 on: January 16, 2020, 08:38:53 am »
Does the "sound" example of the SFML SDK work? That should be your starting point.
Laurent Gomila - SFML developer

TeGeek

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Error loading audio file
« Reply #12 on: January 16, 2020, 10:33:12 am »
do you mean the sound example in the sfml folder?

if thats what you mean i cant run the exe file cause it says im missing OpenAL32.dll

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Error loading audio file
« Reply #13 on: January 16, 2020, 12:57:24 pm »
All the necessary DLLs are included, just copy them next to the executable.
Laurent Gomila - SFML developer

TeGeek

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Error loading audio file
« Reply #14 on: January 16, 2020, 04:33:24 pm »
i still get the same error after copying the dll to the executable

 

anything