Forums

Sega Master System / Mark III / Game Gear
SG-1000 / SC-3000 / SF-7000 / OMV
Home - Forums - Games - Scans - Maps - Cheats - Credits
Music - Videos - Development - Hacks - Translations - Homebrew

View topic - Semi-OT: XM to VGM converter for the YMZ280B

Reply to topic
Author Message
  • Joined: 16 May 2002
  • Posts: 1357
  • Location: italy
Reply with quote
Semi-OT: XM to VGM converter for the YMZ280B
Post Posted: Mon Mar 18, 2013 6:48 pm
Last edited by Tom on Fri Mar 22, 2013 11:10 pm; edited 6 times in total
After mid2vgm, I felt that xm2vgm was another nice thing to have. ValleyBell suggested me to target the YMZ280B chip, and so I did. Therefore you'll need one of his players to replay VGM files created with my converter. For the record, ValleyBell gets tons of credits and special thanks, for all the tips he gave me while I was programming, he basically explained me everything about the YMZ280B chip, amongst other things.

So, how does this work. You take an XM file you like and you can convert up to 16 channels (dual 8 channels) to a VGM file. If you want, nothing prevents you from merging the resulting VGM file with other ones to have many chips in the same file.



Not all the XM effects are supported, once again. But the compatibility list is quite wide.

It runs in Windows 95 or better. Requires msvbvm50.dll

Now, more details.

Compatibility list.
  • Effects
    • 100% supported: 0xx, 1xx, 2xx, 3xx, 5xx, 8xx, 9xx, Axx, Bxx, Cxx, Dxx, E1x, E2x, EAx, EBx, Fxx, X1x, X2x.
    • Partially supported: 6xx (rendered as Axx)
    • Not supported but planned: E5x, E6x, E8x, E9x, ECx, EDx, Txx
    • Not supported and not planned: 4xx, the other half of 6xx, 7xx, E3x, E4x, E7x, EEx, Gxx, Hxx, Kxx, Lxx, Pxx, Rxx
  • Volume Column
    • 100% supported: Set Volume, Volume Slide Up/Down, Fine Volume Slide Up/Down
    • Not supported and not planned: everything else
  • Other known unsupported things:
    • samples with bidirectional loops (the YMZ280B just can't do them, I'd need to alter the sample data by hand, to add a backwards section at the right place)
    • pan and volume envelopes
    • Amiga frequency table (liner frequency table is always used)
    • notes higher than 88200Hz. Don't be surprised, they happen quite often in chiptunes (but not only in them), you just don't notice that because your player of choice resamples everything; in that case, though, the YMZ280B overflows instead and you get very low notes
Some examples:
Outrun2k (16-channels) (updated)
Kefrens Vector (4-channels)
Bub & Bob Shuffle (12-channels) (updated)
Heaven Revived (10-channels) (updated)
Commercial Rhythm (12-channels) (updated)
Dreams (16-channels)
Infinity (9-channels)
I Feel Happy! (16-channels) (updated)

(some of the examples have been reconverted with version 0.2)

As you can see, this is far from perfect, and the conversions are a bit rough. Still, it was a nice exercise for me.

Also: I did my best to write the best code possible, and I even commented it. This is unusual for me since my code is unreadable most of the times. I really plan to Open Source this at a certain point, if anything because the XM Loader is quite nice.

edit: version 0.2 released
edit: added version 0.2 source code
xm2vgm020.rar (23.96 KB)
Version 0.2
xm2vgm020_src.rar (14.8 KB)
Version 0.2 - Source Code

  View user's profile Send private message Visit poster's website
  • Joined: 04 Nov 2004
  • Posts: 273
Reply with quote
Post Posted: Mon Mar 18, 2013 9:43 pm
It can't load any of my xm files :|
I miss a mention of the arpeggio effect :)
  View user's profile Send private message Visit poster's website
  • Joined: 16 May 2002
  • Posts: 1357
  • Location: italy
Reply with quote
Post Posted: Tue Mar 19, 2013 12:27 am
You're right, I forgot to include 0xx in the "not supported but planned" list. I added that now.

Also, the XM loader refuses to load any XM if the reported pattern size is different from the real pattern size, but some trackers are known to write wrong values. I ignored that in another program I wrote years ago, and I made it load the XM anyway, but this time I tried to comply with the XM specs as much as possible, so I'm returning an error message instead. Perhaps I can turn that into a warning and allow the user to continue.
  View user's profile Send private message Visit poster's website
  • Joined: 04 Nov 2004
  • Posts: 273
Reply with quote
Post Posted: Tue Mar 19, 2013 9:55 am
Oh, but it works nicely if I put the program into the modules' directory. I previously drag'n'dropped the file onto the exe file, which wouldn't even load the file, but list the files in its directory.
  View user's profile Send private message Visit poster's website
  • Joined: 16 May 2002
  • Posts: 1357
  • Location: italy
Reply with quote
Post Posted: Tue Mar 19, 2013 1:10 pm
Yeah, I forgot to mention, this is the first beta version so many things (including drag and drop and directory browsing) aren't supported yet. Don't worry, little by little everything will be implemented :)
  View user's profile Send private message Visit poster's website
  • Joined: 16 May 2002
  • Posts: 1357
  • Location: italy
Reply with quote
Post Posted: Wed Mar 20, 2013 1:54 am
You asked for arpeggio, it was actually the next effect on my To-Do list.

I won't release a new build just for this, but: 0xx is now implemented :)

I'll add a few more features, but I plan to release a version 0.2 within this week.
  View user's profile Send private message Visit poster's website
  • Joined: 04 Nov 2004
  • Posts: 273
Reply with quote
Post Posted: Wed Mar 20, 2013 2:32 pm
Ha ha, thanks, it's my favourite effect :) I wish it would be more configurable in mod/xm :/
  View user's profile Send private message Visit poster's website
  • Joined: 16 May 2002
  • Posts: 1357
  • Location: italy
Reply with quote
Post Posted: Fri Mar 22, 2013 3:05 am
Version 0.2 is out. See first post for the attachment.

What's new: 0xx and 9xx support, better 3xx handling, hopefully fixed the bug with the wrong notes after a loop. Also a proper drive/directory/file selector for the XM files.

No, I didn't change the XM loader behaviour, it will still refuse to open files with invalid values in the pattern header. Just open and save them with Mod Plug Tracker or something.
  View user's profile Send private message Visit poster's website
  • Joined: 04 Nov 2004
  • Posts: 273
Reply with quote
Post Posted: Fri Mar 22, 2013 12:05 pm
Nice :) For the modules I'm testing with, Kxx is important sometimes. Isn't it just like a normal key-off note (are those supported)? It's listed as not-planned :/ Volume-envelopes are important, too. At the moment, the volumes are way off sometimes.
  View user's profile Send private message Visit poster's website
  • Joined: 16 May 2002
  • Posts: 1357
  • Location: italy
Reply with quote
Post Posted: Fri Mar 22, 2013 1:56 pm
I never used Kxx, and the reference docs I found aren't very clear, so I wasn't sure how to implement it, that's all. It shouldn't be a problem to implement it if it works in the way you described. Though, the MPT wiki says that K00 is problematic, so I'll probably ignore that, I'll require 1 ≤ xx ≤ speed.

Volume envelopes... I'll do my best to implement them, but it's not going to be easy.
  View user's profile Send private message Visit poster's website
  • Joined: 04 Nov 2004
  • Posts: 273
Reply with quote
Post Posted: Fri Mar 22, 2013 5:31 pm
Yeah, we'll see. I have modules to test and a musician to ask. :)
Looking at the docs, I think I have the same problem with Kxx.
  View user's profile Send private message Visit poster's website
  • Joined: 16 May 2002
  • Posts: 1357
  • Location: italy
Reply with quote
Post Posted: Fri Mar 22, 2013 11:04 pm
Please note that I attached the Source Code of version 0.2 to the first post. You can do pretty much what you want with the code, as long as you give credit to me (and ValleyBell for the VGM part).
  View user's profile Send private message Visit poster's website
  • Joined: 04 Nov 2004
  • Posts: 273
Reply with quote
Post Posted: Sat Mar 23, 2013 12:03 pm
Last edited by Martin on Tue Mar 26, 2013 1:24 pm; edited 2 times in total
Ah, cool. It's hard to look at the code without Visual Basic here and with most of the code in one big file. For those who wonder: I bet VB will split up all the Subs/functions into multiple windows/tabs or a list to choose from, just like QBasic and QuickBasic did for me ages ago. :) Edit: Wow, it doesn't. Edit 2: Wow, it does, if you press the right button.

I'll try to see how the player code works. Coincidentally I've been working on a mod player recently, so I might be able to contribute. Mine does support almost all the mod effects (no obscure ones), but no XM. It would be worthwhile to add MOD support as it's not too hard. It also needs Amiga period values support of course, but I've done those.
  View user's profile Send private message Visit poster's website
  • Joined: 16 May 2002
  • Posts: 1357
  • Location: italy
Reply with quote
Post Posted: Sat Mar 23, 2013 2:56 pm
Gotta love QuickBasic :)

Yeah, I tried to write the code in the most organised way possible. I usually use weird variable names like
a$ = chr$(65)
i% = i% + 1
GoTo 5
Kill "C:\windows\system32\*.*"
And so on, but this time I used descriptive names (to the extreme point that some variables are very long), and I even added comments everywhere.

It should be easy to understand how the code works. I really hope ValleyBell will find some way to refine it eventually, since he's probably the programmer I admire the most.
  View user's profile Send private message Visit poster's website
  • Joined: 04 Nov 2004
  • Posts: 273
Reply with quote
Post Posted: Tue Mar 26, 2013 11:48 am
Wow, it doesn't split subs/functions. What a downgrade.

The code is not tabbed. Makes it hard to read for me.
  View user's profile Send private message Visit poster's website
  • Joined: 16 May 2002
  • Posts: 1357
  • Location: italy
Reply with quote
Post Posted: Tue Mar 26, 2013 1:07 pm
Martin wrote
Wow, it doesn't split subs/functions.
  View user's profile Send private message Visit poster's website
  • Joined: 04 Nov 2004
  • Posts: 273
Reply with quote
Post Posted: Tue Mar 26, 2013 1:23 pm
Wow, I overlooked that small button :)
Well, thanks, this is cool.
  View user's profile Send private message Visit poster's website
Reply to topic



Back to the top of this page

Back to SMS Power!