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

Author Topic: Better understanding of the max number of sounds  (Read 4447 times)

0 Members and 1 Guest are viewing this topic.

adge

  • Newbie
  • *
  • Posts: 6
    • View Profile
Better understanding of the max number of sounds
« on: March 12, 2018, 04:07:21 pm »
Hi there,

I am currently adding sounds to my game. It's a city building game so naturally there are a lot of sound emitting entities. I read that there is a limit of 256 sounds that should never be acceeded.

Does this limit refer to the number of instances of the sf::Sound class or the number of instances where a sound is actually playing? (Same for the sf::Music of course). Furthermore, I guess that this limit is related to multithreading. Hence I'd be interested when the thread playing the sound is created. (Just out of curiosity ;))

Thanks!

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Better understanding of the max number of sounds
« Reply #1 on: March 12, 2018, 04:18:01 pm »
One approach to this is to have a set number of sf::Sound instances and then use and re-use them as necessary. This means that the sf::Sounds act as "voices" and whenever you start a new sound, you can use any sf::Sound that isn't currently in use. Consider how many things that will be actually playing at once and find your maximum. Do you really need over 200 things playing simultaneously?

A simple implementation of this can be found here: https://github.com/Hapaxia/SfmlSoundSystem

Also, as far as I'm aware, the thread is created when the sound is started/played.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Better understanding of the max number of sounds
« Reply #2 on: March 12, 2018, 05:26:47 pm »
Quote
I read that there is a limit of 256 sounds that should never be acceeded.
The "256" limit is an implementation detail of OpenAL-Soft, and might depend on the OS. So, for any detail about it, you should rather search there.

Quote
Does this limit refer to the number of instances of the sf::Sound class or the number of instances where a sound is actually playing?
It refers to the number of sf::Sound and sf::SoundStream (and derived classes) instanciated.

Quote
Furthermore, I guess that this limit is related to multithreading
I think it's rather related to the audio muxer. OpenAL-Soft uses a single thread, so there's no real multithreading.

Quote
Hence I'd be interested when the thread playing the sound is created
I have no idea; again, it happens inside OpenAL-Soft.
Laurent Gomila - SFML developer

adge

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Better understanding of the max number of sounds
« Reply #3 on: March 12, 2018, 06:53:32 pm »
Ok thanks a lot guys! Hope I can present my game to you at some point next year... Also great work with the C++ 11 support (I know its a while ago now but still worth a mention)