SFML community forums

Help => Audio => Topic started by: shobbi123 on September 07, 2014, 01:05:32 pm

Title: No sound after update to 2.1
Post by: shobbi123 on September 07, 2014, 01:05:32 pm
Hi,

I updated a project of mine to SFML 2.1 from 1.6 and since that the sound is no longer playing. My project is a cross platform application for Win, Mac and Linux and with 2.1 the sound stopped working at least on Linux and Win (haven't tried Mac yet). I tried it on different PCs with the same result..
I wanted to get the example working under linux, just the sound part, but the sound is not playing either and I don't get any error message. That's the example code I'm trying to run:
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
sf::Music music;
if (!music.openFromFile("/home/user/audiofile.ogg"))
    return EXIT_FAILURE;
music.play();
while (window.isOpen())
{
    sf::Event event;
    while (window.pollEvent(event))
    {
        if (event.type == sf::Event::Closed)
            window.close();
    }
    window.clear();
    window.display();
}
return EXIT_SUCCESS;
Does anybody have an Idea what is wrong?
Title: Re: No sound after update to 2.1
Post by: Hapax on September 07, 2014, 02:21:24 pm
Have you tried it with a specific file location i.e. full address?
Title: Re: No sound after update to 2.1
Post by: zsbzsb on September 07, 2014, 02:52:07 pm
On windows check that you are using the OpenAL dll included with the SFML package.

Have you tried it with a specific file location i.e. full address?

Really?? If the music can't be loaded then the program would exit immediately. Relative paths have nothing to do with this.
Title: Re: No sound after update to 2.1
Post by: Jesper Juhl on September 07, 2014, 04:54:53 pm
The code looks reasonable. I assume that it runs but is silent and doesn't just exit at once due to loading failing?

Unfortunately I don't have any specific guesses except for the usual stuff that cause people trouble:

- are you perhaps mixing debug/release builds of the library and your code?

- are you sure that you are using the exact same compiler to build your code as was used to build SFML?

- assuming you downloaded a pre-built SFML, have you tried compiling it yourself so that it is built with the exact same compiler as your own code.

- have you tried the latest SFML from github? It has many bug fixes compared to 2.1 .

- have you tried using a debugger to gain some insight into what's going on?
Title: Re: No sound after update to 2.1
Post by: shobbi123 on September 07, 2014, 07:08:19 pm
Thanks for the replies. I tried the full path to the file and I think I can count out compiler problems. I'm working under Linux currently, so everything (build setup, libs) comes from the Ubuntu repositories and should be compatible. I'll try debugging and if that does not help I'll revert to the old setup with sfml 1.6.
Title: Re: No sound after update to 2.1
Post by: Jesper Juhl on September 07, 2014, 07:11:38 pm
Are you 100% certain that what you got from the Ubuntu repos is SFML 2.1?
Are you 100% sure that you don't have any SFML 1.6 bits left that may be linked or included?

EDIT: and I really, strongly, recommend you to (uninstall all the distro SFML packages and) try a custom build of the latest github master branch rather than SFML 2.1 - there are so many improvements and bug fixes.

EDIT2: I have to ask the stupid question: if you use some other application to play the file, does it play OK on the same machine/OS?
Title: Re: No sound after update to 2.1
Post by: Hapax on September 08, 2014, 07:07:05 am
Relative paths have nothing to do with this.
You couldn't've been certain of this. It could have been pointing to an empty or silent sound file that loads fine.

It's not that though because he's tried full path  :D

I'd also recommend upgrading to the latest github version. It scares me that you're considering going back to 1.6.
Title: Re: No sound after update to 2.1
Post by: shobbi123 on September 09, 2014, 10:24:14 am
I have to ask the stupid question: if you use some other application to play the file, does it play OK on the same machine/OS?

Acutally that was a good question, as the file didn't play in Amarok too. The reason was simply because I had the volume on the speakers turned down :D After turning up the volumne at the speakers I could hear the sound. Sorry for having stolen your time. Now I still have to figure out why my friends can not hear sound. I guess they don't have the same problem.

Thanks to all of you for your help.
Title: Re: No sound after update to 2.1
Post by: ChronicRat on September 14, 2014, 08:02:01 pm
 ;D