|
ForumsSega Master System / Mark III / Game GearSG-1000 / SC-3000 / SF-7000 / OMV |
Home - Forums - Games - Scans - Maps - Cheats - Credits Music - Videos - Development - Hacks - Translations - Homebrew |
Author | Message |
---|---|
|
Reversing VGM files
Posted: Wed Feb 28, 2018 7:14 pm
|
Hi, is there an easy way, a website, or an app, that can reverse the sound output in a VGM so that it can play backwards? | |
|
Posted: Wed Feb 28, 2018 7:39 pm |
No, it may be quite hard. Probably easier to reverse the WAV. | |
|
Posted: Wed Feb 28, 2018 10:26 pm |
You know, I gave this a quick try, but yeah, it's not as simple as reversing the order of the commands, some stuff rely on the current status of the chip to properly work. I deliberately excluded 1.50 Data Blocks, and I knew from the start that the GG Stereo would have been broken, but yeah, I underestimated the number of things which just can't be swapped around. A task like this is better suited for ValleyBell's black magic.
For the lulz, I attached a very broken Sunset Park 3 Backwards. I recommend you to turn down the volume because it's not nice to listen to. |
|
|
Posted: Wed Feb 28, 2018 11:29 pm |
Ahh, I get you, thought it might be hard. I'm not skilled enough at vgm-mm to make stuff, I'm working on a rom hack and considered using one of the original pieces played backwards as a sort of joke. It's easy enough for me to use good sn76489 music I found, though I intend to put a few other creations in too. When people get musical help on hacks, is it common practice to offer compensation regardless of the work required? I'm certainly going to need help eventually and I certainly wouldn't want to go begging. | |
|
Posted: Thu Mar 01, 2018 12:24 am |
I think it's mostly done pro bono.
For some chips it's almost entirely impossible to play backwards - envelopes and key events are hard to build and place - but for SN76489 in theory you could chunk the file into states with durations, reverse that and then render it back to VGM. It'd almost certainly sound terrible though. Is that the approach you took, Tom? I'm too lazy to try it myself, but the reversed WAV would be a good way to approximate the result before doing the hard work. |
|
|
Posted: Thu Mar 01, 2018 1:06 am Last edited by Tom on Thu Sep 27, 2018 1:37 pm; edited 1 time in total |
No, my attempt was even quicker and dirtier than that, I merely reversed the order of the commands, my laziness prevented me from doing anything better. At first I thought that only the GG Stereo events would be broken, but I later realised all the flaws of such a direct solution. Sometimes my curiosity prevents me from thinking straight before I start coding something, so I extremely underestimated the complexity of such a seemingly trivial task, only opening my eyes while I was falling back to the ground.
Later, I indeed thought about a solution which would detect the "important" commands which define a state (including GG Stereo, why not), and put them in a proper order, but I felt it would have been way too much work for such a novelty, so I didn't pursue it. I can totally see this feature sneaking its way into one of ValleyBell's tools, though, since he can speak the VGM language as well as he can speak English. Or German. I'm sorry, I could have avoided these two posts if only I counted up to ten (thousands) before I started coding while thinking "let's just reverse the order of the commands and see if that works". On a side note, the mere "reverse the order of the commands" approach should totally work in other file formats which don't preserve the state. For example, it wouldn't work with MIDI files, because, like VGM files, they would require a more accurate handling of instruments and controllers (the most obvious one being volume), but it should theoretically work with simple MOD/XM files (but not IT files). Of course, if the MOD/XM file uses advanced commands such as portamento, then it's all lost once again. Still, even in the ideal conditions, one should still think about what to do with the note durations. Think about this example:
I really, really should count up to ten (billions) before I start wondering about things. edit: I noticed a typo, like, 6 months later |
|
|
Posted: Thu Mar 01, 2018 7:47 am |
Yeah, reversing playback isn't straightforward, though it's probably doable with a bit of effort. If you want something comparable but simpler, it would probably be easier to make a "frequency inverter" that can do what this hack does, but for SMS/GG VGM files. It still wouldn't be 100% trivial, since you'd have to simulate playback in order to combine the separate latch/data commands and get the actual output tone on each channel, but I don't think it'd be difficult. You'd probably need some options for setting the inversion point/range, too, because a literal frequency inversion usually results in a lot of ear-splittingly high tones (as I found when I made a few hacks like this a while back).
I'm not promising I'll do anything, mind, but I might try it if no one else wants to. |
|
|
Posted: Thu Mar 01, 2018 10:59 am |
maybe making the original tune set all the 4 channels parameters at every tick would be a good starting data to handle the way Tom explained? | |
|
Posted: Thu Mar 01, 2018 1:13 pm |
The basis for a VGM trimmer or optimiser is to transform it from commands + timing to states + duration. This is kind of like transforming a video file to all keyframes - you can then mess with it (cut, reverse, transform, filter, transpose, time stretch) and then pass it back into the reverse transformation to VGM commands. So it's possibly fairly easy to bolt onto an existing tool or framework. The only issue is that backwards music still sounds weird... | |
|
Posted: Fri Mar 02, 2018 1:27 am Last edited by Tom on Fri Mar 02, 2018 3:11 am; edited 1 time in total |
Why did I spend so much time on this.
I'll test it a bit more and then I'll release it, both the tool and the source code. |
|
|
Posted: Fri Mar 02, 2018 3:01 am Last edited by Tom on Fri Mar 02, 2018 11:54 pm; edited 1 time in total |
UPDATE: version 0.1 deleted from here, see post below for 0.1.2 Please, treat it as a beta, but it should work, given the following constraints:
I'm sorry for the Attachment Fairy, but I'd prefer if the Virtual Machine is not attached to my post for copyright reasons. It's not like that file is going to disappear from the internet anyway; on the contrary, it's all over the place if you Google for it. I do have several backup copies of it in the unlikely event that all the internet goes down at the same time, though. Once you're all set, just drag and drop a file on the VGM_Reverse.exe icon in your Windows Explorer. If nothing goes wrong, you should receive a second VGM file with the _backwards suffix. If something goes wrong, you'll get some kind of error message. I should add more, but for now this will do. UPDATE: the source code is in the post below; it's still confusing as hell, but I commented it today so you might be able to read it. Also, I don't get why the backwards version of Chris's song is a bit shorter, but since it's 4am here in Italy and I still don't know why I spent so much time over this, I'll take another look at a later time. All I know is that VGMTools doesn't seem to find any errors, neither in the original file nor in the backwards one. But I'm too tired to investigate this further now. Good night to me. |
|
|
Posted: Fri Mar 02, 2018 11:51 pm |
I don't feel loved :(
Either way, here is version 0.1.2 complete with commented source code. I don't think I'm going to work on this any further. |
|
|
Posted: Sat Mar 03, 2018 7:23 am |
I love you Tom ❤️
I wish we could get an inline JS player for the VGMs to make it easy to listen. |
|
|
Posted: Sun Mar 04, 2018 3:24 am |
Oh that's wonderful! I love you too ♥ It works just as I had wanted! When I have finished what I am working on I will be sure to send you a copy. The result may give you a chuckle. | |