SFML community forums
Help => Audio => Topic started by: trinistry_ on August 20, 2011, 09:08:54 pm
-
Hello,
I have a weird Problem. The code:
sf::SoundBuffer buffer;
if (buffer.LoadFromFile("assets/sound/bonk.wav")) {
sf::Sound sound;
sound.SetBuffer(buffer);
sound.Play();
std::cout << "sound status: " << sound.GetStatus() << " sound duration: " << buffer.GetDuration() << std::endl;
}
produced output:
sound status: 2 sound duration: 0.767574
As far as I know, status 2 is "playing". There is no error or warning in linkage nor in compiler. But I do not hear anything (and yes, the sound plays in media player for example, my boxes are turned on etc...)
I am using SFML 1.6 and VS Express 2010 on Windows 7. I recompiled the sfml-dlls (not the libsndfile-1.dll and the openal32.dll - is this the reason?).
Target is "debug".
Is there anything I am missing? Could it be that the wrong sound device is taken or something?
Please help! Thanks!
-
I think the sf::Sound instance must stay alive as long as the sound is played.
-
Argh! Sure you are right.
Sorry for stupid question and many thanks for support!
-
When I use that code I get an error :P
sf::SoundBuffer buffer;
if (buffer.LoadFromFile("sound/laugh.wav")) {
sf::Sound sound;
sound.SetBuffer(buffer);
sound.Play();
}
Starting C:\Users\Ground Zero\Desktop\C++\leren\GAME\game-build-desktop\debug\test.exe...
C:\Users\Ground Zero\Desktop\C++\leren\GAME\test-build-desktop\debug\test.exe exited with code -1073741515