Wohlstand / libADLMIDI

A Software MIDI Synthesizer library with OPL3 (YMF262) emulator
GNU Lesser General Public License v3.0
174 stars 17 forks source link

Add ability to use your own FM banks (.op2, .wopl) #24

Closed freq-mod closed 6 years ago

freq-mod commented 6 years ago

Why not? libOPNmidi has this option, and it would help in testing projects such as DMXOPL.

Wohlstand commented 6 years ago

I thinking to make same as now I have various banks too I would to test without rebuilding entire banks cache and without updating at least four repos where I using libADLMIDI by myself. I will add ability to use custom WOPL banks together with ability to build libADLMIDI without embedded banks to make it be lightweighth (on choice you will be able to use libADLMIDI how with both embedded / custom, also with custom-only like OPNMIDI does). In case of libOPNMIDI it don't use embedded banks: custom only. In case of SDL Mixer X, I converted default bank into C header which was passed to libOPNMIDI as default bank

Wohlstand commented 6 years ago

P.S. I would to pre-include a lite assembly of libADLMIDI to support quick preview of currently opened bank by dropping of any MIDI file

Wohlstand commented 6 years ago

With two commits I have been added support for custom WOPL banks loadable in runtime! https://github.com/Wohlstand/libADLMIDI/commit/8b88c5ce46c508f5b7277774456b2266d459cc88 https://github.com/Wohlstand/libADLMIDI/commit/8b88c5ce46c508f5b7277774456b2266d459cc88 So, to use custom bank you need to use one of two functions instead of adl_setBank():

/*Load WOPL bank file from File System*/
extern int adl_openBankFile(struct ADL_MIDIPlayer *device, char *filePath);

/*Load WOPL bank file from memory data*/
extern int adl_openBankData(struct ADL_MIDIPlayer *device, void *mem, long size);

First will open the bank file by filepath, second will load bank by memory address. That means you are able to convert your WOPL file into C header and use as own default bank instead of ADLMIDI embeddeds like I did here in libOPN2MIDI: https://github.com/WohlSoft/SDL-Mixer-X/tree/master/src/codecs/OPNMIDI or when you are using file mappers or similar things.

One thing I need is provide ability to build libADLMIDI without embedded banks (like libOPNMIDI does).

EDIT: Everything has been implemented!

Please review the result until I'll close this 😉

freq-mod commented 6 years ago

Since I managed to compile libADLMIDI without embedded banks, load custom bank, listen to some midis and not encounter any bugs, I think you can close this ;)

P.S: I hope SDL-MIxer-X's embedded ADLMIDI and, by extension, PGE MUSplay (IMO the best MIDI player I've used) will receive the same treatment :D

Wohlstand commented 6 years ago

PGE MusPlay is not so good player like VLC and primary created for music testing purposes, however, after I'll add seekability, I'll update SDL Mixer X's libADLMIDI too. I will also apply same set of changes to libOPNMIDI I did recently on libADLMIDI (except of custom banks are already was on linOPNMIDI 😄 )