Skip to content

mesen2vgm: some Lua script for Mesen for recording Game Boy VGMs

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

Moderator: Staff

  • User avatar
  • SergioFLS Offline
  • Posts: 4
  • Joined: 2023-11-24, 20:16:56
  • Location: Chile

mesen2vgm: some Lua script for Mesen for recording Game Boy VGMs

Post by SergioFLS »

https://github.com/SergioFLS/mesen2vgm

Mostly did this as an exercise to understand more about the VGM file format. Also that I wasn't able to find an emulator that was accurate enough and logged VGMs (closest was MAME but wave channel is broken?). I mostly wanted one so I could record and listen to demoscene songs where GBS rips are either hard to find or don't exist at all.

So far it seems to work on everything I've threw it to (GBC, PCM audio).

I've also implemented some Game Boy Advance/GBA PSG support, though the wave channel might not play correctly on the current VGM players due to the extra features coming from the GBA (banking and double-width waveforms).

Anyway, hopefully someone enjoys this. :P
  • User avatar
  • Jlooky Offline
  • Posts: 161
  • Joined: 2023-05-18, 1:35:49
  • Location: United States, Maryland / Also visiting inside game consoles/handhelds/computers from time to time.
  • Contact:

Re: mesen2vgm: some Lua script for Mesen for recording Game Boy VGMs

Post by Jlooky »

Nice work man!
Eggs
  • User avatar
  • ValleyBell Offline
  • Posts: 4936
  • Joined: 2011-12-01, 20:20:07
  • Location: Germany

Re: mesen2vgm: some Lua script for Mesen for recording Game Boy VGMs

Post by ValleyBell »

It's great to see other people doing VGM mods/scripts as well!

I had a quick look and your timing code looks very good and should be free of accumulating rounding errors.
I have only one nitpick: You should write the "total sample count" header field (offset 0x18) when finishing the file.

GD3 tags would also be nice, but I don't know how complicated it is in Lua to do the UTF-16 encoding.
  • User avatar
  • SergioFLS Offline
  • Posts: 4
  • Joined: 2023-11-24, 20:16:56
  • Location: Chile

Re: mesen2vgm: some Lua script for Mesen for recording Game Boy VGMs

Post by SergioFLS »

ValleyBell wrote: 2024-08-28, 22:18:17 I have only one nitpick: You should write the "total sample count" header field (offset 0x18) when finishing the file.
I... forgot about that :lol:, should now be fixed in https://github.com/SergioFLS/mesen2vgm/ ... ecdd6face6.
ValleyBell wrote: 2024-08-28, 22:18:17 GD3 tags would also be nice, but I don't know how complicated it is in Lua to do the UTF-16 encoding.
There's no library to handle UTF-16 encoding, though I don't think that's really a problem since the format is simple I could write an encoder myself.
  • User avatar
  • SergioFLS Offline
  • Posts: 4
  • Joined: 2023-11-24, 20:16:56
  • Location: Chile

Re: mesen2vgm: some Lua script for Mesen for recording Game Boy VGMs

Post by SergioFLS »

SergioFLS wrote: 2024-08-30, 18:39:24
ValleyBell wrote: 2024-08-28, 22:18:17 GD3 tags would also be nice, but I don't know how complicated it is in Lua to do the UTF-16 encoding.
There's no library to handle UTF-16 encoding, though I don't think that's really a problem since the format is simple I could write an encoder myself.
Added as of commit b7202c015ebdfecc20c61b49388a862f258fbddb.

Also fixed EOF offset value in header in 04e173931010e4ee707671dc63c2b48e90f64fbd, which makes metadata display properly in vgmplay.

Re: mesen2vgm: some Lua script for Mesen for recording Game Boy VGMs

Post by alexanderjohn »

SergioFLS wrote: 2024-08-27, 4:55:09 https://github.com/SergioFLS/mesen2vgm iq test free

Mostly did this as an exercise to understand more about the VGM file format. Also that I wasn't able to find an emulator that was accurate enough and logged VGMs (closest was MAME but wave channel is broken?). I mostly wanted one so I could record and listen to demoscene songs where GBS rips are either hard to find or don't exist at all.

So far it seems to work on everything I've threw it to (GBC, PCM audio).

I've also implemented some Game Boy Advance/GBA PSG support, though the wave channel might not play correctly on the current VGM players due to the extra features coming from the GBA (banking and double-width waveforms).

Anyway, hopefully someone enjoys this. :P
Great work, SergioFLS! This is a fantastic initiative for capturing Game Boy VGMs accurately. It's always exciting to see projects that enhance our ability to enjoy demoscene music. Looking forward to testing it out!
Post Reply