Jump to content
IGNORED

VGM Compression Tool


Tursi

Recommended Posts

  • 3 years later...

Hey! Resurrecting this old post to note that the work I've been doing on version 2 of this tool is finally running on ColecoVision (well, hopefully, my hardware is packed so I can't test there at the moment!)

 

The goals of v2 were better CPU usage, less RAM usage, and better packing. CPU didn't go down much, unfortunately, but it did save a bit of RAM and pack a bit better on pretty much all songs. But there was a second goal - and that was a more complete toolchain for conversion.

 

I've got a whole thread over in the TI side and I'm going to continue to use that for updates, but as of tonight I've got the ColecoVision SN player, the AY player for SGM and Phoenix, and the Sound Effects player working. New posts start here:

https://atariage.com/forums/topic/225463-vgm-compression-tool/?do=findComment&comment=4493240

 

Unfortunately, I don't know Z80 well enough to do a deep hand-optimization of these like I did for the TI... but I may have to take a stab at it eventually anyway. I think if I do a first pass there should arise people to tell me how wrongly I did it. :lol:

 

I have some samples you can drop in a folder and play with:

- playerSN is a sample playing on the stock ColecoVision SN sound chip. It plays a conversion of the Journey to Silius title from NES (some of it anyway ;) )

- playerAY is a sample playing on the SGM or Phoenix AY sound chip. It plays a conversion of the Master System Afterburner (yes, an SN chiptune. Ironic ;) )

- playerSNAY plays a sample from Wonderboy in Monster Land arcade - originally a dual SN arrangement. It plays here on the AY and SN chips.

- playerSNSFX is just a port of the old demo app from my first version of this tool to show sound effects working

 

And if you just want something to watch, Piano is a quick port of the same demo I released on the TI last week, a conversion of the Protracker MOD GalaxyII using the new MOD conversion toolchain. I love it when a port just works. ;)

 

piano1.thumb.png.27d22cb9b93f492f871a143fa468164d.png

 

The code is all Windows, cause that's what I use, but it's all command line and should compile with minimal pain on Linux, although I didn't go out of my way to create makefiles (most tools are single source file and only the players use any Windows specific code). Source repo is up but it's not done yet - you can just grab the raw tools or docs in the "dist" subfolder.

https://github.com/tursilion/vgmcomp2

 

Anyway, just wanted to let you know that the Coleco side is functional at last... though it could use some optimization!

 

playerSN.zip playerAY.zip playerSNAY.zip playerSNSFX.zip Piano.zip

  • Like 3
Link to comment
Share on other sites

The samples sound fantastic. I manually had to figure out the ay playback recently which i succeed at but I really appreciate a tool set like this which will make that unnecessary in the future as i 'll use this library for sure. 

 

Thanks for converting this. i'm sure many people will use it.

Edited by digress
  • Like 2
Link to comment
Share on other sites

Maybe hand-optimizing is out, but I can /read/ Z80 code, and spent a few hours (more than I should have) tonight on optimizing the C code to get better output. The results are about 20% better, and I've pushed that up. There's still performance to be found, but this should be optimal enough to start using it. :)

 

Link to comment
Share on other sites

On 7/26/2020 at 10:11 PM, Tursi said:

Maybe hand-optimizing is out, but I can /read/ Z80 code, and spent a few hours (more than I should have) tonight on optimizing the C code to get better output. The results are about 20% better, and I've pushed that up. There's still performance to be found, but this should be optimal enough to start using it. :)

 

I think extending the last chapter of my book is in order with this update - very well done.  If you don't mind I will add VGM playback as a 2nd sub-chapter after my coverage of using the OS 7 BIOS routines.  And if I get time I will see if I can optimize the player code and share back here.

Can't wait to play with this some more!

Link to comment
Share on other sites

3 hours ago, Tony Cruise said:

I think extending the last chapter of my book is in order with this update - very well done.  If you don't mind I will add VGM playback as a 2nd sub-chapter after my coverage of using the OS 7 BIOS routines.  And if I get time I will see if I can optimize the player code and share back here.

Can't wait to play with this some more!

Sure, let me know if you have any questions. If it's useful to anyone, that's the point.

 

I was thinking it might be more efficient with a change of the data structure from an array of structs to independent arrays, just from looking at the generated code, but that pass will have to come later.

 

Link to comment
Share on other sites

Really nice work Tursi, but one thing I do not understand is how to make sfx in vgm format ?

I can understand how to convert mod to vgm, but what about sfx ?

 

Another point: I can't see source code of the vgm lib, we need to link with your .a file ?

*EDIT* found it in \Players\libcolecovgm2, sorry to have not checked before 

Edited by alekmaul
Link to comment
Share on other sites

That's cool, there are a lot of files in there...

 

Sound Effects are just really short audio clips, so you can make them with a tracker that outputs VGM, or by hand, or from a perl script of your own devising, or from the other sources the toolchain supports. The goal of the intermediate files being plain ASCII text was to make it easy to create input files for the compressor.

 

There is a separate player dedicated to SFX, for cases when you want music AND SFX this is necessary for two reasons. First, each must maintain their state (unless you pause the music, but I really wanted the music to keep going in the background), and second so the SFX can keep the music off channels it is using. Of course if you are not playing music but ONLY sound effects, then just use the regular player.

 

Link to comment
Share on other sites

Thanks for your reply.

The music driver works fine with my game Sir Ababol, the music renders really different from the mod file I used, but it is normal as the Coleco does not support samples. By the way, the result is great.

Regarding sfx, I will use the regular player but I wanted to know how to handle them with VGM. Now, it's ok, thanks to you ;)

For your information, I compiled the lib with sdcc 3.9 and it works fine.

Thanks again for your great work @Tursi !

  • Like 1
Link to comment
Share on other sites

  • 4 months later...

The same vgm files that work with vgmcomp old version but not with vgmcomp2

 

C:\cygwin64\home\gerry\HEX\HEX_music\VGMComp2>vgmcomp2 -sn Dixie(t1000).vgm moonlight.vgm englgrdn.vgm
VGMComp2 Compression Tool - v20200803

Error parsing line 1
Failed reading channel 0 from 'Dixie(t1000).vgm'

C:\cygwin64\home\gerry\HEX\HEX_music\VGMComp2>sfk174 hexdump -hexsrc Dixie(t1000).vgm.spf +toclip
cannot read file status: Dixie(t1000).vgm.spf
1 warnings occurred.

 

I've tried a few other vgm files. 

 

OLD output::::::::

C:\cygwin64\home\gerry\HEX\HEX_music>vgmcomp Dixie(t1000).vgm moonlight.vgm englgrdn.vgm
v103 - 10/14/2015
Reading Dixie(t1000).vgm - 8815 bytes
Reading moonlight.vgm - 34942 bytes
Reading englgrdn.vgm - 14205 bytes
Final output size: 6716 bytes (89 %)

C:\cygwin64\home\gerry\HEX\HEX_music>sfk174 hexdump -hexsrc Dixie(t1000).vgm.spf +toclip

C:\cygwin64\home\gerry\HEX\HEX_music>pause
Press any key to continue . . .

 

 

edit: i got the 30hz thing working. Now my sfx sound slow so I got to do them too.

 

 

 

 

Dixie(t1000).vgm

Edited by digress
Link to comment
Share on other sites

Right, that's a change in the toolchain... although it's named vgmcomp still, it actually no longer works directly with VGM files. Rather, the compression tool and all the manipulation tools work with text files containing all the note data, which I call PSG files.

 

So to go from a VGM to a compressed file is now multiple steps:

 

First, convert from VGM to PSG data with vgm_psg2psg(*). This will output four separate track files which will have a ".60hz" extension (one for each voice).

Second, optionally manipulate the files if desired to improve the converted music. There are a lot of little tools included, and the format is easy to modify with your own.

Third, pack the four (or fewer) channels you want to compress into a single .PSG file with "prepare4sn" or "prepare4ay" depending on your target chip. If there are preparation errors, you may want to go back to the second step to correct the data.

Finally, you can now use vgmcomp2 to compress the resulting file.

 

I realize this is a bit more work but it's infinitely more flexible. My intent is that this would be scripted for your own workflow (batch files, makefile, etc), so you'd only need to write the steps once, once you knew what a particular song needed. To help with the process, the "testplayer" tool is capable of playing the output from any of those steps, so you can hear how it's doing.

 

The documentation does cover all that, though it's probably better as a reference than a guide: https://github.com/tursilion/vgmcomp2/blob/master/dist/VGMComp2.pdf

 

(* - edit: note that because of this change, SN-only VGMs are no longer the only supported ones. There are also importers for MOD files, SID files, Voice samples, and VGMs can contain AY, Gameboy, Megadrive, NES, Pokey, or SN PSG music - several of these will output more than 4 tracks though, and it's up to you to decide what to do with that ;) ).

 

Edited by Tursi
  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...