nineko's MIDI to XM to SMPS guide

Discussion in 'Tutorials Archive' started by nineko, Feb 25, 2013.

Thread Status:
Not open for further replies.
  1. nineko

    nineko I am the Holy Cat Member

    Joined:
    Mar 24, 2008
    Messages:
    1,902
    Location:
    italy
    This is a long overdue guide on how to get the best results from your music conversions.


    Please note: what I'm describing here is not the only way to convert songs. This is my way. You're free to either follow these steps or do something else. But if you do something else, or you use other programs, don't post it in this topic, write your own guide. xm4smps users can probably follow the first steps of this guide, while mid2smps users probably won't find anything useful here.


    What you need:

    Table of contents:
    • Chapter 1: make sure that your chosen MIDI file can be imported in Mod Plug Tracker.
    • Chapter 2: prepare the XM file for the conversion or why Mod Plug Tracker is retarded.
    • Chapter 3: xm3smps, I choose you!
    I might add more chapters later, but this is more than enough to get you started.
     
    Last edited by a moderator: Feb 25, 2013
  2. nineko

    nineko I am the Holy Cat Member

    Joined:
    Mar 24, 2008
    Messages:
    1,902
    Location:
    italy
    Chapter 1: make sure that your chosen MIDI file can be imported in Mod Plug Tracker.


    So, you chose to convert the map theme from Super Mario Land 2 to SMPS, so you try to import it in Mod Plug Tracker.


    But you have a bad surprise: it sounds all wrong, the tempo notably jitters.


    What you should do:

    • open the MIDI with my MIDI Event Editor
    • write down (e.g. in notepad) the tempo used by the MIDI, in this case 160 bpm
    • delete ALL the Set Tempo Meta Events from the MIDI file (usually there's only one, but some sequencers like to write lots of them, as seen here)[​IMG]
    • change the Time Division (aka MIDI resolution) to 480 ticks per beat
      right click on the Time Division box
    • enter 480 in the first field
    • ensure "Rescale Events" is checked
    [​IMG][*]save the MIDI file
    Once this is done, you can import the new MIDI file into Mod Plug Tracker.

    This time the things should be much better. Sure the song will be either too slow or too fast (in this case, too slow), but at least the tempo shouldn't be affected by jitters in most cases. This isn't true in two cases: (1) if the original MIDI uses a broken tempo to begin with, such as the popular non-mine rip of Sonic & Knuckles Collection, or (2) if the original MIDI uses triplets. In case 1 there's nothing you can do about it, just forget about the song; in case 2 you can do something else with my Midi Editor, but I'll explain that another time.


    However, yeah, this time the MIDI is imported decently, you can already tell by looking at MPT's "Patterns" tab, and see how the notes are evenly spaced. See how there are 4 (or multiples) rows between notes, this looks good:

    [​IMG]


    Now, to fix the tempo.

    • first of all, delete the TF0 you see in the event column of the first row of the first channel
      note: it might not be on the first channel if there are other events for some reason, just look for TF0 on the other channels
    [*]then, switch to the "General" tab, and enter new values in the Tempo and Speed boxes. Keep this in mind: a MIDI imported in this way will use a Tempo of 2× the MIDI bpm and a Speed of 3. In this case, 2×160 = 320, which isn't possible to use as a Tempo (don't let anyone lie to you, XM tempos can't go above 255, despite some anarchic forks of MPT trying to lead you to believe so), so we have to do some math here. 320 / 3 = 106 / 1, so set the Tempo to 106 and the Speed to 1.[​IMG]

    [*]at this point, use SMPS Tempo to find out if the song will have an equivalent tempo in Sonic 1 SMPS format, or you'll end up wasting time for nothing.[​IMG]

    [*]it turns out that 106 / 1 doesn't have an equivalent tempo in Sonic 1, but 100 / 1 and 112.5 / 1 do. If you find either of those alternatives acceptable, then you can proceed. Otherwise you'll have to do something else with my Midi Event Editor, but like the triplets issue, I'll explain it at a later time.
    After trying 100 / 1 in Mod Plug Tracker, I decide it's acceptable enough, so we can proceed.

    [*]save the file in Mod Plug Tracker without doing any other operation. This will unfortunately save it in IT format instead of XM, but it will also delete all the unused channels (by default, MIDIs are imported as 32-channels modules)
    [*]close and reopen the IT file: see how the channels aren't 32 anymore, but only 11 (in this case)
    [*]change the module type to XM.[​IMG]

    [​IMG]

    [*]save the XM.
    [*]you can delete the IT at this point.
    Now, a few tips.
    • Mod Plug Tracker fails at importing notes if they're longer than 50 module rows, and it will truncate them with a Note Off command ("=="). You should go through the XM file by hand, look for those, and delete them. They're easy to spot if there's another, legit, Note Off command afterwards (say, there's one on row 50 and one on row 64), but they might be tricky to find in other cases.
    • remember how SMPS Tempo gave you a result made up of 4 hexadecimal numbers? In this case it was 0103. The first two numbers are known as "tempo divider", even though it really works in the opposite way, but I don't want to get technical here. Either way, with 01 and 02 there are no problems whatsoever, but from 03 onwards you should take extra care with something: SMPS notes can't be longer than 255 / [that value]. For example, if the result suggested by SMPS Tempo was 0405, then SMPS notes couldn't be longer than 255 / 4 = 63. How to handle this will be covered at a later time, too.
    • Sometimes, even if a MIDI channel is strictly monophonic, it is possible that Mod Plug Tracker decides to spread it on two XM channels if the second Note On event in the MIDI file happens "before" the first Note Off event (by "before" I refer to the internal MIDI event order, even if those events happen on the exact same MIDI tick). You can fix this by changing the internal MIDI event order with my MIDI Editor, but it would be boring and time consuming. You can deal with this when you rearrange the XM channels, which will be done in the next chapter.
     
    Last edited by a moderator: Feb 26, 2013
  3. nineko

    nineko I am the Holy Cat Member

    Joined:
    Mar 24, 2008
    Messages:
    1,902
    Location:
    italy
    Chapter 2: prepare the XM file for the conversion or why Mod Plug Tracker is retarded.


    So, you should be in a situation in which you have this XM file right now. Good, but not acceptable yet.


    Let's get started.

    • first of all, and I can't stress this enough, find the loop point. You'll notice that there are 17 patterns in this XM file, because the MIDI was uselessly long. It turns out that only the first 4 are needed (from 0 to 3). So, click on "4", and press "delete" on your keyboard, until all the patterns from 4 to 16 are deleted. It won't delete to the left, so you can just hold "delete" down with no risk.[​IMG]


      (interestingly enough, in this particular case, the original MIDI files gets wrong after the first loop, so truncating from pattern 4 onwards also fixes the song as a side effect)
    • once that is done, you can (and you should) cleanup the patterns, which will reduce the file size:[​IMG]
    • save the XM afterwards
    • set the start of the loop, which is labeled as "Restart Position" in the "General" tab of Mod Plug Tracker; it's measured in patterns, so we can keep it at 0 in this case, but other values should be used if the song has an intro before the loop starts. Furthermore, if your loop point is in the middle of a pattern, you'll have to split that pattern by hand and set the loop point accordingly.
    • please note that there are two trailing notes at the end of pattern 3 since we truncated from pattern 4 onwards, so we should take care of those. The pattern which will come after pattern 3 is now pattern 0, so that's where we should do our magic. Add a Note Off command ("==") on row 4 of channel 8 and row 4 of channel 11. This will ensure that the song will sound correct after the loop.[​IMG]


      Tip: to add a Note Off just press the Caps Lock key (if you're using the FT2 keyboard settings, which I recommend).
    The XM is now a flawless XM per se, but not suitable for the conversion yet. Now we have to investigate the channels to find out how they're used and how (and if) they can be converted to SMPS.

    Remember, the SMPS engine limits you to 9 channels at the same time: 6 on the YM2612 and 3 on the SN76946; the first one is actually a hardware limit, while the second one is a self-imposed SMPS limit (the SN76946 would be able to handle 4 channels per se, but it can't be done in SMPS, and it's actually a good thing).


    Of the 6 channels which can go on the YM2612, the first 5 are always FM channels; for the sixth one you're given a choice: you can either use it as a sixth FM channel, or you can use it for the drums. Various names have been given to the "drum channel" of the YM2612: you might see it labeled as "DAC channel" or "PCM channel" in other guides, the first name referring to the Digital-to-Analog Converter capabilities of the sound chip being used, and the second name referring to the Pulse Code Modulation format being used by the drum samples themselves; either way, once again, let's not get technical, and let's just call it the "drum channel". You'll probably want to use the drum channel in 95% of your songs, unless you decide to use FM drums, which is a possibility, but I'll leave that for another chapter.


    Of the 3 channels which can go on the SN76946, the first 2 are always used for square waves (with various envelopes, but still, square waves); for the third one you're given a choice: you can either use it as a third square wave channel, or you can use it for the hi-hats. You'll probably want to use the hi-hats channel in 70% of your songs, unless you decide to use FM hi-hats, which is a possibility, but I'll leave that for another chapter. The SN76946 channels are usually called "PSG channels" (e.g. PSG1), and I will refer to them as such.


    This XM uses 11 channels, which means that 2 maybe will need to be removed, unless things can be rearranged in the XM file. Let's find out.


    In the "Patterns" view, right click on the Channel headers, and click on "Solo", one channel per time, and play the song.

    [​IMG]


    It turns out that the channel usage, right now, is:

    • Steel Drums, good candidate for FM
    • Bass, definitely on FM
    • Marimba, probably will go on a PSG channel
    • Strings, something hard to convert, probably will go on a FM channel
    • drums and hi-hats
    • more drums and more hi-hats
    • even more drums and even more hi-hats
    • Steel Drums, this is an echo of Channel 1. Echos usually are amongst the first things you can remove to free channels; but if you keep it, this probably should go on FM too like Channel 1
    • Marimba, this is an echo of Channel 3. Likewise, if this won't be cut, it should share its assignment fate with Channel 3, so probably PSG
    • Steel Drums, this isn't an echo, it's a second lead, so it should be kept, probably still on FM.
    • Steel Drums, this is an echo of Channel 10, you know how it works by now.
    The most obvious thing right now is that drums and hi-hats are all scrambled around on three channels, so you'll have to drag and drop them until all the drums are on a single channel, and all the hi-hats are on another channel. This is a time consuming process but it can hardly be avoided: welcome to Mod Plug Tracker's world of retardness. If two drums play at the same time, you have to choose. Usually snares should take the priority over bass drums (aka kicks), and cymbals (if you have them) should take the priority over snares, but this isn't a written rule and it highly depends on the song, so your taste will matter here. If you don't have cymbals in your PCM definitions, you can map them to the hi-hats channel as open hi-hats, it won't be good, but it will be something.

    However, even after some happy drag and dropping there will be 10 channels, so something will need to be cut anyway. We can't cut the bass, obviously, we can't cut the two main Steel Drums channels, and we won't gain anything useful if we cut the Marimba channels since those are going to PSG, and the problem here is that we're short of one FM channel. We should remove one of the echos, but that would make the song asymmetric, so we'll just remove all of them. Not a big loss, they were only an embellishment in the MIDI file done by the guy who sequenced it. Alternatively, if you really want to keep the echos in, you can remove the drum channel, it's something I did a few times in the past and it gives particular results, but I don't advise you to do so.


    So, it's decided: channels 8, 9, and 11, will be deleted. Likewise, channels 5, 6, and 7, will be sorted and rearranged via drag and dropping into two channels. In this particular case, I suggest you to use channel 5 for the drums and channel 6 for the hi-hats.


    What to put on the drum channel (in general): bass drums, snares, cymbals (*), toms, timpanis, hand claps (*). An asterisks indicates drums which aren't present in the Sonic 1 drumset. If you have more PCM definitions, more things can go here.


    What to put on the hi-hats channel (in general): open hi-hats, closed hi-hats, pedal hi-hats (which are just like closed hi-hats anyway), cymbals (if you don't have a PCM definition for those).


    What shouldn't go neither on the drum channel nor on the hi-hats channel: everything else, whistles, castanets, sometimes bongos and congas can be mapped to timpanis, but they won't sound good. It depends on your PCM definitions, if you have more than regular Sonic 1, good for you.


    So, here's how the drums and hi-hats should look now:

    [​IMG]


    Now, to delete channels, simply go to the "General" tab in Mod Plug Tracker, decrease the channels to 7, and flag 7, 8, 9, and 11.

    [​IMG]

    [​IMG]


    You can save the XM now. Also, since at this point you removed stuff you're not going to include in the conversion, you can as well clean up the XM itself to remove unused instruments and whatnot, to reduce the file size. Mod Plug Tracker can take care of that:

    [​IMG]


    Say yes 3 or 4 times when it wants to remove and/or reorganise samples and instruments. Now you can really save.


    Now, to prepare the XM to use an xm3smps feature: automatic channel assignments. You should know that Mod Plug Tracker hacks the XM format in quite a few ways, for example it allows you to write a comment and to give names to the channels, neither of those features being listed in the XM specifications. Still, channel names are handy, so I implemented support for that in xm3smps even if it's not part of the XM standard. It makes conversions easier.


    So, we have our 7-channels XM file. Let's go through the channels usages once again, but this time let's make definite assignments:

    • Steel Drums (lead 1) -> FM2
    • Bass -> FM1
    • Marimba -> PSG1
    • Strings -> FM4
    • Drums -> Drum channel
    • Hi-Hats -> Hi-Hats channel
    • Steel Drums (lead 2) -> FM3
    We can write the channel names in the "General" tab of Mod Plug Tracker. Please note that xm3smps requires you to label the drum channel as "DAC" and the hi-hats channel as "HATS", I apologise for that.[​IMG]

    [​IMG]


    Some tips which can be useful to know when you decide a channel layout:

    • the important stuff should go to FM1 and FM2, those channels are never muted by sound effects; I usually put the Bass on FM1 and the first/main lead on FM2.
    • FM4 and FM5 are the most muted channels, if anything because the ring sfxs are played here. You can use these for chords or less important parts.
    • FM3 is halfway between them, there are few sound effects which mute it (falling platform in GHZ and SBZ, for example), but it's not muted for the most part. Useful for a second lead, or for the most important note in a chord.
    • If you want to pan FM channels, try to use them symmetrically, e.g. FM1 and FM2, or FM4 and FM5.
    • The most muted PSG channel is PSG1, therefore important things should go to PSG2. You might even want to add an empty PSG channel, which would also fix the trailing PSG bug after the 1-Up jingle. I won't do that in this song since it's only an example.
    Now, I was about to write chapter 3, when I noticed something. It turns out that MPT reads channel 3 in a wrong way, because the guy who sequenced this MIDI used a pitch bend instead of actually transposing the notes. Play channels 1 and 3 in solo mode, and note how they're dissonant in patterns 2 and 3. That's because channel 1 is shifted up by two semitones compared to patterns 0 and 1, but channel 3 is shifted up only by one. Good, this bizzarre choice by the sequencer combined to this bug in Mod Plug Tracker's importer gives me the chance to show you one more feature of Mod Plug Tracker itself. Go to pattern 2, right click on any row of channel 3, click on "Select Column", then right click again, and click on "Transpose +1". Do it again in pattern 3.[​IMG]

    [​IMG]


    Maybe I didn't pick the best song ever for this example, but I didn't plan it beforehand. I just picked a random MIDI from my folder and wrote this guide in real time as I converted it. Note to self: check it all the way through before writing a guide the next time.


    All that said, your XM should now look like this.


    In the next chapter we'll finally get to use xm3smps, so stay tuned :)
     
    Last edited by a moderator: Feb 25, 2013
  4. nineko

    nineko I am the Holy Cat Member

    Joined:
    Mar 24, 2008
    Messages:
    1,902
    Location:
    italy
    Chapter 3: xm3smps, I choose you!


    So, what do we have now? An XM file, with labeled channels. Let's load it.

    [​IMG]


    In the "General Parametres" window, set the tempo to 01 03 (as seen with SMPS Tempo before), and click on "Auto fill", which will set up the channel layout for you (if you labeled the channels in the XM file, obviously).

    [​IMG]

    [​IMG]


    Now, the instruments for the FM channels. We need a Steel Drum, a Bass, and a String. This guide won't tell you where to find the instruments, but I will provide you an x3v file for this specific song.


    Go to the "Voice manager" (another thing I apologise for, I went with the popular "voices" name even though "instruments" is more correct), and load all the instruments from the provided x3v:

    [​IMG]


    The numbers in the brackets will help you remember the XM instrument number they refer to, it will be useful in the next window.


    In the "More parametres" window, in fact, you have to specify which SMPS instrument is mapped to each XM instrument, amongst other things.

    [​IMG]


    Select XM instrument 4, and then select SMPS voice 2. The other ones are already mapped, xm3smps automatically maps XM instrument (n) to SMPS instrument (n-1) by default.


    Also, select XM instrument 3 and PSG voice 3. Informations about the PSG envelopes can be found here.


    Furthermore, select XM instrument 9 and DAC sample 82. Informations about the DAC samples (also known as PCM indexes) can be found here, unless you're using a custom driver.


    This took care of the instrument assignments. Now we have to finetune the volumes and the pitches, which should be done by trial and error. Remember that the volume works logarithmically and backwards (e.g. 0 is ultra loud).


    This is what I suggest:

    • FM1: pitch 0, volume 12
    • FM2: pitch 0, volume 8
    • FM3: pitch 0, volume 8
    • FM4: pitch -12, volume 18
    • PSG1: pitch -36 (this is the default for a PSG channel), volume 0
    • PSG Noise: volume 0
    Also, you should set all the pannings to "centre". The default option, which is "default", will read the 8xx commands from the XM, but you don't need that now. Other options are "left" and "right" which should be self-explanatory. The "remove rests" option is useful if your drum channel is filled with rests (Note Off commands in the XM), which are ignored anyway, so by checking that box you can reduce the size of the converted song. More experienced users might use rests in a clever way to optimise the note/duration streaks, but this definitely isn't a topic for this simple guide.[​IMG]


    At this point, this is the BIN file you should have. But! You can run it through ValleyBell's SMPS Optimiser:

    C:How To SMPS>SMPSOpt.exe s1 sml2map2.bin sml2map3.bin
    (...)
    Total: 551 bytes -> 412 bytes (Ratio: 74.77 %, 3 passes)Which would result into this smaller file.

    Now put that file in your hack.

    Here, have a vgz.
     
    Last edited by a moderator: Feb 25, 2013
  5. DanielHall

    DanielHall Well-Known Member Member

    Joined:
    Jan 18, 2010
    Messages:
    860
    Location:
    North Wales
    Nice guide, but the images are broken.

    Fixed.
     
    Last edited by a moderator: Feb 25, 2013
  6. nineko

    nineko I am the Holy Cat Member

    Joined:
    Mar 24, 2008
    Messages:
    1,902
    Location:
    italy
    The images have never been broken, so I don't get the purpose of your post.


    Nevertheless, thanks.
     
  7. ProfessorRenderer

    ProfessorRenderer Certified Bear Scientist Member

    Joined:
    Sep 28, 2011
    Messages:
    102
    Location:
    Willoughby, Ohio
    Thank you so much nineko!
     
  8. hebereke

    hebereke opa opa! Member

    Joined:
    May 3, 2012
    Messages:
    36
    Thanks for making this guide, the main trouble I had with xm?smps songs was poor/jumpy conversions.

    Also while this may be a bit off topic, but have you ever considered updating the xm3smps program to include a voice editing application (for previewing instruments) like 2612edit or something similar?
     
  9. nineko

    nineko I am the Holy Cat Member

    Joined:
    Mar 24, 2008
    Messages:
    1,902
    Location:
    italy
    Not sure how good it is since I never used it (and I don't plan to use it either), but, I heard that xm3smps/oerg (which is a fork of xm3smps I officially authorised) comes with an instrument editor.
     
  10. ThomasThePencil

    ThomasThePencil resident psycho Member

    Joined:
    Jan 29, 2013
    Messages:
    910
    Location:
    the united states. where else?
    Sorry for being a bit off-topic, but can a song converted this way be used for a Sonic 2 sound driver (within reason, of course)?
     
  11. nineko

    nineko I am the Holy Cat Member

    Joined:
    Mar 24, 2008
    Messages:
    1,902
    Location:
    italy
    The best answer I can give you is the one I already gave you here (which, in turn, links to yet another post, so I think this question is answered enough by now).


    Both xm3smps and xm4smps can only output to the Sonic 1 SMPS format (and I think the same applies to mid2smps), so you'll need to port your converted song in some way, and compress it in Saxman format.
     
    Last edited by a moderator: Feb 27, 2013
  12. ThomasThePencil

    ThomasThePencil resident psycho Member

    Joined:
    Jan 29, 2013
    Messages:
    910
    Location:
    the united states. where else?
    DAMNIT! I completely forgot about that post! :p

    Well, thanks anyway.

    THE GUIDE MAKES NO SENSE.

    ...

    Now that I have your attention, I kinda like the way you made this guide. It's easy to understand, and it isn't terribly long, which is what I prefer in a guide. Thanks for making this guide, nineko. Now I don't need to bother you people about SMPS songs anymore! YAY :D
     
    Last edited by a moderator: Feb 27, 2013
  13. nineko

    nineko I am the Holy Cat Member

    Joined:
    Mar 24, 2008
    Messages:
    1,902
    Location:
    italy
    You weren't a bother, I am always up to help people with SMPS and I will keep on sharing SMPS songs in the future. I just brought to your attention that when you make a request there's no guarantee that it's going to be fulfilled at all.


    That said, I will probably post more chapters in the next days, covering more tricks and more advanced techniques, and they will probably be in separate topics so this guide can remain as the "SMPS for dummies" version.
     
  14. VegaLTE

    VegaLTE Newcomer Trialist

    Joined:
    Feb 11, 2013
    Messages:
    9
    Than How to make Sonic 3 & Knuckles SMPS format?
     
  15. nineko

    nineko I am the Holy Cat Member

    Joined:
    Mar 24, 2008
    Messages:
    1,902
    Location:
    italy
  16. ThomasThePencil

    ThomasThePencil resident psycho Member

    Joined:
    Jan 29, 2013
    Messages:
    910
    Location:
    the united states. where else?
    Okey dokey. Anyway, what exactly will the next chapters cover? You can either explain it generally or explain it in-depth, but either is fine by me.
     
  17. nineko

    nineko I am the Holy Cat Member

    Joined:
    Mar 24, 2008
    Messages:
    1,902
    Location:
    italy
    Well, I didn't really think about that yet. And I don't know when I'm going to write them, either.


    I'll probably cover some tempo-adjusting techniques for those songs that use triplets, and maybe some more details about panning. Maybe FM drums too. Dunno yet, really.
     
  18. ThomasThePencil

    ThomasThePencil resident psycho Member

    Joined:
    Jan 29, 2013
    Messages:
    910
    Location:
    the united states. where else?
    Okay. I can definitely understand that. I guess now I can start converting some stuff to SMPS for my hack. Thanks for the guide.
     
  19. VegaLTE

    VegaLTE Newcomer Trialist

    Joined:
    Feb 11, 2013
    Messages:
    9
  20. ThomasThePencil

    ThomasThePencil resident psycho Member

    Joined:
    Jan 29, 2013
    Messages:
    910
    Location:
    the united states. where else?
    Erm...okay...so what do I do if I don't find the tempo smpsTempo suggests acceptable? I've gotten to that point with Lost Labyrinth Zone Act 1, but I don't like the tempo it suggests; it's slightly too fast.
     
    Last edited by a moderator: May 11, 2013
Thread Status:
Not open for further replies.