S3&K Collection (PC) HQ music hack [upd v1.3]

Discussion in 'Engineering & Reverse Engineering' started by angryzor, Apr 16, 2011.

  1. angryzor

    angryzor

    Member
    27
    0
    0
    S&KC HQ Music
    [UPDATED] Current version: 1.3

    Hello, I'm new here, and though I've been lurking here for a long time, I decided to join after I saw Felik's post in ValleyBell's S&K MIDI tool thread:
    This seemed like a fun quick hack and the only alternative was college work, so I gave it a try.

    Thus, I present to you my Sonic 3 & Knuckles Collection (PC) HQ Audio hack.
    It allows you to replace any of the built-in MIDI music tracks with your own custom file in the MP3/OGG/MP2/MP1/AIFF/XM/MOD/IT/S3M/UMX/MTM or any format supported by vgmstream (see below). Any tracks you don't specify just fall back to the standard MIDI track. It basically just emulates the standard MIDI engine, but plays your HQ files instead.
    It also scales up the tempo of your music during speed mode and special stages.

    Download link: http://www.mediafire.com/?eabcdhbhza6ozan
    Quick video demo: https://github.com/angryzor/bass-vgmstream

    Some technical data for anyone who might be interested:

    A custom MIDIOUT.DLL dll should expose a C function GetMidiInterface that takes no parameters.
    It should return a pointer to a MidiInterfaceClass:

    Code (Text):
    1. class MidiInterfaceClass
    2. {
    3. public:
    4.     virtual bool initialize(HWND hwnd) = 0; // hwnd = game window
    5.     virtual bool load_song(unsigned char id, unsigned int bgmmode) = 0; // id = song to be played + 1 (well, +1 compared to the sound test id, it's the ID of the song in the MIDIOUT.DLL's resources); bgmmode = 0 for FM synth, 1 for General MIDI
    6.     virtual bool play_song() = 0;
    7.     virtual bool stop_song() = 0;
    8.     virtual bool pause_song() = 0;
    9.     virtual bool unpause_song() = 0;
    10.     virtual bool set_song_tempo(unsigned int pct) = 0; // pct = percentage of delay between beats the song should be set to. lower = faster tempo
    11. };
    Just derive from that class and overwrite the virtual methods. The game doesn't notify you when the user closes it, which may cause a problem. I hooked WM_DESTROY to mitigate that.

    Changelog
    v1.3:
    • Added support for FLAC
    • Added fade-outs
    • Added error messages
    • Added config options: "FadeOutDuration" & "ShowErrorMessages"
    v1.2 (not a critical upgrade, just more formats and bloat):
    • Now using vgmstream to play a large number of game music formats: 2dx, aax, acm, adpcm, aix, adp, ads, adx, afc, ahx, aifc, agsc, amts, as4, asd, asf, ast, asr, ass, aud, aus, baka, bh2pcm, bg00, bgw, bmdx, brstm, brstmspm, ccc, cfn, cnk, dcs, de2, dsp, dtk, dvi, dxh, eam, emff, enth, classy gentleman, filp, fsb, gbts, gca, gcm, gcw, genh, gms, gsb, hgc1, hps, hwas, idvi, idsp, ikm, ild, int, lps, isd, ivaud, ivb, joe, kces, kcey, kraw, leg, lwav, logg, matx, mcg, msvp, mwv, mi4, mib, mic, mihb, mpdsp, mus, musc, musx, mss, ndp, npsf, nwa, omu, p2bt, pcm, pnb, pos, psh, psw, raw, rkv, rnd, rrds, rsd, rsf, rstm, rwar, rwav, rws, rwsd, rwx, rxw, sad, sap, sd9, sdt, seg, sfl, sfs, sl3, sli, smp, snd, sng, spd, sps, spsd, spw, ss2, ss3, ss7, stma, str, strm, sts, ssm, svag, svs, swav, swd, tec, thp, tk5, tydsp, um3, vag, vas, vb, vig, vgs, vpk, vs, vsf, waa, wac, wad, wam, wavm, wii, wp2, wsd, wsi, wvs, xa, xa2, xa30, xmu, xsf, xss, xvas, xwav, xwb, ydsp, ymf, zsd & zwdsp
    • Added "IgnorePauseCommands" config option
    v1.1:
    • Using static linking for the VC++ runtime now. This should avoid problems where people do not have the MSVC++ 2010 runtime installed (msvcr100.dll) as it is built into the program.
    • General support for looping tracks
    • Fixed a bug where an event track would loop like normal music
    • Fixed a bug where tracks did not report to the game that they have finished playing and need the music to kick back in
     
  2. nineko

    nineko

    I am the Holy Cat Tech Member
    This... this... just... wow :O
     
  3. LordOfSquad

    LordOfSquad

    tails is still a girl Member
    4,799
    7
    18
    Winnipeg, MB
    making cool music no one gives a shit about
    This is perfect. Now I can use that <a href="http://forums.sonicretro.org/index.php?showtopic=23394&st=0&p=528444" target="_blank">Sonic R3masters</a> thing I did in game. Thanks a lot, man!
     
  4. MarkeyJester

    MarkeyJester

    ♡ ! Resident Jester
    Ahh interesting, so we'll start seeing PC S3K hacks with full quality music? I have no rejections to this, fabulous work! =)

    Also welcome to Retro =P
     
  5. MainMemory

    MainMemory

    Have no fear...Amy Rose is here! Tech Member
    4,374
    43
    28
    SonLVL
    This is very nice, although I'd like to see support for looping music, either by intro and loop files, or a format which supports looping (like ADX).

    I'd also like to see a disassembly or decompilation of the original MIDIOUT.DLL for the SVN, if you have one.
     
  6. angryzor

    angryzor

    Member
    27
    0
    0
    S&KC HQ Music
    <!--quoteo(post=578748:date=Apr 16 2011, 05:14 PM:name=LordOfSquad)--><div class='quotetop'>QUOTE (LordOfSquad @ Apr 16 2011, 05:14 PM) <a href="index.php?act=findpost&pid=578748"><img src="public/style_images/retro/snapback.png"></a></div><div class='quotemain'><!--quotec-->This is perfect. Now I can use that <a href="http://forums.sonicretro.org/index.php?showtopic=23394&st=0&p=528444" target="_blank">Sonic R3masters</a> thing I did in game. Thanks a lot, man!<!--QuoteEnd--></div><!--QuoteEEnd-->
    My pleasure!

    <!--quoteo(post=578763:date=Apr 16 2011, 05:59 PM:name=MarkeyJester)--><div class='quotetop'>QUOTE (MarkeyJester @ Apr 16 2011, 05:59 PM) <a href="index.php?act=findpost&pid=578763"><img src="public/style_images/retro/snapback.png"></a></div><div class='quotemain'><!--quotec-->Ahh interesting, so we'll start seeing PC S3K hacks with full quality music? I have no rejections to this, fabulous work! =)

    Also welcome to Retro =P<!--QuoteEnd--></div><!--QuoteEEnd-->
    Well, I certainly hope so, and thank you!

    <!--quoteo(post=578765:date=Apr 16 2011, 06:10 PM:name=MainMemory)--><div class='quotetop'>QUOTE (MainMemory @ Apr 16 2011, 06:10 PM) <a href="index.php?act=findpost&pid=578765"><img src="public/style_images/retro/snapback.png"></a></div><div class='quotemain'><!--quotec-->This is very nice, although I'd like to see support for looping music, either by intro and loop files, or a format which supports looping (like ADX).

    I'd also like to see a disassembly or decompilation of the original MIDIOUT.DLL for the SVN, if you have one.<!--QuoteEnd--></div><!--QuoteEEnd-->
    Ok, I'll see what I can do to add looped music. I'll start out with the ADX approach, and will add multi-file loops if it doesn't mess up my code too much.
    Looping MODs work already, by the way.

    I have a disassembly. Didn't delve too deep into it as I only needed to know how it interfaces with the main program, but I did identify a fair amount of the functions.
    It's an IDA 5.5 database, I hope that works for you: <a href="http://www.mediafire.com/?4axpk6oy3waytb3" target="_blank">http://www.mediafire.com/?4axpk6oy3waytb3</a>.
     
  7. Naean

    Naean

    Artist, photographer, audio and video editor. Member
    583
    10
    18
    United Kingdom
    2D. Sonic Level Designs
    Is the SnKC HD Audio.rar file download working? I cannot get it to download, even though I can download other files from MediaFire....
     
  8. angryzor

    angryzor

    Member
    27
    0
    0
    S&KC HQ Music
    <!--quoteo(post=578859:date=Apr 17 2011, 12:06 AM:name=Naean)--><div class='quotetop'>QUOTE (Naean @ Apr 17 2011, 12:06 AM) <a href="index.php?act=findpost&pid=578859"><img src="public/style_images/retro/snapback.png"></a></div><div class='quotemain'><!--quotec-->Is the SnKC HD Audio.rar file download working? I cannot get it to download, even though I can download other files from MediaFire....<!--QuoteEnd--></div><!--QuoteEEnd-->
    Works perfectly here... Try <a href="http://node.angryzor.com/~rtytgat/SnKC%20HD%20Audio.rar" target="_blank">http://node.angryzor.com/~rtytgat/SnKC HD Audio.rar</a>
     
  9. Naean

    Naean

    Artist, photographer, audio and video editor. Member
    583
    10
    18
    United Kingdom
    2D. Sonic Level Designs
    <!--quoteo(post=578860:date=Apr 16 2011, 11:07 PM:name=angryzor)--><div class='quotetop'>QUOTE (angryzor @ Apr 16 2011, 11:07 PM) <a href="index.php?act=findpost&pid=578860"><img src="public/style_images/retro/snapback.png"></a></div><div class='quotemain'><!--quotec--><!--quoteo(post=578859:date=Apr 17 2011, 12:06 AM:name=Naean)--><div class='quotetop'>QUOTE (Naean @ Apr 17 2011, 12:06 AM) <a href="index.php?act=findpost&pid=578859"><img src="public/style_images/retro/snapback.png"></a></div><div class='quotemain'><!--quotec-->Is the SnKC HD Audio.rar file download working? I cannot get it to download, even though I can download other files from MediaFire....<!--QuoteEnd--></div><!--QuoteEEnd-->
    Works perfectly here... Try <a href="http://node.angryzor.com/~rtytgat/SnKC%20HD%20Audio.rar" target="_blank">http://node.angryzor.com/~rtytgat/SnKC HD Audio.rar</a>
    <!--QuoteEnd--></div><!--QuoteEEnd-->
    MediaFire download works fine for me now; I don't know why it wasn't working before. Thanks anyway! :)
     
  10. Naean

    Naean

    Artist, photographer, audio and video editor. Member
    583
    10
    18
    United Kingdom
    2D. Sonic Level Designs
    Wow, this is fucking awesome. Brilliant work man, seriously. This is a really kick ass tool.
     
  11. ValleyBell

    ValleyBell

    Tech Member
    237
    10
    18
    researching SMPS sound drivers
    Great work! I just played Hydrocity with the Hydropolis Zone music from Sonicesque II and it works very well.
    I was even able to swap the songs while the game was running.
     
  12. SonicVaan

    SonicVaan

    The probably one and only cybergoth in this commun Member
    387
    0
    16
    Germany, Cologne
    Betatesting, Various hacking projects, programming synthesizers, music production
    Uhh, I don't seem to get it work. I have done the stuff which has been mentioned in the readme. But it doesn't work.
    Anyone mind explaining it to me, please? =P
     
  13. Peruant

    Peruant

    Just dropping in through gaps Member
    <!--quoteo(post=578955:date=Apr 17 2011, 04:54 AM:name=SonicVaan)--><div class='quotetop'>QUOTE (SonicVaan @ Apr 17 2011, 04:54 AM) <a href="index.php?act=findpost&pid=578955"><img src="public/style_images/retro/snapback.png"></a></div><div class='quotemain'><!--quotec-->Uhh, I don't seem to get it work. I have done the stuff which has been mentioned in the readme. But it doesn't work.
    Anyone mind explaining it to me, please? =P<!--QuoteEnd--></div><!--QuoteEEnd-->

    Try renaming the song file to something short. I had to rename mine for it to work.
     
  14. angryzor

    angryzor

    Member
    27
    0
    0
    S&KC HQ Music
    <!--quoteo(post=578955:date=Apr 17 2011, 11:54 AM:name=SonicVaan)--><div class='quotetop'>QUOTE (SonicVaan @ Apr 17 2011, 11:54 AM) <a href="index.php?act=findpost&pid=578955"><img src="public/style_images/retro/snapback.png"></a></div><div class='quotemain'><!--quotec-->Uhh, I don't seem to get it work. I have done the stuff which has been mentioned in the readme. But it doesn't work.
    Anyone mind explaining it to me, please? =P<!--QuoteEnd--></div><!--QuoteEEnd-->
    If Peruant's suggestion doesn't work, please post as much info as you can about how you're using it (screenshot of your game/songs folder, content of the ini, ...)

    <!--quoteo(post=578966:date=Apr 17 2011, 04:00 PM:name=Peruant)--><div class='quotetop'>QUOTE (Peruant @ Apr 17 2011, 04:00 PM) <a href="index.php?act=findpost&pid=578966"><img src="public/style_images/retro/snapback.png"></a></div><div class='quotemain'><!--quotec--><!--quoteo(post=578955:date=Apr 17 2011, 04:54 AM:name=SonicVaan)--><div class='quotetop'>QUOTE (SonicVaan @ Apr 17 2011, 04:54 AM) <a href="index.php?act=findpost&pid=578955"><img src="public/style_images/retro/snapback.png"></a></div><div class='quotemain'><!--quotec-->Uhh, I don't seem to get it work. I have done the stuff which has been mentioned in the readme. But it doesn't work.
    Anyone mind explaining it to me, please? =P<!--QuoteEnd--></div><!--QuoteEEnd-->

    Try renaming the song file to something short. I had to rename mine for it to work.
    <!--QuoteEnd--></div><!--QuoteEEnd-->
    This isn't normal... What name did it have originally?
     
  15. Peruant

    Peruant

    Just dropping in through gaps Member
    Well I'm running into the same problem as Vaan is now. Guess I only got Angel Island Act 1 to work.

    edit: Weird. It's picky with certain songs then it'll work and the filename didn't have to be shorten.
     
  16. angryzor

    angryzor

    Member
    27
    0
    0
    S&KC HQ Music
    You didn't by any chance forget the enter at the end of the last line in the ini file? If not could you please post a link to one of those files that don't work? Thanks
     
  17. Peruant

    Peruant

    Just dropping in through gaps Member
    Nevermind, everything is working as it should be. All it took was removing some square brackets out of the song tracks' names I had.

    For example, here's how my tracklist looks like:
    <!--quoteo--><div class='quotetop'>QUOTE </div><div class='quotemain'><!--quotec-->[Config]
    SongDirectory=songs/

    [Songs]
    0=01 A, B, C, Start!.mp3
    1=02 Haru-iro Komichi ~ Colorful Path.mp3
    2=10 Have A Lovely Interment.mp3
    16=08 Fall of Fall ~ Akimeku Taki.mp3
    21=13 Konjaku Gensoukyou ~ Flower Land.mp3
    26=15 Uchouten Hen ~ Wonderful Heaven.mp3
    45=01 Hisouten.mp3<!--QuoteEnd--></div><!--QuoteEEnd-->

    Still kinda messing with everything.
     
  18. SonicVaan

    SonicVaan

    The probably one and only cybergoth in this commun Member
    387
    0
    16
    Germany, Cologne
    Betatesting, Various hacking projects, programming synthesizers, music production
    One thing I should maybe point out, is that I'm using 320kb/s songs.

    Other than that, here's what I've got in the .ini file:

    <div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:pre;overflow:auto'>[Config]
    SongDirectory=songs\

    [Songs]
    1=angel2.mp3
    2=angel2.mp3

    </div>

    And yes, I did press enter at the end of the last line.

    EDIT: I had to add the 2 DLL files: msvcr100.dll and msvcp100.dll. So if I want to run the game, it gives me the error message that "_invalid_parameter_noinfo_noreturn" wasn't found in the msvcr100.dll file.

    EDIT2: Like SOTI said. Game works, no BGM.
     
  19. Spanner

    Spanner

    The Tool Member
    3,251
    45
    28
    United Kingdom
    Sonic Hacking Contest
    I seem to be getting this error when starting the game.
    <img src="http://i54.tinypic.com/zmimp5.png" border="0" class="linked-image" />
    You can still play the game, but no BGM tracks work at all. Not sure what's up with that.
     
  20. angryzor

    angryzor

    Member
    27
    0
    0
    S&KC HQ Music
    <!--quoteo(post=578987:date=Apr 17 2011, 06:24 PM:name=SonicVaan)--><div class='quotetop'>QUOTE (SonicVaan @ Apr 17 2011, 06:24 PM) <a href="index.php?act=findpost&pid=578987"><img src="public/style_images/retro/snapback.png"></a></div><div class='quotemain'><!--quotec-->One thing I should maybe point out, is that I'm using 320kb/s songs.

    Other than that, here's what I've got in the .ini file:

    <div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:pre;overflow:auto'>[Config]
    SongDirectory=songs\

    [Songs]
    1=angel2.mp3
    2=angel2.mp3

    </div>

    And yes, I did press enter at the end of the last line.<!--QuoteEnd--></div><!--QuoteEEnd-->
    Hmm, I got 320kbps files playing fine... In what way is not working actually? Does it fall back to MIDI? Is it only giving trouble for angel2.mp3 or other files too?


    <!--quoteo(post=578988:date=Apr 17 2011, 06:30 PM:name=SOTI)--><div class='quotetop'>QUOTE (SOTI @ Apr 17 2011, 06:30 PM) <a href="index.php?act=findpost&pid=578988"><img src="public/style_images/retro/snapback.png"></a></div><div class='quotemain'><!--quotec-->I seem to be getting this error when starting the game.
    <img src="http://i54.tinypic.com/zmimp5.png" border="0" class="linked-image" />
    You can still play the game, but no BGM tracks work at all. Not sure what's up with that.<!--QuoteEnd--></div><!--QuoteEEnd-->
    Download the MSVC++ 2010 runtime:
    <a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=a7b7a05e-6de6-4d3a-a423-37bf0912db84" target="_blank">http://www.microsoft.com/downloads/en/deta...23-37bf0912db84</a>
    [EDIT]It contains among other things the MSVCR100.DLL. Don't try to install it manually.