An important question about the "play sound()" command

Make games! Discuss those games here.

Moderators: Bob the Hamster, marionline, SDHawk

Post Reply
User avatar
Soda_piggy
Slime Knight
Posts: 163
Joined: Tue Oct 16, 2007 1:18 am
Location: Osaka, Japan
Contact:

An important question about the "play sound()" com

Post by Soda_piggy »

Just curious if anyone knows, is there a limit to the number of sound effects that can play simultaneously using the "play sound()" command? I'm currently working on a pretty difficult-to-program music game. At any given time, it may play between 4 to 8 sounds at one time. It seems that if too many sounds are already playing that a new one will not play. Does anyone know the specifics on this? Thanks!

:D
<a href="https://www.sodapiggymusic.com">Soda Piggy Website</a>
User avatar
Bob the Hamster
Liquid Metal King Slime
Posts: 7460
Joined: Tue Oct 16, 2007 2:34 pm
Location: Hamster Republic (Ontario Enclave)
Contact:

Post by Bob the Hamster »

That varies depending on the backend.

with the music_sdl backend, you can have 8 different sound effects playing simultaneously. When you play the 9th, it will overwrite one of the others (the oldest, I think? I am not sure, maybe just the first one?)

with the music_native backend, you get 11 sound effects at a time, I think, allthough I am much less familiar with that code, so I could be wrong.

Also, there is no way to play two copies of the same sound simultaneously.

Your sound backends leave a lot to be desired :(
Last edited by Bob the Hamster on Tue Sep 30, 2014 3:18 pm, edited 1 time in total.
User avatar
Soda_piggy
Slime Knight
Posts: 163
Joined: Tue Oct 16, 2007 1:18 am
Location: Osaka, Japan
Contact:

Post by Soda_piggy »

Ok thanks for the help. I'm not sure where to find the music_native backend however. I've looked all over the OHR page.
<a href="https://www.sodapiggymusic.com">Soda Piggy Website</a>
User avatar
Bob the Hamster
Liquid Metal King Slime
Posts: 7460
Joined: Tue Oct 16, 2007 2:34 pm
Location: Hamster Republic (Ontario Enclave)
Contact:

Post by Bob the Hamster »

You can find it with the nightly builds http://hamsterrepublic.com/ohrrpgce/nightly/

However, I can't really reccomend it. It only works on Windows, which means if you rely on it, your game will not sound right on Mac, Linux or Android. It is based on a sound library that has not been updated since 2006.

Perhaps a better solution would be to increase the number of simultaneous sounds allowed by the music_sdl backend. I think we just picked 8 arbitrarily. I could try bumping it up to 11 so the backends would be the same in that regard.

EDIT: yeah, it was easy. Now music_sdl supports 11 channels, same as music_native. I am rebuilding the nightly wip builds, they should be ready within less than an hour
Last edited by Bob the Hamster on Tue Sep 30, 2014 4:01 pm, edited 2 times in total.
TMC
Metal King Slime
Posts: 4101
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Not quite; music_native/native2 has no limit on the number of simultaneous sound effects, because it resizes the array as needed. So I bumped it to 16 because 11 is an odd number.
8 sound channels was the default number for SDL_mixer.
Last edited by TMC on Tue Sep 30, 2014 9:21 pm, edited 1 time in total.
User avatar
Soda_piggy
Slime Knight
Posts: 163
Joined: Tue Oct 16, 2007 1:18 am
Location: Osaka, Japan
Contact:

Post by Soda_piggy »

Many thanks! I'll try it out tonight. You both have really helped me out here. :)
<a href="https://www.sodapiggymusic.com">Soda Piggy Website</a>
Post Reply