-
-
Notifications
You must be signed in to change notification settings - Fork 408
Reduce number of simultaneous creature walk sounds. Battlefield #7322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…nly for the duration of one step)
…stopping the sound.
Hi, @Districh-ru ! 2023-06-18.13-16-08.mp4I hope my ears don't lie to me. It seems that the last sound played in a sequence is cut. It is noticeable for walking creatures, especially making 1 single step. Is this behaviour intended? While making two or more steps sounds seem to be played fully (or closer to that). Curious thing is that flying sound of Dragons and Phoenixes is not cut. |
Hi, @Branikolog! Also I forgot to mention that in this PR only walk sounds were changed (as they have step sound and sometimes a sequence of steps). Now the fly sounds use the same logic. Could you please check how now the move sounds are played when you have time. |
Hi, @Districh-ru ! 2023-06-21.13-48-00.mp4Increased fade has fixed clicks for Air elementals. Except of the last sound: I can still hear a click when Elemental stops. 2023-06-21.13-48-20.mp4 |
It works this way:
While walking steps have their maximum volume at the beginning of sound (the sound of step), the flying sound has its maximum around the middle of the sound (before flapping the wing must be raised), so for some big birds on very high battle speeds the sound might be cut just before the sound of wing flap.
And again we are faced with the imperfection of SDL_mixer. :( And at every step, when the amplitude is significantly changed, there might be clicks in sound. This issue needs some time to find a proper solution, so I'm marking this PR as draft. |
I believe, that's because SDL_mixer works this way: when SDL audio driver needs more data, the mixing function is called to produce another audio chunk, and the whole chunk has the same volume (I mean, the specific fading channel has the same volume during the whole chunk). We can try to reduce the |
…e to reduce clicks, Revert sound limit for flying creatures
@oleg-derevenetz, thanks for the suggestion. Yes, SDL_mixer works this way: for each chunk it adjusts the volume: I reduced the Also I reverted the simultaneous sound limit for flying creatures. I'll also check the changed |
On Vita3K it seems to be OK. Vita3K.2023-06-21.21-51-22-185.mp4 |
Hi, @Districh-ru ! I've tested the build and found a few issues. Could you check, please, if you can fix it? I've found that sometimes the last sound is faded too obviously. I've set battle speed as 5 and I can clearly hear fade in some cases. 2023-07-13.15-28-45.mp4There's definitely a fade after the first crusader moves. 2023-07-13.15-27-16.mp4Here the first crusader walking sound looks like been interrupted. The second crusader has walking sound played completely after the troop has stopped. When I set 10 speed some sounds are actually not really pleasant to ear. Like champion or crusader sounds. 2023-07-13.15-29-39.mp4It sounds predictable according to the proposed logic in this PR, but it simply sounds not pleasant. I'm not sure, if it's possible to do something here... Maybe skip several simultaneous sounds or simply play only a single sound, since creature can cover the whole battlefield almost instantly... |
Hi @Branikolog!
On the 2nd video we hear the fully played first sound. the walk sound for all other steps is interrupted. And the 1st crusader ends his movement when the first sound is near its and and we can clearly hear the fade of the second channel sound. The 2nd crusader has one step less movement and the first sound has more volume at this time than the faded sound in second channel. Should we fade all sounds when the unit ends his movement (e.g. cavalry moves for 1 hexagon, but move sound is made for many steps, should we stop the sound when the unit stops)?
Yes, in this case we have many-many sounds, but a little less than in master build as all second channel sounds are faded. |
…play second simultaneous sound.
Issues I noticed:
|
Hi @Districh-ru , could you please explain the status of this pull request and what should be done? Can we implement a part of logic / code which partially fixes the problem but doesn't introduce any issues? |
Hi, @ihhub, |
Currently in master build on high battle speeds when creature is moving the walk sound is played for move to every next cell. It results in many simultaneous move sounds playback.
This PR makes engine to play only "about" one sound at a time. "About" is because on low battle speeds we need to avoid possible sound playback delays in case the sound has ended at the beginning of the next turn and we have to listen silence until the next one.
The algorithm: we know the theoretical time for cell to cell move (from game assets) and we know the move sound duration time. So we can calculate how many cells to wait until the next sound playback.
But on high speeds the real move speed may be less than theoretical due to CPU limit or display 'v-sync' limit. So for this case (if creature movement FPS is more than 50 Hz) we start the next sound after a fact that a previous one has ended. A possible pause after the sound end and the next cell step will be not noticeable as the move speed is very high.