-
Notifications
You must be signed in to change notification settings - Fork 78
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
Improve audio playback for both wav and midi streams #199
base: master
Are you sure you want to change the base?
Improve audio playback for both wav and midi streams #199
Commits on Oct 21, 2023
-
media: PlatformPlayer: Fix wav and midi incorrect loop count
It appears that most java games (Gameloft ones, like Asphalt 4, Asphalt 6, Ferrari GT 3, Assassin's Creed Revelations and many others for example) set the loop count on both midi and wav streams as 1. This, however, translates to Java 8 looping those samples one time more than needed, so every sfx and bgm playback repeated two times instead of just one. By reducing the requested loop count by one and checking cases where J2ME apps might request loop count 0, pretty much all the aforementioned games have their audio playback fixed.
Configuration menu - View commit details
-
Copy full SHA for 8909567 - Browse repository at this point
Copy the full SHA 8909567View commit details -
media: Manager: Limit the amount of MIDI "channels" for J2ME apps
DOOM II as well as Orcs and Elves II appear to constantly allocate new MIDI samples whenever a different sample from the previously played one is loaded, and never deallocate any of their samples, resulting in memory leaks. While not the best solution to this, we can work around those leaks by imposing a hard limit on how many MIDI "channel slots" a J2ME app can populate. Currently set at 36 slots, it seems to be big enough for anything i tested so far, including Ferrari GT 3 which loads up many different MIDI BGMs alongside wav files (unrestricted, can allocate as many as needed) during a race.
Configuration menu - View commit details
-
Copy full SHA for 49c2ca7 - Browse repository at this point
Copy the full SHA 49c2ca7View commit details -
WavImaAdpcmDecoder: Change some variables from int to byte type
Swapping them to byte variables helps indicate that they should not receive larger values.
Configuration menu - View commit details
-
Copy full SHA for 7e5b227 - Browse repository at this point
Copy the full SHA 7e5b227View commit details -
WavImaAdpcmDecoder: Offload ADPCM decoding to a separate thread
The main thread on FreeJ2ME is already pretty busy with graphics and everything else, we don't need ADPCM decoding clogging things up even further. This should help make decoding faster and reduce stuttering.
Configuration menu - View commit details
-
Copy full SHA for 2509a43 - Browse repository at this point
Copy the full SHA 2509a43View commit details
Commits on Oct 22, 2023
-
Make the max amount of MIDI players a configurable setting
Instead of relying on a fixed value for the max, a user setting for that allows more control and fine tuning for specific apps.
Configuration menu - View commit details
-
Copy full SHA for 1aa4a1d - Browse repository at this point
Copy the full SHA 1aa4a1dView commit details -
Manager: Avoid deallocating streams that are currently running
Previously, the logic behind deallocating streams only took into account if the player index had reached the end of the array, and started deallocating from its first position onwards. This was a problem because it is possible that some of those positions would still be running when FreeJ2ME went to deallocate them. Now it will also take into account whether the current position is running or not, and will only forcefully deallocate a position that's running if the entire array is allocated, and all the players are running, to make space for a new one.
Configuration menu - View commit details
-
Copy full SHA for 0dfcb9a - Browse repository at this point
Copy the full SHA 0dfcb9aView commit details