libOPNMIDI
libOPNMIDI copied to clipboard
Make MIDI2VGM with using of raw YM2612 stream of chip
It's would be cool to implement something like MIDI2VGM converter. What to do:
- make a pseudo-chip which will output everything into the VGM file. It can be run in single-chip mode only. (this pseudo-chip will NOT be used out of MIDI2VGM converter, in OPN2-BE and in libOPNMIDI it will NOT be used).
- receive raw registers data or "loop start/loop end" points (to set the looping area) instead of looping the stream.
- when processing audio stream, increase the "delay" command value into output VGM until new register commands will come.
- compile the whole thing as separated command-line binary which will receive MIDI file itself and WOPN bank to use it with generated VGM file.
Because of the perfect automatical channels management model, this thing will allow the making of VGM files much easier and the result will be much better than Nineko's experimental thing which requires every MIDI channel to use single note while OPNMIDI does full automation of channel management.
- [x] Make a pseudo-chip that will dump full input into the file
- [x] Make loop hooks into MIDI Sequencer's code
- [x] Make the writing tool itself
- [ ] Add tags writing support (with using of MIDI meta-data fields)
- [x] Take for use the vgm_cmp tool to optimize generated VGM data for compactness.
- [x] Optionally support ZLib for compressed VGZ writing.
The complete VGM specification is here: https://vgmrips.net/wiki/VGM_Specification
It's the problem with VGM, I doubt you can use as many devices as you want in it. Technically in s98, you could. The libvgm code supports s98 format. Whether that library implement multi-device, it remains to be checked.
Right now it's need ym2612 only which is simplest thing now
I actually mean multi-chip above (as in 4x YM2612), not multi-device
Yeah, therefore a single-chip mode only will be,, and yeah, the channel manager can work on single-chip wisely until polyphony overflow that will cause arpeggio.
Okay, I have made the experimental branch with the working thing: https://github.com/Wohlstand/libOPNMIDI/tree/midi2vgm
There are samples I made with this WIP version: custom_vgms.zip
s98 format
Oh, a thing I have missed up... Does it support full multi-chip to have 4~8 chips? Or it has some limits? VGM, as I see, is able to run two chips maximum.
So, http://www.purose.net/befis/download/kmp/old/s98spec2.txt Yeah, I see S98 really can multichip. :eyes:
Yes, I was trying to tell this. A s98 file has a pair of indexes for devices, with one being to call the lower register bank, and the other for the upper. By usage of this addressing, it covers the full OPL3.
Some chips don't need the upper bank. In libvgm, it says even a chip which uses one only occupy 2 indices; however in OPL-BE, I remember I have considered it took 1...
So, I may have wrong implementation there. Or it's libvgm... Back then, I have based my understanding only on the S98 spec document, and not other's code.
I'm testing this tool right now, everything seems to be fine, but I noticed that created VGMs are a bit louder than midis, both played via PGE MUSplay with MAME YM2612 at volume level 100. That's weird.
Also, in the future, would i be possible to add option to log into YM2608 VGM?
Note that in GME is an unfixed bug at its resampler which damages quality a bit, so, please try to play via ZXTune which gives better sound quality. Yeah, that a good idea to also support OPNA and some other chips.
GME is an unfixed bug at its resampler which damages quality a bit
Oh, I see. Thanks for recommending me ZXTune, now it sounds way better, not terribly loud anymore 😉
@ValleyBell, maybe you know something better about VGM optimization? I have MIDI2VGM code and here is an actual VGM writer: https://github.com/Wohlstand/libOPNMIDI/blob/master/src/chips/vgm_file_dumper.cpp which does the writing of music data in as-is form, in result, there are music files with a mass at least 1 MB size. Your vgm_cmp helps me a lot to compress it into few kilobytes and gzip helps to make the smaller vgz. I think, it's would be better to generate the optimized output rather than requiring to do extra actions to compress it. (the midi2vgm tool itself is in utils/midi2vgm which toggles the libOPNMIDI library into "make me VGM file please" mode and does a write of VGM file).
https://github.com/vgmrips/vgmtools/blob/master/vgm_cmp.c
@papiezak, with recent updates of MixerX and PGE MusPlay I have been fixed quality of VGM playing, now they are playing clearly. However, it's a testing player and ZXTune is a better player for enjoying the music and having playlists on aboard.
Some days ago I did the VGM-Cmp usage and ZLib output support: https://github.com/Wohlstand/libOPNMIDI/commit/81c60705a75728b4c7ce6b570766b430724f318d So, the tool will generate the compact output.