An important question about the "play sound()" command
Moderators: Bob the Hamster, marionline, SDHawk
- 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
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!

<a href="https://www.sodapiggymusic.com">Soda Piggy Website</a>
- Bob the Hamster
- Liquid Metal King Slime
- Posts: 7460
- Joined: Tue Oct 16, 2007 2:34 pm
- Location: Hamster Republic (Ontario Enclave)
- Contact:
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 :(
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.
- Soda_piggy
- Slime Knight
- Posts: 163
- Joined: Tue Oct 16, 2007 1:18 am
- Location: Osaka, Japan
- Contact:
- Bob the Hamster
- Liquid Metal King Slime
- Posts: 7460
- Joined: Tue Oct 16, 2007 2:34 pm
- Location: Hamster Republic (Ontario Enclave)
- Contact:
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
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.
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.
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.
- Soda_piggy
- Slime Knight
- Posts: 163
- Joined: Tue Oct 16, 2007 1:18 am
- Location: Osaka, Japan
- Contact: