Skip to content
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

PlatformPlayer: Add support for custom MIDI soundfonts #193

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

AShiningRay
Copy link
Contributor

Given this is a bit of an experiment, i don't expect it to be merged, but there's no harm in trying since it would be a nice feature to have.

While it has already been closed, this PR would technically close #74... Had some fun with it this weekend and the prospect of having FreeJ2ME be able to effectively "remaster" midi tracks or simulate some phones like the Nokia Series 30 was very interesting.

Turns out it is possible to alter the soundfont used by a JVM's midi synth, and not only is it easy, but it can also be isolated from system drivers, which means users can just put a .sf2 file on the specified folder, enable the option on libretro or AWT menus, and run with it without having to deal with MIDI shenanigans on linux or windows.

Personal testing showed that while you can load pretty much any soundfont in there, the RAM and processing requirements will vary a lot depending on the used soundfont. On one hand you can make MIDI samples sound like they're coming from a Yamaha Tyros 4 if you really want to, but be ready to use 10+ gigs of RAM just to load some games, but on the other you can use small soundfonts and FreeJ2ME will actually get lighter and some games (Asphalt 4) will load slightly faster.

As an example, running Block Breaker 2 Deluxe with TyrolandGS.sf2 (a soundfont that simulates the Tyros 4 + Roland JV-1010) gets me the following usage stats upon reaching the menu:
FreeJ2ME_TyrolandGS_RAM

Turns out it is rather easy to do, and works like a charm!

However, big soundfonts can easily make FreeJ2ME's RAM usage
go through the roof, so beware! On the other hand, using small
soundfonts (less than 3MB) actually reduces RAM footprint and
can help some games load faster.
Windows side of things needed a few small tweaks to use the jar
path as the starting point instead of retroarch.exe, but besides
that, it all works as intended on both windows and linux.
Turns out WIN32 isn't the only one that needs to have the child
process working directory be changed... it turns out that, on
linux, the working directory was set to the place where the lr jar
was first built in for some reason, which in turn causes issues
with the relative of the custom midi file.
@vadosnaprimer
Copy link
Contributor

Woohoo finally the thing I tried to bring up here #83 (comment) Dunno if my patch was used as a reference but I see our code mostly matches. The part I couldn't get over was setting up the infrastructure to make this properly optional.

Here's the soundfont that sounds the most like my Nokia X2-00
https://musical-artifacts.com/artifacts/828
I wonder if it makes sense to ship FJ2M with it, enabled by default? After all j2me loader is also not relying on system soundfont.

And yeah from my previous testing, audio sounds weird without fps limitation (so maybe it should also become default?)

Thanks and congrats :)

@AShiningRay
Copy link
Contributor Author

Woohoo finally the thing I tried to bring up here #83 (comment) Dunno if my patch was used as a reference but I see our code mostly matches. The part I couldn't get over was setting up the infrastructure to make this properly optional.

Here's the soundfont that sounds the most like my Nokia X2-00 https://musical-artifacts.com/artifacts/828 I wonder if it makes sense to ship FJ2M with it, enabled by default? After all j2me loader is also not relying on system soundfont.

And yeah from my previous testing, audio sounds weird without fps limitation (so maybe it should also become default?)

Thanks and congrats :)

Huh, now that i looked at it, they're pretty similar, but i guess that's because there's only really one way to handle custom soundfonts on MidiSystem and PlatformPlayer's midiPlayer is the only place where it would make sense to add the code into... at least intuitively. Making it a toggle-able config on both standalone and libretro was the bulk of the work, although i'm coming to understand FreeJ2ME as a whole a bit more because of it.

Shipping custom soundfonts by default doesn't seem like a good idea to me (mainly thinking about licensing issues, even though quite a few general sf2 are CC 3.0 Unported), the default soundfont already works so there's no reason to ship anything else with FreeJ2ME as that would add unnecessary complexity and size to it.

As for audio playback being wonky, limiting fps doesn't really help matters over here and only mitigates some of it, which means we have another issue sitting around elsewhere... no idea what it could be though, and FreeJ2ME's audio subsystem is far from perfect for now with almost all audio playback repeating two times for some unknown reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MIDI device configuration?
2 participants