SFML community forums

Help => Audio => Topic started by: CodingMadeEasy on January 06, 2011, 05:55:15 am

Title: Failed to open the audio device
Post by: CodingMadeEasy on January 06, 2011, 05:55:15 am
Hi. I'm trying to you music in my program but somethings wrong with
the audio class.

I include it
Code: [Select]

#include <SFML/Audio.hpp>


and whenever I create my music file I get an error in the console window that says

"Failed to open the audio device"

I've added the audio to the linker.
I've defined SFML_DYNAMIC.
I have everything in the right folder.
Graphics and stuff work fine. I just started on music today and now I can't figure out the problem.

Say I have a code like this

Code: [Select]

#include <SFML/Audio.hpp>

int main () {
sf::Music Music;
return 0;
}


I get the same error .. so what's going on with the Audio class?
[/code]
Title: Failed to open the audio device
Post by: Laurent on January 06, 2011, 08:48:03 am
Do you use the openal32.dll file which is provided with SFML? What's your OS?
Title: Failed to open the audio device
Post by: CodingMadeEasy on January 07, 2011, 05:07:47 am
yes i'm using openal32.dll which is provided with sfml.
I'm running this on windows and I'm using sfml version 1.6 .
Title: Failed to open the audio device
Post by: Laurent on January 07, 2011, 09:13:38 am
Are you sure that there's not another openal32.dll in Windows\System32 that may conflict?
Title: Failed to open the audio device
Post by: CodingMadeEasy on January 07, 2011, 09:44:35 pm
I checked and there was a openal32.dll and a openal64.dll. So I removed them and it still didn't work.

So I placed the sfml's openal32 into the system32 folder and it still won't work.

I have tried every option and it just won't work.
Title: Failed to open the audio device
Post by: CodingMadeEasy on January 09, 2011, 10:11:12 am
So is there any way you can help me? I've tried the 2.0 version and the 1.5 version but they still give the same error.

I really don't know what else I can do but I really need the sound in my game.
Title: Failed to open the audio device
Post by: Laurent on January 09, 2011, 01:07:13 pm
Is your audio config ok (hardware, drivers, etc.)? Can you play music in other softwares?
Title: Failed to open the audio device
Post by: CodingMadeEasy on January 09, 2011, 06:46:19 pm
Yes. Everything else works fine ... I make music on my laptop everyday and I listen to music everyday so all the sound drivers are fine
Title: Failed to open the audio device
Post by: CodingMadeEasy on January 10, 2011, 07:07:26 pm
What I'll do is test it out on my other computer to see if it plays the music.
If it doesn't then there must be something wrong with the audio files.

If it does work then there must be something wrong with my laptop.
I'll report back to you once I've tested it
Title: Failed to open the audio device
Post by: Laurent on January 10, 2011, 07:21:48 pm
Quote
If it doesn't then there must be something wrong with the audio files.

I don't think so. You should even have the same message without loading any sound.
Title: Failed to open the audio device
Post by: CodingMadeEasy on January 10, 2011, 10:41:35 pm
So loading the sound is the problem?
Title: Failed to open the audio device
Post by: CodingMadeEasy on January 10, 2011, 10:54:07 pm
I remember it saying earlier that I needed to use the initialize function .... but I didn't because I saw examples where you didn't need it .... and then after a while it said that it failed to open the audio device...

does that have anything to do with it?
Title: Failed to open the audio device
Post by: CodingMadeEasy on January 10, 2011, 11:37:42 pm
Ok this is weird.... Now I've made my file into an executable file and when I run the executable (.exe) file the sound works fine. But when I run it in the compiler it doesn't play :/
Title: Failed to open the audio device
Post by: Maxamor on January 11, 2011, 04:00:43 am
Is your working directory correct?

If you're using Visual Studio, for example, unless you have specified the working directory when you run your program by pressing the "debug" button it does not actually execute the program from your "Debug" folder. This could be a problem if you are referencing files in the same directory or using a relative path since they won't be found in the working directory.

In Visual Studio you can change your working directory for each configuration by going to Project > [project name] Properties... > Configuration Properties > Debugging > Working Directory.
Title: Failed to open the audio device
Post by: CodingMadeEasy on January 11, 2011, 05:55:10 pm
I'm using Code::Blocks and I have the music files in my project folder. I put the graphics in the same place and the graphics work fine .... maybe I should put the .dll files in the same folder as the .exe file.. maybe it will work then ... when I reach home I'll test it out and tell you the results

but how would you set the working directory in code::blocks?
Title: Failed to open the audio device
Post by: CodingMadeEasy on January 11, 2011, 10:29:31 pm
When I put all the audio (.dll) files in the debug folder it works.... but why doesn't this happen with graphics?