hex007 / freej2me

A free J2ME emulator with libretro, awt and sdl2 frontends.
Other
469 stars 72 forks source link

Improve audio playback for both wav and midi streams #199

Open AShiningRay opened 8 months ago

AShiningRay commented 8 months ago

Fixes #197 Fixes #198

First off, i think it might result in conflicts if #193 is to be merged at some point, so i'll have to look at it later.

Now to the PR itself... this one contains fixes for audio looping on both MIDI and WAV streams, as well as a workaround to ID Software games' tendency to infinitely allocate new MIDI streams. The latter doesn't have a straightforward fix as far as i can tell, since InputStreams are used heavily throughout the audio players, though i'm open to discussions on how to improve this workaround or even do away with it by implementing a better fix.

As a bonus, this PR also comes packed with a few minor cleanups to the ADPCM decoder, as well as threading support for it, to make it a bit lighter at runtime.

AShiningRay commented 8 months ago

"MIDI Channel" has a specific meaning in MIDI, which is very different from how it's being used here. As for what to call it, that's up for debate. I thought "MIDI Stream" might be okay, though I can think of reasons why that could also be confusing... "MIDI Source" or "MIDI Audio Source"?

Yeah, couldn't think of a good way of naming those either. Only settled for "channels" (with quotation marks) because i thought it would kinda work by imposing a max limit on how many streams would be able to be played at any given time, similar to FM chips with a limited amount set of channels for FM Synthesis.

Still, i also don't like calling those "channels", just couldn't find any better naming scheme for them just yet... "MIDI Players" could also do, but this really feels like something that should come with a tooltip, description or something along those lines to better explain what it's about.