Skip to content

Extending VGZ files?

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

Moderator: Staff

  • User avatar
  • Yntec Offline
  • Posts: 5
  • Joined: 2018-10-16, 8:53:45

Extending VGZ files?

Post by Yntec »

There are some songs that I like so much that I'd love if they looped 3 or 4 times, while the rest would remain looping just 2.

This is easy to do in some other music formats like SPC or MiniUSF that allow one to right-click -> View file info, on the Playlist Window of Winamp, in where one can change the length of the song directly. While In_VGM also shows a length box for the songs, one is unable to change it despite the blinking text cursor.

Other music formats like Module Tracker allow length editing by third party software (say, copying and pasting the part one likes to loop an extra time(s).)

I've been messing around trying to change the length of a song with VGMTool and vgm_spts, but I'm only able to make the songs shorter (say, loop once in a loop 2 times environment), not longer.

I'd like to know if there's a way to extend these VGZ music files, or a way to extend VGM music files (by choosing arbitrary length, or specifying some Loop "x times" that overrides default, or some other method.)
  • ctr Offline
  • Posts: 492
  • Joined: 2013-07-17, 23:32:39

Post by ctr »

Use vgm_ptch from the vgmtools.

Usage:
If it's an old VGM file (pre v1.51 for SetLoopMod or 1.60 for SetLoopBase) you will have to update it with the following command

Code: Select all

vgm_ptch -UpdateVer:1.51 myfile.vgm
then you can

Code: Select all

vgm_ptch -SetLoopMod:0x20 myfile.vgm
This multiplies the loop count (notice hexadecimal notation, the actual loop modifier is a 4.4 fixed point value, or the value divided by 16).

OR

Code: Select all

vgm_ptch -SetLoopBase:-100 myfile.vgm
This subtracts a "base value" from the default loop count, so if set to -100 (Notice the negative value), and the default loop count is 2, it will loop 102 times.

SetLoopBase will add or subtract from the player's loop count preference, while SetLoopMod will multiply or divide this value.
  • User avatar
  • ValleyBell Offline
  • Posts: 4768
  • Joined: 2011-12-01, 20:20:07
  • Location: Germany

Post by ValleyBell »

If you don't want to use the hexadecimal notation, you can also use

Code: Select all

-SetLoopMod:*2.0   -> loop twice as often as set in the player's preferences
-SetLoopMod:/2.0   -> loop half as often as set in the player's preferences
  • User avatar
  • Yntec Offline
  • Posts: 5
  • Joined: 2018-10-16, 8:53:45

Post by Yntec »

Hi, finally got to try this out, did this really happen 4 years ago?

So, I'm trying to extend a song that is 1:11 to 1:40 or so, I updated it and tried both methods, it tells me:

Code: Select all

File: BonusRace.vgz ...
SetLoopBase: -100
Info: Header resized - Old: 0x40 bytes, New: 0x80 bytes
File written.
But then when I add it to winamp it still shows 1:11 and it only plays by that much time, as if my "play two loops, fade 5 seconds" setting on VGM input plugin was overriding my changes, any other way to make this file play for longer?
  • User avatar
  • ValleyBell Offline
  • Posts: 4768
  • Joined: 2011-12-01, 20:20:07
  • Location: Germany

Post by ValleyBell »

  • What is the song length and loop length?
  • What version of in_vgm are you using?
    I .... think I may have broken negative loop base values in v0.50.
  • User avatar
  • Yntec Offline
  • Posts: 5
  • Joined: 2018-10-16, 8:53:45

Post by Yntec »

ValleyBell wrote:
  • What is the song length and loop length?
37.30 (7.72 intro and 29.59 loop)

Hey, is there a way to use a Hex editor to modify the song's length directly? I think it'd solve all my problems without having to edit loop data.
ValleyBell wrote:
  • What version of in_vgm are you using?
VGM input plugin v0.50.1 (in_vgmW). The weird thing is that with the plugin I was using previously the song showed 1:11 as its length when added to Winamp's Library, but now this field appears empty (no length shown) though it plays fine. I'd still love if I could modify a song's length directly in the View file info...'s dialog like with Alpha-II's SPC input plugin.
  • User avatar
  • ValleyBell Offline
  • Posts: 4768
  • Joined: 2011-12-01, 20:20:07
  • Location: Germany

Post by ValleyBell »

Okay, I can confirm that in_vgm 0.51.0 is definitely buggy when it comes to the calculation of the reported song length.

It plays fine, but the reported song length when loading the file is wrong.

Example with the 3 files below (13.7 s loop, no intro):
  • drop into the playlist -> reported length is 0:32 for all
  • play the 1st file -> reported length is 0:32
  • then play the 2nd file -> reported length is 0:32, however it plays for 23:19 and the scroll bar indicates that as well
  • then play the 2nd file again -> reported length is 23:19
  • now play the 3rd file -> reported length is 23:19, but it plays for 1:54 only
  • then play the 3rd file again -> reported length is 1:54
What I figured out is:
  • when dropping the file into the playlist, default loop settings are assumed
  • when loading the file, the playlist info assumes loop settings from the last song you played
I'll fix this whenever I get time to touch in_vgm again.

Yntec wrote:Hey, is there a way to use a Hex editor to modify the song's length directly? I think it'd solve all my problems without having to edit loop data.
I'm afraid that this doesn't work due to technical limitations of the VGM format.

In case of NSF/GBS/SPC/xSF files, you just have a tiny ROM that executes sound code with no information about song lengths, loops being available to the player from the "internal" data.
Such information is supplied using additional tags that you can freely define. (SPC/xSF lets you do this for example, but the original NSF and GBS formats do not.)

VGMs work more like WAV/MP3 in that regard: They are recordings of data and the VGM ripper determines song length and loop size by cutting the song at the appropriate places.
Playing the song once means "play all data from beginning to the end". Looping it means "when reaching the end, restart at a certain defined point".
From this you can determine the song and loop lengths very precisely, but you can't freely redefine them.
The players are generally limited to playing the VGM file once + playing the loop N times and will allow you to fade out only at the point where the VGM loops back. You can not play half of a loop, only full loops.
Attachments
Saboten Bombers_12 Unused 3_LoopMod_x4.vgm
Loop Modifier set to *4.0
(33.75 KiB) Downloaded 30 times
Saboten Bombers_12 Unused 3_LoopBase_-100.vgm
Loop Base set to -100
(33.75 KiB) Downloaded 25 times
Saboten Bombers_12 Unused 3_DefaultLoop.vgm
no loop adjustments
(33.75 KiB) Downloaded 26 times
  • User avatar
  • Yntec Offline
  • Posts: 5
  • Joined: 2018-10-16, 8:53:45

Post by Yntec »

ValleyBell wrote:The players are generally limited to playing the VGM file once + playing the loop N times and will allow you to fade out only at the point where the VGM loops back. You can not play half of a loop, only full loops.
Thank you, this was the information I needed. I thought about a feature request that would be very cool to have: Minimum song length, you set it to, say, 2 minutes, then if a song's length is below this, it just plays another loop, this way one doesn't need to extend VGZ files individually, if they're too short they loop more times, and one doesn't need to edit thousands of songs so they play for longer (my NSF files do this for 1:40, but of course if the song is longer it's cut short, VGZ files wouldn't have this problem as longer songs wouldn't be affected as they would already go over Minimum song length.)

Just an idea.
  • User avatar
  • ValleyBell Offline
  • Posts: 4768
  • Joined: 2011-12-01, 20:20:07
  • Location: Germany

Post by ValleyBell »

If you want such a feature, please make a GitHub Issue about it in either the libvgm, VGMPlay or in_vgm repository.
(else I'm very likely to forget about it)
Post Reply