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

Author Topic: How to play several sound effects simultaneously?  (Read 16135 times)

0 Members and 2 Guests are viewing this topic.

mkalex777

  • Full Member
  • ***
  • Posts: 206
    • View Profile
Re: How to play several sound effects simultaneously?
« Reply #15 on: October 25, 2015, 06:31:55 am »
Actually List<T> is not a wrapper at all and if you naming it "array" (this is incorrect, at least in terms of .net), then you should name it "dynamic array", because it's growing collection, you can add and remove items into it. By the way .net has separate internal implementation for arrays (fixed arrays in your terms). It allows to improve performance when you work with array in compare to other collections. So, List<T> is not array at all.

Read the reference code yourself. It is essentially a wrapper. It handles the reallocations for you.

Can you show such effective Queue implementation for sound play?

willm127

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: How to play several sound effects simultaneously?
« Reply #16 on: May 22, 2016, 05:02:24 am »
Just wanted to thank everyone on this thread for all the answers and suggestions. I was having this same issue, and didn't know that vectors were the problem. You guys rock!

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: How to play several sound effects simultaneously?
« Reply #17 on: June 12, 2016, 12:57:46 pm »
if it's designed to use 256 instances, then ok.

If you can, make it configurable. Some cheaper end sound cards will lie about capabilities and simply screw up, if you try to play more than 16 sounds simultaneously (I'm looking at you, RealTek!).

With today's cards, 32 - 64 sounds should be fine, but still try to keep the number reasonable.

Also think about restarting sounds rather than playing them a second time, in case some common/short sound plays multiple times.

For example, some coin collection sound shouldn't start playing more than once every few game frames in parallel, because otherwise these would add up and get far loud than intended.