vgmrips / vgmtools

A collection of tools for the VGM file format
GNU General Public License v2.0
118 stars 18 forks source link

How to scale playback speed #21

Closed meyertime closed 2 years ago

meyertime commented 2 years ago

Hi, @ValleyBell. Sorry this isn't really an issue as much as it is a question, and I haven't been able to find another way to contact you. You've been super helpful and responsive! Thanks for all your work!

So the last issue I'm dealing with in my project is that the .vgm files play at about 98% of the speed of the real song in the real game when played using a VGM player ROM in a real Sega Genesis. Interestingly, it plays at the correct speed when I load the same ROM into a Genesis emulator, so it is something peculiar to the actual hardware and probably the VGM player's programming. That's really not an issue with vgmtools, but it may be something that vgmtools can help me work around.

What changes would need to be made to a .vgm file to scale its playback speed by about 2%? I'm aware of the rate setting in the .vgm header, but it goes by video frame rate (60 Hz), so it probably won't give me the precision I'm looking for. I understand that the .vgm format assumes a sampling rate of 44100 Hz for the purpose of timing things. In theory, I could scale the delay values accordingly to produce a tempo change. But I'm not yet familiar with how the DAC is handled and how to scale that playback as well.

Some other observations:

How can I scale the DAC playback? Is there anything else that would need to be scaled? Where would be a good place to integrate this feature into vgmtools? Any tips you could offer would be greatly appreciated. Thanks!

ValleyBell commented 2 years ago

Hi, I'm in the vgmrips IRC channel (irc://irc.digibase.ca/vgmrips) most of the time.

Regarding VGM tempo:

meyertime commented 2 years ago

Thanks, super helpful as always! I got this working and put together a draft pull request.

meyertime commented 2 years ago

So, I really should read all the documentation... On the Sega MegaDrive Vgm Player page, it says:

Suplied custom version with playback rate scaling, by default the playback speed is slightly wrong (less than 1%)

Sure enough, there is a Playback delay scale option. It works the opposite from the -ScaleTempo command that I developed. Less than 1 makes it faster, more than 1 makes it slower, because it's the delay scale, not the tempo scale. But it works for my purposes and does the same thing. Going to close this issue and the pull request. It will be there if anyone needs it for some other reason and wants to pick it up.