don't click here

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
    1
    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
    6,268
    469
    63
    italy
    This... this... just... wow :O
     
  3. LordOfSquad

    LordOfSquad

    bobs over baghdad Member
    5,139
    196
    43
    Winnipeg, MB
    making cool music no one gives a shit about
    This is perfect. Now I can use that Sonic R3masters thing I did in game. Thanks a lot, man!
     
  4. MarkeyJester

    MarkeyJester

    Nothing's Impossible Resident Jester
    2,170
    360
    63
    Japan
    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

    Kate the Wolf Tech Member
    4,697
    295
    63
    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
    1
    S&KC HQ Music
    My pleasure!

    Well, I certainly hope so, and thank you!

    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: http://www.mediafire.com/?4axpk6oy3waytb3.
     
  7. Naean

    Naean

    Naean H.F. (Nez Man) Member
    808
    186
    43
    United Kingdom
    2D. Sonic Fan Game
    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
    1
    S&KC HQ Music
    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

    Naean H.F. (Nez Man) Member
    808
    186
    43
    United Kingdom
    2D. Sonic Fan Game
    MediaFire download works fine for me now; I don't know why it wasn't working before. Thanks anyway! :)
     
  10. Naean

    Naean

    Naean H.F. (Nez Man) Member
    808
    186
    43
    United Kingdom
    2D. Sonic Fan Game
    Wow, this is fucking awesome. Brilliant work man, seriously. This is a really kick ass tool.
     
  11. ValleyBell

    ValleyBell

    Tech Member
    246
    25
    28
    researching PC-98/X68000 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. neonsynth

    neonsynth

    Previously 'SonicVaan' Member
    394
    9
    18
    Germany, Stammbach
    gaming and 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
    Try renaming the song file to something short. I had to rename mine for it to work.
     
  14. angryzor

    angryzor

    Member
    27
    0
    1
    S&KC HQ Music
    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, ...)

    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
    1
    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:
    Still kinda messing with everything.
     
  18. neonsynth

    neonsynth

    Previously 'SonicVaan' Member
    394
    9
    18
    Germany, Stammbach
    gaming and 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,361
    179
    43
    United Kingdom
    Sonic Hacking Contest
    I seem to be getting this error when starting the game.
    [​IMG]
    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
    1
    S&KC HQ Music
    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?


    Download the MSVC++ 2010 runtime:
    http://www.microsoft.com/downloads/en/deta...23-37bf0912db84
    [EDIT]It contains among other things the MSVCR100.DLL. Don't try to install it manually.