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

Author Topic: sf::sound causes severe performance lag.  (Read 1071 times)

0 Members and 1 Guest are viewing this topic.

Me-Myself-And-I

  • Jr. Member
  • **
  • Posts: 77
    • View Profile
sf::sound causes severe performance lag.
« on: May 30, 2024, 03:46:49 pm »
I'm having trouble getting around this. If I play a simple sound it always makes the program lag. Is there something that i'm doing wrong with sf::Sound?

I have a simple script that happens only once.
                buffer[4].loadFromFile("ASSETS/thunder.wav");
                sound[4].setBuffer(buffer[4]);
                sound[4].play();
 
Its only an array of 10 sounds and an array of 10 buffers. Any clues as to why it causes a lag? More specifically, I notice a definite lag in graphics when this happens.

fallahn

  • Hero Member
  • *****
  • Posts: 504
  • Buns.
    • View Profile
    • Trederia
Re: sf::sound causes severe performance lag.
« Reply #1 on: May 30, 2024, 05:11:08 pm »
Make sure you're only loading the buffer from file *once* then keeping it around, and not trying to load it every frame

Me-Myself-And-I

  • Jr. Member
  • **
  • Posts: 77
    • View Profile
Re: sf::sound causes severe performance lag.
« Reply #2 on: May 30, 2024, 11:30:26 pm »
That fixed it.Thanks

 

anything