SFML community forums

Help => Audio => Topic started by: Devil0150 on June 12, 2009, 11:39:10 am

Title: Audio doesn't fully play[solved]
Post by: Devil0150 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.
Title: Audio doesn't fully play[solved]
Post by: Nexus 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.
Title: Audio doesn't fully play[solved]
Post by: nitram_cero 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!
Title: Audio doesn't fully play[solved]
Post by: Devil0150 on June 13, 2009, 01:51:50 pm
It worked fine. I just put it out of the loop. Thanks.
Title: Audio doesn't fully play[solved]
Post by: Nexus 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)...
Title: Audio doesn't fully play[solved]
Post by: nitram_cero 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.