Does anyone know a way to get the current number of sounds being played by SimpleSoundEngine or CocosDenshion?
How to get current # of sounds playing?
(4 posts) (3 voices)-
Posted 1 year ago #
-
As far as I have read, in SimpleAudioEngine, keeping track of the number of buffers used is the responsibility of the caller. (Not too sure about CDAudioManager/CocosDenshion).
UPDATE:
If you don't mind modifying SimpleSoundEngine, this *should* work (haven't tested it though):
-(int) getTotalBuffersUsed { int iBuffersUsed=0; for(int i = 0; i < CD_MAX_BUFFERS ; i++) { if(usedBuffers[i]) { iBuffersUsed++; } } return iBuffersUsed; }Posted 1 year ago # -
It looks like that returns the number of buffers currently loaded with a sound, but not the number of sounds currently playing. For instance, I have 16 sounds preloaded, so getTotalBuffersUsed is always returning 16 even though only 2 or 3 are currently playing.
Posted 1 year ago # -
You have to do this at the CDSoundEngine level. You need to iterate over all the sources and check which ones are playing.
Depending on what you are trying to do you may be better off using the new version of CocosDenshion and maintaining an array of CDSoundSource objects that you simply iterate over and check the playing property but without knowing more details it is hard to say.
Posted 1 year ago #
Reply
You must log in to post.