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

Author Topic: Loading Audio  (Read 2602 times)

0 Members and 1 Guest are viewing this topic.

wilrader

  • Newbie
  • *
  • Posts: 5
    • View Profile
Loading Audio
« on: May 30, 2010, 08:04:17 am »
Is it better to load all audio for a "level" all at once, or to load them as needed on the fly? The type of audio I'm thinking of would be, for example, random sound effects that are used maybe once or twice in the level.

Wil

ETA: Let me further elaborate. If, for example, I have a spatial sound effect that is toward the end of the level (say, the sound of a waterfall), should I have the audio looping the entire time and running or should I have the audio loaded but not playing until they are within distance or should I load the audio and play when they are within distance at the same time?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Loading Audio
« Reply #1 on: May 30, 2010, 10:24:55 am »
I think you should load sounds at initialization time, and play them when you need to. Loading a sound will always take a significant amount of time, and produce lag if you do it right before playing the sound.
Laurent Gomila - SFML developer

Walker

  • Full Member
  • ***
  • Posts: 181
    • View Profile
Loading Audio
« Reply #2 on: May 30, 2010, 01:48:36 pm »
I load all my sounds at level initialisation. As for your example, it's personal preference really. I would prefer to have it stopped, and only start playing it when you are nearly close enough to hear it. I think that's a cleaner approach than having it looping at zero volume. It doesn't seem much more difficult to code either.