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

Author Topic: No sound though all seems correct  (Read 2052 times)

0 Members and 1 Guest are viewing this topic.

trinistry_

  • Newbie
  • *
  • Posts: 2
    • View Profile
No sound though all seems correct
« on: August 20, 2011, 09:08:54 pm »
Hello,

I have a weird Problem. The code:

Code: [Select]

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:

Code: [Select]
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!

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
No sound though all seems correct
« Reply #1 on: August 20, 2011, 09:23:09 pm »
I think the sf::Sound instance must stay alive as long as the sound is played.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

trinistry_

  • Newbie
  • *
  • Posts: 2
    • View Profile
No sound though all seems correct
« Reply #2 on: August 20, 2011, 09:31:03 pm »
Argh! Sure you are right.

Sorry for stupid question and many thanks for support!

GroundZero

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
No sound though all seems correct
« Reply #3 on: September 01, 2011, 06:45:38 pm »
When I use that code I get an error :P

Code: [Select]
   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

 

anything