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

Author Topic: Audio doesn't fully play[solved]  (Read 4132 times)

0 Members and 1 Guest are viewing this topic.

Devil0150

  • Newbie
  • *
  • Posts: 25
    • View Profile
    • Email
Audio doesn't fully play[solved]
« on: June 12, 2009, 11:39:10 am »
I am trying to play a wav file but it doesn't play until the end. It plays only the first 3 or 5 seconds. This is the code:
Code: [Select]
int main()
{
   // i make a sprite here
...

// i make some text
...

// here is the sound stuff
sf::SoundBuffer Sound;
if (!Sound.LoadFromFile("C:\\sound.wav"))
return 0;
sf::Sound MySound;
MySound.SetBuffer(Sound);
MySound.SetLoop(true);
sf::Event myEvent;
while (App.IsOpened())
{

while (App.GetEvent(myEvent))
{
if (myEvent.Type == sf::Event::Closed)
App.Close();
}
// Get elapsed time
float ElapsedTime = App.GetFrameTime();
 // move sprite on input
...
App.Clear();
App.Draw(Sprite);
App.Draw(Text);
MySound.Play();
App.Display();
}
return 0;
}

Sorry if it is  a stupid question, im a beginner.
Im using SFML 1.5 if necessary to know.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Audio doesn't fully play[solved]
« Reply #1 on: June 12, 2009, 03:29:09 pm »
Why do you call sf::Sound::Play() every loop iteration? Calling it once at the beginning is enough.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

nitram_cero

  • Full Member
  • ***
  • Posts: 166
    • View Profile
Audio doesn't fully play[solved]
« Reply #2 on: June 13, 2009, 09:47:58 am »
Which compiler are you using?

Try putting the OpenAL32.dll and libsndfile-1.dll files (somewhere in the SFML package) in the same directory as the ".exe"

Good luck!

Devil0150

  • Newbie
  • *
  • Posts: 25
    • View Profile
    • Email
Audio doesn't fully play[solved]
« Reply #3 on: June 13, 2009, 01:51:50 pm »
It worked fine. I just put it out of the loop. Thanks.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Audio doesn't fully play[solved]
« Reply #4 on: June 13, 2009, 02:13:57 pm »
Quote from: "nitram_cero"
Try putting the OpenAL32.dll and libsndfile-1.dll files (somewhere in the SFML package) in the same directory as the ".exe"
I guess you normally also need wrap_oal.dll (if it's not in the system directory)...
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

nitram_cero

  • Full Member
  • ***
  • Posts: 166
    • View Profile
Audio doesn't fully play[solved]
« Reply #5 on: June 16, 2009, 01:12:25 am »
I think OpenAL32.dll is wrap_oal.dll renamed (as OpenAL Soft readme says you can do to avoid the application loading any other OpenAL driver)

Laurent should be the one to answer to that.