Play same sound effect multiple times when others are not finished yet - cocos2d-x

I use cocos2d-x 3.0 on Windows, but the game should be on Android and iOS.
I want to create coin collection sound. My player can collect for example 10 coins with 0.1 seconds delay. Now I want to play the same effect 10 times with the same delay, whereas my effect length is 1 second. SimpleAudioEngine does not play that. How I can achieve that?
In other words I want to play the same sound with multiple streams. Please help me.

Size matters. If the size of .wav file is "enough" small, then it can play multiple times.

Related

Find the FPS to take screenshots with varying video FPS?

I am building a video rendering engine and am stuck on a problem. I would like to determine the rate at which to take the screenshots.
Currently, I am setting the rate to be 25 fps. From that, I can determine the total screenshots, as an example, a 10-second video would be 250 screenshots.
for (let i = 0; i < 250; i++ {
//... i / 25 fps is what I set the HTML 5 video to be
//... this means every 0.04s or 40ms a screenshot is taken
}
The problem is that in my editor a user may combine a 25 fps video with a 30 fps video. I have found the 30 fps video will at times be choppy because the natual rate would be i / 30 which means it needs a screenshot every 0.033s or 33ms.
I am trying to come up with ways to combat this from being an issue. I would like to inform myself more around solving this problem.
As for solutions with my existing knowledge I can only think of two.
make sure every video that gets added to the editor gets re-encoded with 25fps, this could still cause issues and be problematic, since removing frames could cause jank, and adding frames is impossible.
have a variable frame rate while taking the screenshots so that when the video in view is 30fps I can change the rate of the screenshot mechanism. This poses problems when layers on top use an animation frame rate of 25 fps, or if it's next to a video side by side with a frame rate of 25.
Both solutions I can think of arent the best. So I would like to ask the folks who understand this problem the most and would like to share some of that knowledge.
Lastly, it seems the browser does a good job of handling this which tells me it's possible. Here is a screen recording of the app https://share.getcloudapp.com/KouwpkwE the first run was a bit sluggish but the second one showcases the video in the background using a frame rate of 30, then the lottie animation on top using a frame rate of 25.
When trying to capture this frame by frame at a fixed 25 I run into issues. Any techniques to solve this?
Thanks

Actionscript 3 - Play Sound Parallel and Very Often

I have a sound that must be played really often and the playback will overlap the playing of the same sound.
I kept my sounds really short but I can still hear the lack of plays. Does that mean when I try to parallel-play a sound 1000 times it will play it only 8 and ignore the others ? How many channels are there ?
Can I control and modify the parallel play behavior ?
AS3 maxes out at 32 channels. Make sure that once you're done playing a sound, you're disposing of its sound channel so that it can be freed up for another Sound to use it.

Is it possible to play an HTML5 audio element for a very specific duration (less than total duration of the sound bite)

I have a sound element that is actually a composition of several different sounds. My approach had been to only have to load a single source for sound, and play different segments based on the desired sound bite.
I can seek to the start point just fine by setting the 'currentTime' property. However, setting the 'duration' property does not seem to have any affect what-so-ever.
I've tried to use a setTimeout, but, as expected, the timer resolution is not sufficient to get consistent behavior in the audio (sometimes it does not play at all, and when it does play it's 'stop' point is inconsistent).
Is this possible? Or will I be stuck loading each sound bite in it's own individual element?
Remy Sharp has posted about this as Audio Sprites (and fixes for iOS). Does that implementation work for you?

Can I start or seek to sub-second intervals with NetStream?

I am working on a Flash Video player and am implementing the ability to start a video at x time within the span of an FLV (served from FMS). I am able to start it x seconds into a stream without any issue using
netStream.play(source, startTime);
but as far as I can tell, it only supports seconds. I am looking to be able to give a start time (or even a seek time if that is supported) in milliseconds, or really anything more precise than whole seconds.
Anyone know of any way to achieve this even by monkey patching the fl classes?
Thanks,
Doug
Well the seek will allow you to seek by a number of frames, but the spec says that it only seeks to the closes I-Frame in the FLV. That will become a problem with any method you use, because the I-Frames are the only ones that actually contain the whole picture frame (here's the gist of that).

ActionScript 3: Smooth programmatic animation

I want to animate MoviveClips/Sprite objects as smootly as possible. However so far the only method that works is placing the movement code into the EnterFrame event handler. There is one problem with this approach: when the framerate on a specific machine is below the desired framerate then the whole game slows down. I want to be able to do this in a time-independent manner.
There are two ways to do programmatic animation within the Flash player. The first you already pointed out by using a onEnterFrame. However, as you might already have noticed, to get a smooth animation you need to increase the overall frame rate of your movie. Doing this will also increase the CPU load for the entire period of time your SWF runs. This is not something you always want.
The other way of doing programmatic animation is by using a timer. Within a timer handler it is possible to call a function named updateAfterEvent which will update the screen independent from the FPS you'd set for your SWF. Therefore, using a timer leaves a gateway to do smooth animation within the Flash player without increasing the overall frame rate of your SWF.
Two years ago or so I set out to create my own tween libraries for Flash (because of my frustrations with the then existing tween libraries available). I released it under the name Coretween and this library lets you, among other things, choose what type of animation you prefer for every individual tween. On the documentation page I give an example of the difference between frame based and time based animation. The example SWF on that page runs at 12 fps but as you can see, the lower circle tweens much smoother because it's controlled by a timer that ticks at 60 fps and updates the screen in-depended from the SWF frame rate. Do keep in mind though that even the timer ticks at 60 fps in reality the Flash Player will never be able to achieve this frame rate. However, it will try to achieve this frame rate which results in a much smoother overall animation.
Unfortunately until now I've not been able to release a 1.0 version of my library but as far as I know it's pretty stable. You're more than welcome to use it in any way you see fit. I've used Coretween in many commercial productions including this one we did for StGeorge bank here in Australia.
Here are a few Actionscript based animation libraries:
TweenMax
Tweener
They both work well, and should help you with what you need.