How to Import Custom DAC samples within S2's Clone Driver

Discussion in 'Engineering & Reverse Engineering' started by Irixion, Jan 16, 2010.

Thread Status:
Not open for further replies.
  1. How to Import Custom DAC samples within S2's Clone Driver

    Made by Irixion/ErexFox

    Note: Do not reproduce without permission of creator, or I will hunt you down, and cut your penis off.

    On with the show!

    ======Table Of Contents======

    1. Credits
    2. Special Thanks
    3. Foreplay
    4. Cream Filling
    5. The Aftermath
    6. Troubleshooting


    Tweaker - For pretty much all of this information :P, and saying that compression
    isn't needed, which prompted me to try this.
    Hayate - For also making me realize that compression isn't needed for this driver.

    Eduardo Knuckles - For helping me fix the clicking annoyance!

    Puto - For listing the samples' Pitch/Sample rate..table..thing.

    Irixion/ErexFox - For writing this lovely guide!

    ======Special Thanks:======

    Flygon, and Kradorex for chilling with me while writing this. (Also for hugs :))
    Boredman for bugging me to figure this out. Someone validate him. (If you want <_<)
    S3K for having motherfucking sexy drums.


    So, now you have the Clone Driver. Now you want custom DAC? Oh shit, what am I going to do?
    Have no fear, for ErexFox is here! No seriously, this is some easy shit. Read on!

    ======Cream Filling:======

    Get this:
    Code (Text):
    1. File type:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Wav
    2. Bit Rate:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;88kbps
    3. Audio sample size:&nbsp;&nbsp; 8 bit
    4. Channels:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1 (mono)
    5. Audio sample rate:&nbsp;&nbsp; 11 kHz
    6. Audio format:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PCM
    MAKE SURE IT'S HEADER-LESS How do you check? If you media player can play it, it has a header.
    You can record a sample, and convert it using applications.
    If you have any recommended ones, please list them:

    Put this wav sample in your desired location. (So, "sounds\DAC\" is an example)

    Open up the sample's property box and go to 'PCM_table:' in your Clone Driver ASM.
    You may open windows calculator if you feel that it is necessary.

    Here is an example of the PCM table, and a description of what every line here does.

    Code (Text):
    1. PCM_Table Example/Format:
    3. &nbsp;&nbsp;&nbsp;&nbsp;dc.l&nbsp;&nbsp; $A00200, DAC1&nbsp;&nbsp;Add $8 every time a new sample is added
    4. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;This is essentially the z80 RAM Address
    5. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;that the sample will be kept at.
    6. &nbsp;&nbsp;&nbsp;&nbsp;
    7. &nbsp;&nbsp;&nbsp;&nbsp;dc.w&nbsp;&nbsp; $269&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Size of DAC sample in words.
    8. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Take 'size' from file properties,
    9. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Not 'size on disk') of sample and devide by $2
    11. &nbsp;&nbsp;&nbsp;&nbsp;dc.b&nbsp;&nbsp; $19,0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;This is the pitch at which the sample is played.
    12. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;It's reversed, so the higher value, lower pitch

    So, first line is the RAM address. Just add $8 (Notice that it's hex value, not decimal) to it to get the address for the next sample. Only do so if you're creating a new line in the PCM_Table, to add a new DAC sample.

    The second line is the size of the DAC sample in words. Open up the properties box, and take its 'size', (NOT its 'size on disk') and divide that number by the hex value of $2.

    An easy way to do this is: (If you're good at hex and decimal math, skip this bit.)

    <a href="" target="_blank">Get this utility</a>, open your DAC file, and hit copy. then paste as the size in your ASM file.

    The last line is the pitch. It's reversed, so the higher the value, the lower the pitch is, and vice-versa.

    Once you're done in PCM table, go down to the DAC binclude area.

    Code (Text):
    1. DAC1: binclude sounds\dac1d.bin
    2. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;even
    Now, change it to binclude your file. In our example, it will be:

    Code (Text):
    1. DAC1: binclude sounds\DAC\Kick.wav
    2. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;even
    =====The Aftermath:===

    Build and test! Enjoy your custom samples! Now don't you feel like a whore.


    I'm getting a click at the end of my sample! WHAT IS THIS?!

    A few things could be wrong. Your sample most likely has a header. Open it up in a hex editor. Get rid of a bit at the beginning.

    Code (Text):
    1. RIFF....WAVEfmt

    I'm still getting a click at the end of my sample! It has no header!

    Then your converter left some garbage at the end of the file. Open it up in a hex editor, and delete all text at the end.

    Code (Text):
    1. LISTJ...INFOISFT>...File created by GoldWave.&nbsp;&nbsp;GoldWave copyright (C) Chris Craig.

    I'm still getting a click at the end of my sample! You're not helping!

    If you followed the other two steps and still are getting a click, remove any 00 that you may have at the end of your file.

    Example: Remove the bolded text.
    Code (Text):
    1. 77FF 77FF FF[b]00 0000[/b]

    I don't know what I should set the pitch to! Halp?

    Play around with it, start at about $6. But like I said, experiment, until you get it sounding the way you want it to.

    <!--quoteo(post=396803:date=Jan 16 2010, 01:24 PM:name=Puto)--><div class='quotetop'>QUOTE (Puto @ Jan 16 2010, 01:24 PM) <a href="index.php?act=findpost&pid=396803">[​IMG]</a></div><div class='quotemain'><!--quotec-->Might as well mention some values here:

    Pitch $9 is 16KHz.
    Pitch $5 is ~22KHz.
    Pitch $13 is 11KHz, I think.<!--QuoteEnd--></div><!--QuoteEEnd-->

    Hopefully that should be of some help!

    Comments are welcomed. Be nice though :<.

    Oh, and feel free to put his up on the wiki, as I fail at wiki editing.
  2. roxahris


    Everyone's a hypocrite. Take my word for it. Member
    Doing anything at all
    What's the point in telling people to use a specific sample rate when you then proceed to mention the "pitch"? If you rip samples from other games, or want to keep your samples small, the best way to find the proper "pitch" for the pitch of your samples is through experimentation.
  3. Cinossu


    London, UK
    Sonic the Hedgehog Extended Edition
    I think it's to keep filesize down for people. You could use 44.1khz samples if you wanted, but lol big size?
  4. Puto


    Shin'ichi Kudō, detective. Tech Member
    Portugal, Oeiras
    Part of Team Megamix, but haven't done any actual work in ages.
    Might as well mention some values here:

    Pitch 9 is 16KHz.
    Pitch 5 is ~22KHz.
    Pitch $13 is 11KHz, I think.
  5. The pitch is purely up to the person using the sample. Sonic 2 Megamix, for example, had a slowed down snare sample.


    I spend all this time making a guide and no one tells me what I can do to make it a better guide? D:

    Did I explain everything thoroughly? ._.
  6. Selbi


    The Euphonic Mess Member
    Northern Germany
    Sonic ERaZor
    <!--quoteo(post=396832:date=Jan 16 2010, 10:04 PM:name=Irixion)--><div class='quotetop'>QUOTE (Irixion @ Jan 16 2010, 10:04 PM) <a href="index.php?act=findpost&pid=396832">[​IMG]</a></div><div class='quotemain'><!--quotec-->I spend all this time making a guide and no one tells me what I can do to make it a better guide? D:

    Did I explain everything thoroughly? ._.<!--QuoteEnd--></div><!--QuoteEEnd-->
    The reason why no one tells you how to make the guide better, is probably because there's nothing to make it better. It's fine. :)

    And yes, you explained everything well.
  7. Ravenfreak


    Is actually a guy. Tech Member
    O'Fallon Mo
    Hacking Sonic Drift, Writer at Sonic Cage Dome
    I do see a typo in there, you misspelled "divide". You spelled it as "devide", other than that awesome guide you have here.
  8. <!--quoteo(post=396860:date=Jan 16 2010, 05:29 PM:name=Ravenfreak)--><div class='quotetop'>QUOTE (Ravenfreak @ Jan 16 2010, 05:29 PM) <a href="index.php?act=findpost&pid=396860">[​IMG]</a></div><div class='quotemain'><!--quotec-->I do see a typo in there, you misspelled "divide". You spelled it as "devide", other than that awesome guide you have here.<!--QuoteEnd--></div><!--QuoteEEnd-->

    All spelling mistakes fixed (there were more than just the 'devide')

    I'm sure there are other, and probably better ways of inserting DAC samples, but this is the way I figured it out...should anyone want to share a better way with me, I'll write a guide for that too.
  9. Sorry for the double post, but I've revised the guide, put in a few fixes, made the calculation bit simpler, and as well, added a troubleshooting section.

    :) Enjoy!
  10. Eduardo Knuckles

    Eduardo Knuckles

    Not a loved one, but the most hated person. Misfit
    Someplace somewhere
    Project S.A.M.G.
    Well... This header info may be useful for the lots of people that wants to fix these wheezings at the end and the begin of the file. This will be common if the song is a WAV or something like this. Other (not really easier) way to fix it is opening the sample into some audio editor like Audacity and converting the sample into a Headerless RAW file format.
    Well, Irix... Keep up this good work. Thanks.
  11. It's simpler to just open it up in hex and fix everything in one swoop.

    I also added one more troubleshooting step for the click at the end of your sample.
Thread Status:
Not open for further replies.