Skip to content

Misc. vgm tools talk

Offtopic from Updated vgm2mid?

Technical discussion about the VGM format, and all the software you need to handle VGM files.

Moderator: Staff

  • User avatar
  • dissident93 Offline
  • Posts: 204
  • Joined: 2012-02-17, 5:54:01
  • Location: USA

Misc. vgm tools talk

Post by dissident93 »

Hey Valleybell, this may be slightly off topic, but would it be possible to create a "Normalizer" type tool? where it runs through the samples and permanently adds gain/auto-normalizes the audio? I know GME for Foobar can do this (compatible with Replay Gain, although it only saves it to the local Media Library, so you can't export the metadata to Winamp), and Winamp's Replay Gain used to work with VGMs, but hasn't in 5+ years.

at times like this, I wish I knew some coding so I could help out.
  • User avatar
  • ValleyBell Offline
  • Posts: 4768
  • Joined: 2011-12-01, 20:20:07
  • Location: Germany

Post by ValleyBell »

There is this type of normalizer-tool: vgm_vol
It doesn't work 100% automatically though.

You use vgm_vol with WAV logs from VGMs, it will print the maximum volume of each track, along with a "Volume Modifier" value and the respective gain. Then you need to use vgm_ptch to apply to "Volume Modifier" to all VGMs of a pack (or only certain ones).
  • VGMfreak Offline
  • Posts: 31
  • Joined: 2013-08-02, 8:43:08

Post by VGMfreak »

Hey ValleyBell, just wondering about the development of MIDI2VGM, any chance that the Sega PCM chip (RF5c164) will be added? Also, when I'm trying to edit ym2612 instruments, I was referring to the VOPM VST plugin. How can I convert those parameters since MIDI2VGM and VOPM have different interfaces? Thanks.
  • User avatar
  • ValleyBell Offline
  • Posts: 4768
  • Joined: 2011-12-01, 20:20:07
  • Location: Germany

Post by ValleyBell »

[Pagebreak quote] VGMfreak wrote:Hey ValleyBell, just wondering about the development of MIDI2VGM, any chance that the Sega PCM chip (RF5c164) will be added? Also, when I'm trying to edit ym2612 instruments, I was referring to the VOPM VST plugin. How can I convert those parameters since MIDI2VGM and VOPM have different interfaces? Thanks.
I worked on a mid2vgm converter for the RF5C68 chip (the Arcade variant of the SegaCD PCM chip) one year ago, but it didn't get further than proof-of-concept state. I made a VGM with 2xYM2612 + RF5C68 though.

If you want to use OPM files with mid2vgm 2612, you need to convert them to the .gyb format. You can do that using 2612edit, which is part of the mid2smps package. (older versions have bugs with OPMs)
  • VGMfreak Offline
  • Posts: 31
  • Joined: 2013-08-02, 8:43:08

Post by VGMfreak »

I tried using custom percussion samples for the DAC, realised the sounds were converted to lower bit depth automatically, but MIDI2VGM seemed to be upset when I tried 1 stereo sample for the 'Dry Snare' and leaving every other sound as default, manually configured the DAC.ini file - it comes up with error messages saying it can't find sounds in the specified folder, starting with the replaced snare sample and the rest of them.
I believe that the DAC sound allocation is coded according to MIDI? Because I was going to manually insert instrument samples to replace the percussion sounds to get 8 bit sound output like the RF5c68. After all, I am after the Sonic CD past tunes' authentic taste.
You're not likely to release a working version of MIDI2VGM(PCM) in future? I heard that there was a MIDI2VGM for 2xYM2612 as well.
Last edited by VGMfreak on 2013-08-02, 12:12:42, edited 1 time in total.
  • User avatar
  • ValleyBell Offline
  • Posts: 4768
  • Joined: 2011-12-01, 20:20:07
  • Location: Germany

Post by ValleyBell »

The YM2612 chip has only 1 DAC channel (although it can be panned to the hard left or right), so it is impossible to use Stereo samples. And the routine that converts 16-bit stereo into 8-bit mono is a bit buggy and so it will fail to load any other file if an exception occours during the conversion (because it doesn't close the file).
DAC.ini assigns samples to GM drum notes, that's right. Unfortunately mid2vgm 2612 always puts all defined samples in the VGM, even unused ones, so the files can get large quickly. (m2v 2612 would need a rewrite anyway, but probably it would already help to port some code from my other mid2vgm tools.)

I probably won't release any mid2vgm PCM tool soon, but I can try to make what I have at least "useable" (even if it won't be user friendly) and release that.

Tom (nineko) modified his older verson of mid2vgm 2612 to output 2xYM2612, IIRC, but he never released it.
But that is no problem, since you can just make 2 VGMs that use the YM2612 and merge these with vgmmerge then to get 2xYM2612. This way you can even get 2 DAC channels.
EDIT: 2xYM2612 incl. 2x DAC test VGM
  • VGMfreak Offline
  • Posts: 31
  • Joined: 2013-08-02, 8:43:08

Post by VGMfreak »

OK, thank you ValleyBell for your replies. I was looking at other FM synth and PSG chips to see if they had emulators made for them yet. I was even going to get the real hardware and make a music player but the chips were long obsolete (especially that RF5C164 - none out there I suppose). Still, I'm glad that I could enjoy MIDIs with Genesis/Megadrive sound.

Three things I had in mind -
1)YM2612 has 2 special channels (CH6-FM/DAC and CH3-FM), CH3 has the ability to output 4 frequencies simultaneously. Does that make it a polyphonic channel or must it play 4 frequencies at the same time?

2)(off-topic) I've read that many people that owned Adlib/Creative sound cards with the FM synth chips claim that they don't sound the same (the sound output has variance), particularly the SoundBlaster 16 I think. What thoughts do you have about this? (I thought this was true for the MD, but I only encountered one so I'm not sure)

3)Can you point me to emulators of other Yamaha FM chips from arcades, Commodore64, Master System? I've googled but I haven't found anything chip-specific and those Winamp plugins (adplug) crash all the time. Have you worked on other chips before?

Well, I'll try edit the DAC.ini to get custom instrument samples in place of percussion samples. A lot of reviews for the MD I've seen said that the 8-bit DAC sounded fuzzy/distorted/clipped, whatever, but I'd think that the 2612 was remarkable for its size vs quality - some sound chips didn't even have integrated DACs for direct audio output. Funny thing is that when I heard voice samples from Virtua Racing, I thought the DAC was 1-bit (coincidentally, I was working on a clock/alarm project with 1-bit sound playback from just a microcontroller). Alright, this is a huge post-I'm sorry but I just like asking questions, anyway thanks again.
Last edited by VGMfreak on 2013-08-02, 15:45:14, edited 1 time in total.
  • User avatar
  • dissident93 Offline
  • Posts: 204
  • Joined: 2012-02-17, 5:54:01
  • Location: USA

Post by dissident93 »

ValleyBell wrote:There is this type of normalizer-tool: vgm_vol
It doesn't work 100% automatically though.

You use vgm_vol with WAV logs from VGMs, it will print the maximum volume of each track, along with a "Volume Modifier" value and the respective gain. Then you need to use vgm_ptch to apply to "Volume Modifier" to all VGMs of a pack (or only certain ones).
so that's how you use it... but is there any reason alot of these packs are still too quite? the NES and some of the arcade stuff in particular.

the Replay Gain support in Winamp couldn't be fixed by you though could it? There was a post on SMSpower showing it could be, but that was from 2007 or something.
  • User avatar
  • ValleyBell Offline
  • Posts: 4768
  • Joined: 2011-12-01, 20:20:07
  • Location: Germany

Post by ValleyBell »

vgm_vol: I think the main problem is the lack of documentation about vgm_vol. The readme of the tool collection is so outdated that it even lacks a section about vgm_vol.

Replay Gain: According to Maxim's in_vgm source, the old Replay Gain feature made use of an SQLite database to store all the gain values and sorry, but I'm not going to add something that large to in_vgm. (The file for the SQLite implementation has about 2 MB, that's about the size of the entire VGMPlay source code including sound emulation.)
Also, Replay Gain won't help at all if the VGMs suffer from clipping.


VGMfreak:
1) The YM2612 has 4 "operators" for each channel, each generates a sine wave. Usually, you set one frequency for a channel and each operator gets that frequency multiplied with a value from 0 to 15. Operators can be turned off and on individually.
You can combine the operators in various ways, e.g. making one operator affect the sound of another one. You can also add them, so that they behave like multiple seperate sine waves played at the same time (and play e.g. the notes 1+5).
The special mode of CH3 just allows you to individually control the frequency of each operator, but the amount of playing notes is not different to other channels.
Technically you can play up to 6*4=24 sine waves at the same time on the YM2612, but the frequencies and sound characteristics will be very limited.

To make it short, CH3 is not more or less polyphonic than every other channel, but you have a bit more control over the used frequencies.
I think some songs that use the PMD driver made a very clever use of the YM2203's CH3 mode to play 2 or 3 notes on CH3.

2) There were many variations of sound cards with OPL2 chips. I heard that some of them didn't use Yamaha's original FM chip, but custom ones that sound more or less similar. Also the output seems to be filtered differently, depending on manufacturer and model.
I like that strong bass sounds of my SB16, but the heights are a bit more filtered than on my YMF744.

3) By "emulators" you mean something like Winamp plugins that do similar things as in_vgm, right?
In this case, I know that there is in_fmpmd and I once had a plugin that plays MDX files, too.
You maybe should have a look at Modland. They have about everything related to module and game music. (FTP links are at the very bottom of the page.)
  • VGMfreak Offline
  • Posts: 31
  • Joined: 2013-08-02, 8:43:08

Post by VGMfreak »

Hi ValleyBell,
Thanks for the clarifications, found a couple of FM synth MIDI players which emulated the OPL2/OPL3, but I was hoping to find something that can export VGM for chips other than YM2612 from an imported MIDI. I understand that the latest released MIDI2VGM only supports 2612 and the fact that the Sega PCM chip had a different design to handling samples compared to the 2612's DAC so there's no way I can get VGMs using both chips for now - however, allocating custom instrument samples to the DAC seems to work fine.

Oh, came across a few conversion problems:
1) I would get a runtime (overflow) error of number 6 or 7, mostly 6 when I try to convert some MIDI files of file size greater than 50KB, managed to get around it by manually trimming notes or splitting polyphonic segments into separate tracks, removing redundant data(eg lyrics), re-export the MIDI removing all non-standard controllers/functions - sometimes it's because of just one track that causes the program to throw this error. Looking at the VGMs' sizes, they seem to max out around 350KB (Are there any other errors I might need to be aware of when working with larger MIDI files?)

2) Converting OPM to GYB worked fine, but for some reason, 2612edit is unable to locate "zlibwapi.dll" for VGZ decompression - some files which were not even compressed (had extension .VGM) caused the error dialog to show up. I have copied the dll(modified 28/03/2013 version 1.0.0.0) file into the same directory as 2612edit, run as admin, but no success (of course, I can use VGMToolbox to decompress VGZ --> VGM and those work fine,)

3) Is it possible to change the "Chips Used" in the exported VGM to a different chip? Tried to merge 2 VGMs generated by the same MIDI - the merged VGM was created but crashed Winamp when it was loaded, the MIDI had 13 tracks - 1 percussion, 12 instrument, all tracks have only one note playing at any time, redundant info/non-standard functions removed, 1st exported VGM had tracks 1-5+DAC(10), 2nd had tracks 6-9,11-12. I was hoping to generate one VGM that would have about 15 channels in total so I thought maybe there might be some chip supported by in_vgm that could do that.

Oh, by the way, really off-topic but have you heard of the unused music with duration of about 3.5 minutes from "Sonic Mega Collection" (Gamecube)? The file was called "music24a.adx" on the game disc, was remixing this music 2612 style, do you have any idea if there is a higher quality version of it elsewhere (rumours had it that there was a 48kHz version compared to the disc's original 24kHz). I haven't played the game before, in fact I haven't played much games from the 21st century, but when I discovered it for myself and listened, nostalgia instantly hit me.
I seriously have a lot of problems on hand and I appreciate your fast responses. Are you likely to release your MIDI2VGM(PCM) WIP in the next fortnight or so? If not, I'll continue with the DAC routine. As always, many thanks.
Last edited by VGMfreak on 2013-08-04, 14:35:16, edited 2 times in total.
  • User avatar
  • ValleyBell Offline
  • Posts: 4768
  • Joined: 2011-12-01, 20:20:07
  • Location: Germany

Post by ValleyBell »

0) Please use the name "SegaCD PCM" for the RF5C164 chip. There is sound chip called "Sega PCM" that's used in Arcade games like Out Run and those two are completely different.

1) You shouldn't get runtime errors, actually. Please send me the MIDI (or upload it somewhere and post the link).

2) Copying the DLL into the same directly as 2612edit.exe should be enough to make it find the DLL, so that's really weird. My zlibwapi.dll is from 2010, but both ones should work.
I'd still like to have a .zip with your version of 2612edit.exe + zlibwapi.dll.

3) Winamp isn't supposed to crash at all. As above, I'd like to have a look at the merged VGM (and maybe the two source VGMs, too).

SMC's music24a.adx: I know the song, but I don't know if there's a high quality version. I rarely use ADX files anyway and have very few of them.

mid2vgm RF won't be released within the next week. But after the Sonic Hacking Contest is over, I should have time to work on it.
  • VGMfreak Offline
  • Posts: 31
  • Joined: 2013-08-02, 8:43:08

Post by VGMfreak »

0) My mistake, missed out the "CD" part because I was looking at the "Sega PCM"'s datasheet and I couldn't find any for "SegaCD PCM", thought one was a slightly modified version of another but apparently no.

1) I've kept the "faulty" MIDIs separate from the ones that were successfully converted, but for some of the "faulty" MIDIs, the error doesn't show up after restarting my computer, the really problematic ones had polyphony of more than 5 for a few tracks, was in midi format 2, or had duration longer than 5 minutes. I'll try to recreate the errors for the MIDIs and send them to you within this week. (They were all overflow errors, is it something to do with file size limits, or some bug in MID2VGM?)

2) My 2612edit.exe is 2013 version I think, I get this to you as soon as possible in the week. (Just those 2 files?)

3) Yeah, it crashed my audio driver as well, I'll try to convert it again but yep, within this week also.

OK, that's alright (about mid2vgm RF). So there is no way where you could change the chips used in the vgm file and expect it to work, correct? Oh well, better wait until in_vgm can support 3xYM2612s... :-)
  • User avatar
  • ValleyBell Offline
  • Posts: 4768
  • Joined: 2011-12-01, 20:20:07
  • Location: Germany

Post by ValleyBell »

1) Everything input and output related works in a way that shouldn't throw overflow errors, so these are definitely bugs in mid2vgm.

2) Just those 2 files should be enough.

3) Changing the used chips of a VGM file is difficult, since each chips works differently. Chips of the same family (i.e. OPN family with YM2203, YM2608/10/12) often use similar sets of commands, so changing the chips is possible within some limits. (and changing about every 4th byte in the file)

Anyway, in_vgm isn't supposed to crash. Never. (Though I think I know 2 cases where it does it in the current release, but these shouldn't occour with YM2612 VGMs.)

Also, no, there won't be any support for 3x chip. I already sort of hacked the format to make 2x possible, because it wasn't made with multi-chip support in mind.
  • VGMfreak Offline
  • Posts: 31
  • Joined: 2013-08-02, 8:43:08

Post by VGMfreak »

Would you mind giving your email address for me to send you the stuff? (I just want to make sure the stuff does make it to you).
Unfortunately, some of the MIDIs were made by a friend and I haven't got permission to upload them. They were the ones that had polyphony of about 5 every track and were midi format 2, had total tracks ranging from 12 to 15, duration 4-5 minutes. Also if it helps, they were sequenced by a Korg i4S and transferred to computer - it used special non-standard controllers which their data made up half the file size (about 40KB), I think one was for pitch bends exceeding the GM MIDI spec., had multiple tempo changes as well.

Notable MIDI controllers used include - reverb(91), chorus(93), non-registered parameter number_fine(98)/coarse(99), registered parameter number_fine(100/coarse(101), all controllers off(121) and poly operation(127). One particular file had initial file size of 101KB, all text removed 90KB, all non-standard controllers removed 25KB, no joke, sometimes large MIDIs are not what they seem to be.

UPDATE: the 25KB version of the song worked in conversion, lots of pitch bend was used so it sounded...yeah you can imagine it

Well, most of the MIDIs I've converted have only about 12 tracks in total so maybe 3x chip is not really needed. What is the latest version of in_vgm? (I have v0.40.2), Adplug doesn't like winamp 5.5 so I'm counting on in_vgm.
Last edited by VGMfreak on 2013-08-05, 14:14:09, edited 1 time in total.
  • VGMfreak Offline
  • Posts: 31
  • Joined: 2013-08-02, 8:43:08

Post by VGMfreak »

I found one of the "faulty" MIDIs, called "bo3o", had duration of around 5 1/2 minutes, discovered something when trying to play the faulty merged file. The 2 source VGMs both have the same DAC percussion channel, but different musical notation, should have used up all available channels. When I try to play "bo3o_merged.vgm", it starts playing, shows bitrate of 13kbps, 3 seconds, still silence, suddenly it crash - winamp stopped working because of in_vgm.

My next approach - load any working VGM (merged or not) and play for a second, then load the offending "bo3o_merged.vgm", and we have playback. Strange things... Must it have something to do with the multi-chip aspect of the plugin?

As with the unsuccessful conversions - in "sonicA1.mid", only track 1 (pick bass) was preventing the conversion process from continuing, all other channels were alright. It turned out that it was the only track to have special controllers functioning - they were registered parameter number (100 - fine AND 101 - coarse). Once I removed those controllers, the conversion process worked.
I've seen at smspower.org that you have written a mid2vgm program for OPL but it had problems with those controllers as well. I was trying to download the updated version (mid2vgm_2012.rar) but link's dead (page not found).

EDIT: Stuff has been sent to you.
Last edited by VGMfreak on 2013-08-06, 14:31:26, edited 3 times in total.
Post Reply