don't click here

smps2mid

Discussion in 'Technical Discussion' started by ValleyBell, May 10, 2011.

  1. ValleyBell

    ValleyBell

    Tech Member
    246
    25
    28
    researching PC-98/X68000 sound drivers
    As a preparation for mid2smps, I wrote an smps2mid converter.
    Now with source (Visual Basic 6), too.
    Last Update: v0.4.3

    It supports these ROMs:
    - Sonic 1
    - Sonic 2 (Final and Simon Wai Beta)
    - Sonic 3
    - Sonic & Knuckles (seems quite unstable)
    - Sonic 3D
    - Sonic and Crackers
    - Oerg866's SMPS Player
    - Sonic 1 SMS/GG
    - Sonic 2 SMS/GG
    - Sonic Chaos SMS/GG
    - Sonic Triple Trouble
    - Sonic Blast SMS/GG
    A music pointer offset can be specified, so other ROMs are supported, too.
    It's also possible to load raw SMPS bin-files. Offset correction has to be done via user input.
    There's an auto-detection for 68k or Z80 SMPS format, as well as Sonic 1 SMS.

    Most SMPS tricks (global tempo modifier and co.) are supported. It works almost 100%.
    Tempo calculation should be 100% correct. (Sonic 2 Final, Sonic and Crackers and Sonic 1 SMS were verified with vgm logs.)

    Bugs and issues (all non-Sonic-1):
    - currently only the DAC notes for Sonic 1/2 Bass Drum and Snare Drum are mapped to the correct GM sounds
    - the tool may display run time errors or stop commands and will close afterwards - this should happen rarely to never
    - instruments may be out-of-tune because of strange key displacement values

    On my TODO list:
    - instrument mapping editor (for YM2612, PSG and DAC)
    - making S3&K more stable (many music pointers seem wrong)
    - Pitch Bend instead of Portamento Control
    - Pitch Bend for modulation effects

    Thanks to:
    - all the people who contributed to the Music Hacking Guide
    - nineko for the tempo calcuation algorithm
    - saxman for the Sonic 2 music decompression

    Comments and suggestions are welcome.
     
  2. Tweaker

    Tweaker

    Banned
    12,387
    2
    0
    Fantastic! I've been wanting something like this for a while. :D

    Out of curiosity, do you have any intent to add support for the opposite? A no-frills MIDI2SMPS converter with proper pitch bend support would be a dream come true.
     
  3. Spanner

    Spanner

    The Tool Member
    ValleyBell, have you had a look in the exported MIDIs in OpenMPT? Some of the instruments won't work until a few patterns later. Also, I assume it would be piss easy to get all other percussion to work, since my work usually has a lot more than the kick and snare.

    Good work so far, though.
     
  4. nineko

    nineko

    I am the Holy Cat Tech Member
    6,298
    475
    63
    italy
    When will you stop being so awesome? :O

    This is WAY better than the useless proof of concept I made several months ago... I'd send you my source code but I doubt you would have any use of it :v:

    I can help with midi2smps if you'll want, though.
     
  5. PsychoSk8r

    PsychoSk8r

    PsychedelAnt | Tone Turner Oldbie
    2,641
    57
    28
    Birmingham, UK
    30 Day Project: Revisited.A New Release!
    I would really love to see a MIDI to SMPS program.
    What you've just given us though is great for something I have planned. :D

    Edit: Ah, one thing I notice is that these Midis would be tough to work with, as the notes aren't arranged correctly into bars as they should be, upon inspection. Still a good tool if you want to listen to them though, or use on FL or something. =P
     
  6. nineko

    nineko

    I am the Holy Cat Tech Member
    6,298
    475
    63
    italy
    This happens because the existing Sonic songs don't have a standard number of smps time units per quarter note (GHZ uses 16, most other songs use 12 or 24 to be able to use triplets), making it impossible to match note to beats automatically. Furthermore, we have no indication of the time measure(s) used in those songs. Sonic 1 Special Stage is a 3/4; Sonic 2 CNZ has a small measure as intro; etc. Too many variables which would need manual input to be gotten right.
     
  7. ValleyBell

    ValleyBell

    Tech Member
    246
    25
    28
    researching PC-98/X68000 sound drivers
    Thanks for all the positive feedback.

    No, I haven't even touched OpenMPT. About the instruments: an example would be nice.

    I'd like to read your source. Maybe I'll get some nice ideas.
    I'll PM you about mid2smps when I have questions.

    That's what the small text box with the title "Midi Res:" is for. Type 12 or 24 (or maybe 16 - just as nineko said) in it and the timing should be correct.
    0 is some sort of auto-detection, but that's also affected by the calculated Tempo.
    e.g. a BPM of 500 would cause it to increase the ticks per quarter so that you have 125 BPM which makes more sense than 500.

    btw: I already have ideas for proper a PitchBend in SMPS files.
     
  8. Tanks

    Tanks

    Member
    1,048
    108
    43
    As someone who loves to compile accurate midis from games... This is sex. I figured there was some roundabout way to do SMPS -> XM -> MIDI, but this just rips out the middle men. You, dear sir, deserve a god damn medal.

    EDIT: If it's any help, I can get the BPM for the songs with the tempo issues. Just fixed up the Sonic 2 Race Results song with 60.9 BPM.
     
  9. ValleyBell

    ValleyBell

    Tech Member
    246
    25
    28
    researching PC-98/X68000 sound drivers
    Actually the tempo issue is already fixed.
    I'll post an update in a few days.
     
  10. ValleyBell

    ValleyBell

    Tech Member
    246
    25
    28
    researching PC-98/X68000 sound drivers
    The last few days I worked on smps2mid (not on mid2smps, as you might've expected).

    And these are the new features:
    - correct Tempo calculation for Sonic 2, Sonic 3 and later
    - support for unknown ROMs (by adding a pointers from a custom address)
    - support for extracted Z80 SMPS files with offsets different from zero
    - detection for loop-in-loop with the same index (prevents hanging in Sonic 3D Green Grove 1's DAC channel)
    - Surprise: support for Sonic 1 SMS (thanks to me for reverse-engineering the format :specialed:)

    Thanks to nineko for the icon. (Actually his icon looked like this, with the MIDI below the Sonic head, not the other way.)

    Link is here or in the first post.

    Enjoy!
     
  11. nineko

    nineko

    I am the Holy Cat Tech Member
    6,298
    475
    63
    italy
    I just tried this, and I will love you forever :O

    By the way, the 8-bit Sonic games developed by Aspect (Sonic 2, Sonic Chaos, Sonic Triple Trouble) use a modified version of smps, so I wonder if you would be able to support them as well with a minimal effort. More details from here onwards. Pointers to Sonic 2 songs should be available with the disassembly, and I documented the ones in Sonic Chaos here: SCHG:Sonic_Chaos/sandbox. I can easily do Sonic Triple Trouble as well if you want (maybe I already did but I didn't keep them), I'd be glad to work with you on another project :)

    edit: documented Sonic Triple Trouble for the sake of it: SCHG:Sonic_Triple_Trouble/sandbox.
     
  12. ValleyBell

    ValleyBell

    Tech Member
    246
    25
    28
    researching PC-98/X68000 sound drivers
    I guess it shouldn't be too compilicated to support them too.
    I'll have a look later. (I'll work on mid2smps first.)

    Btw: <a href="http://info.sonicretro.org/SCHG:Sonic_the_Hedgehog_(8-bit)#Music_Hacking" target="_blank" style="background: url(http://info.sonicretro.org/images/5/50/Reticon.png) right no-repeat; padding-right: 20px; border-bottom: 1px dotted #3366BB; color: #3366BB; cursor:pointer; text-decoration:none;" class="wiki">SCHG:Sonic_the_Hedgehog_(8-bit)#Music_Hacking</a>
     
  13. ICEknight

    ICEknight

    Researcher Researcher
    I've noticed that some songs in SMS Sonic seem to play a second time without drums, and the "life lost" tune repeats four times, each with less instruments.

    It sounds kind of cool, but I guess it's a bug. Nice update, in any case!
     
  14. ValleyBell

    ValleyBell

    Tech Member
    246
    25
    28
    researching PC-98/X68000 sound drivers
    It's not a bug that the drums disappear when the second loops begins. It's just that the drum track is shorter/loops earlier than the melody tracks.
    A good example is Green Hill Zone MD: The Noise track stops after a few notes, because the "master loop" is only one note long.

    But the "life lost" tune shouldn't repeat - that's really a bug. (It's the only tune that lacks a loop start command - all other jingles have at least some empty loops.)
     
  15. ICEknight

    ICEknight

    Researcher Researcher
    I see, that makes sense.


    Something I was wondering is that, since MIDIs don't loop, is the general "track loop" info from the original file lost after conversion? Or is it still stored somewhere so converting the MIDI back to SMPS will loop like usual?


    If it's not possible to convert to MIDI, then edit the MIDI, then convert back to SMPS with the looping melody intact, I beg you to add support for other non-MIDI formats like XM. It would make the usefulness of this application multiply by a bunch. Please.
     
  16. Herm the Germ

    Herm the Germ

    Hmm, not bad. Well done, doctor! Member
    1,482
    0
    0
    Dresden, Saxony, Germany
    MIDI-to-SMPS-conversions, mostly. Takin' requests, too.
    I can confirm that Loop points are preserved in a manner that can, in turn, be understood by mid2smps, by placing MIDI Controller 111 set to 0 and 1 at the start and end of loop points, respectively.
     
  17. Hitaxas

    Hitaxas

    Retro 80's themed Twitch streamer ( on hiatus) Member
    Along with ICEknight's request for XM support, I would also love to see a feature that allows ripping of the voices/samples from the midi, for a perfect conversion. I know it sounds lazy, but there are times when finding the perfect voice for a track can be frustrating.
     
  18. Herm the Germ

    Herm the Germ

    Hmm, not bad. Well done, doctor! Member
    1,482
    0
    0
    Dresden, Saxony, Germany
    MIDI-to-SMPS-conversions, mostly. Takin' requests, too.
    Can't Nineko's 2612 Instrument editor tool, found alongside Mid2smps, already rip voices from various sources? The resulting instrument assembly can then be used in conjunction with that tool to include the voices in the new track created, right?
     
  19. saxman

    saxman

    Oldbie Tech Member
    I used your utility: http://forums.sonicretro.org/index.php?showtopic=26025

    Very VERY useful! Thank you for making it!
     
  20. ValleyBell

    ValleyBell

    Tech Member
    246
    25
    28
    researching PC-98/X68000 sound drivers
    Bump for smps2mid v0.3. (And today I release the source, too.)
    Aside from a few bugfixes and a now 100% GM-correct volume calculation, I did these few but big updates:

    - implemented Sonic 3 & Knuckles coordination flags
    - added support for the Master System/Game Gear games (including all revisions) Sonic 2, Sonic Chaos, Sonic Triple Trouble and Sonic Blast
    - improved Modulation controllers (they still ignore the vibrato delay, but at least it sounds good with the MS GS midi driver)
    - improved support for Oerg866's SMPS player - it now works with all SMPS player ROMs and not just the one I used

    Note on the Sonic 2 SMS and later SMPS format:
    They're 3 revisions. Sonic 2 (rev 1), Sonic Chaos (rev 2) and Sonic Triple Trouble/Sonic Blast (rev 3). rev2+ has additional coordination flags (D8 to DF) to set the channel volume. D8 is PSG volume 0, DF is PSG volume 7.
    rev3 (rev2 maybe too) has coord. flag FC, which does the same as flag EB in Sonic & Knuckles.
    rev1/2 and rev3 have a different way of calculating their frequencies, so the notes or the key displacement value in rev3 must be 3 octaves lower than in rev1/2.
    All the SMS drums that sound (they're some that don't do anything) and mapped to quite fitting GM drum sounds. (more hardcoded stuff :argh:)

    smps2mid still fails on some of the Sonic & Knuckles songs. The problem is that I seem to have a wrong music pointer list, so some of the music pointers are wrong.

    Happy converting!