hex007 / freej2me

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

MIDI device configuration? #74

Closed tomrow closed 4 years ago

tomrow commented 4 years ago

On my Windows PC, I have multiple MIDI drivers installed that allow for better sounds. However, FreeJ2ME seems to default to the Microsoft GS Wavetable Synth with no apparent way to change it. Is there a configuration file entry that can be changed to modify which MIDI device is used?

recompileorg commented 4 years ago

No. It doesn't look like something that's easy (or possible?) to do in java: https://docs.oracle.com/javase/7/docs/api/javax/sound/midi/MidiSystem.html

You could try changing the Windows default MIDI sequencer. You need to make a registry change, because no one care about MIDI any more and Microsoft removed the option from the sound control panel. Maybe when MIDI 2.0 comes out, we'll get better options in Windows.

Anyhow, here's a video explaining how to do it. Apparently, the author thinks that written instructions are too easy to follow: https://www.youtube.com/watch?v=RfbbzN9XuPw Why is everything a video these days? Ridiculous.

Nokia64 commented 4 years ago

@tomrow As far as I'm aware, JRE haves both an internal MIDI synthesizer, and a system synth passthrough mode.

On my JRE8, there's this file at sound/sound.properties. It's got some examples:

# Example 2:
# Specify the default Synthesizer by its name "InternalSynth".
# javax.sound.midi.Synthesizer=#InternalSynth

looks like you are able to enable the internal synth there.

EDIT: In JRE8/Windows, there's a file called lib/audio/soundbank.gm in the JRE installation directory. This might be all you need to replace. ~~On installing the soundfont, this is for an very old version of Java, but may still work: https://www.oracle.com/technetwork/java/soundbanks-135798.html~~

AShiningRay commented 1 year ago

Turns out this can be done, or at least it can but in a different way which i consider to be better: Instead of relying on system MIDI drivers, we can change the soundfont used by FreeJ2ME at runtime (requires a restart to apply though, unless you change the soundfont before the app loads any midi streams) by manipulating which soundfont gets loaded by JVM's MIDI synth.

The pull request above proposes a way of doing that by adding a config to set if the user wants to run the default soundfont or a custom one, which can be added to <working_dir>/freej2me_system/customMIDI/. File naming isn't an issue since PlatformPlayer will load the very first soundfont it finds in there that matches the expected .sf2 format... and in cases where the user enables custom soundfont usage but doesn't provide any fonts in there, FreeJ2ME simply uses the default one.

Support for that on libretro cores is also there and it is confirmed to be working on my windows and linux machines as well.