Friday, December 29, 2023

NFS3/NFSHS Car Sound Tutorial

Note: this tutorial is made with the assumption you are familiarized with Audacity's interface and tools. If you don't I strongly recommend to read the program's manual here

    Intro

    There's a couple of car sound editing for NFSHS out there but I always had some trouble making sounds because they either had clicking in spite of following the steps (albeit adapted for Audacity), uneven looping or sounds sounding "muffled" compared to source. After messing around with samples and some hex editing I finally came up with a method to get consistently decent loops in-game and in addition, gathered some insight on NFS3 sound editing as well.
     

    Tools you'll need

     

    The BNK files structure

    NFS3 and NFSHS use sound bank files (.BNK) for car sounds; NFSHS has also the CARENG.CTB and CARENG.LTB files, which are presumed to tell the game which sample of (S)CARENG.BNK use at what rpm since each car has a different set. NFS3 on the other hand has a simpler, standardized structure recycled from NFS2 (the only difference is that NFS3 CAR.BNKs might come with compressed samples, but NFS2 .BNKs can be used as-is). 

     

    NFS3 car sound structure

    File Description Samples Notes
    car.bnk
    Player car sound bank
    1. Engine accelerating
    2. Engine decelerating
    3. Gear shift
    4. Horn
    • Samples 1, 2 and 4 are looped
    • Samples 1 and 2 are normally stereo but mono samples can be used without issues
    ocar.bnk
    Opponent car sound bank
    1. Engine accelerating
    2. Horn
    • Samples are looped
    ocard.bnk
    Opponent car sound bank (for Dolby sound, perhaps?) same as ocar.bnk
    same as ocar.bnk
    scar.bnk
    Player 2 in split-screen bank
    same as car.bnk
    same as car.bnk but all samples are mono

    NFSHS car sound structure (CLK-GTR sounds files)

    File Description Samples Notes
    careng.bnk
    Player car sound bank
    1. Gear shift
    2. Horn
    3. Idle (decelerating)
    4. Low-RPM (decelerating)
    5. Mid-RPM (decelerating)
    6. High-RPM (decelerating)
    7. Idle (accelerating)
    8. Low-RPM (accelerating)
    9. Mid-RPM (accelerating)
    10. High-RPM (accelerating)
    11. Idle (decelerating, interior)
    12. Low-RPM (decelerating, interior)
    13. Mid-RPM (decelerating, interior)
    14. High-RPM (decelerating, interior)
    15. Idle (accelerating, interior)
    16. Low-RPM (accelerating, interior)
    17. Mid-RPM (accelerating, interior)
    18. High-RPM (accelerating, interior)
    • All samples except 1 are looped
    • Samples 11 to 18 are normally stereo but mono samples can be used without issues
    ocareng.bnk
    Opponent car sound bank
    1. Engine accelerating
    2. Horn
    • Samples are looped
    scareng.bnk
    Player 2 in split-screen bank
    same as careng.bnk
    same as careng.bnk but all samples are mono
    careng.ltb
    careng.ctb
    presumably lookup tables for the (s)careng.bnk files



    Sample requirements

    NFS3/NFSHS audio samples do have some requirements in order to work correctly, mostly due to sound memory constraints. Such requirements are:
    • 22050 Hz sample rate
    • Can be mono or stereo
      • Stereo samples should be pitched down 50% compared to mono
    • Max length of samples vary per game but rule of thumb is to not exceed 1.2 seconds (NFSHS maximum) for mono samples, stereo samples are around half of that.

    In general terms, working with mono samples is easier than with stereo samples because of the latter two points.

    Why it was a massive PITA to get decent sound loops... until now

    (this is a rather lengthy theoretical part, so buckle up)
     
    In the simplest terms, it's because the sole program that can work with BNK files (NFSWizard) is ancient jank. NFS Wizard for some forsaken reason corrupts each audio sample at the beginning upon closing a BNK file; it appears it inserts some additional sample info data but it "pushes" audio data forward by fractions of a second, leading to the end of each sample "stomp" on the beginning of the next, creating a noticeable "click" on playback. That's why it was often advised to import all samples again every time you open a BNK file.

    Making matters more complicated, the sample looping interface in NFSWizard is just a couple of sliders; you can't punch the value you need there, hence it's very imprecise. The combination of both factors made getting loops right a near endless game of trial and error.

    However, not all is lost. As mentioned before, the end of each sample stomps on the beginning of the next one; that means one could put a bit of silence at the end of each sample so the "click" is (mostly) avoided. But that's not all: the loop points still have yet to be set and they can't be set precisely... unless you are willing to do some hex editing magic, like I did.
     
    First I looked over into the Sample Info tab of NFSWizard to see if the loop info is there. After moving the loop points and looking at the tab, I found the two addresses that correspond to the loop points:
     
     
    Then I exported the BNK file and opened it with a hex editor. I searched the addresses with the values, and lo and behold there are:

    Each looped sample has 2 addresses of 4 bytes each, one starts with 86 and the other with 87: these correspond to the loop points. The part we're interested is this one:

    "What the hell is a wave sample?", you might ask. Well, a wave sample is the basic unit of sound which varies with the sound frequency: in a 1 second-long 22050 Hz sound there are 22050 samples, for example. Which means 22 wave samples is equivalent to 0.001 seconds... which is about the amount the NFS3 samples get "shifted" around. (NFSHS sounds get shifted by 28 wave samples).

    Now you see the number I pointed out in red doesn't read 22 or anything of the sort, that's because it's a hexadecimal number; you have to convert your decimal numbers to those. Windows Calculator has a programmer mode that allows for such thing, so punching 22 in decimal mode should yield "16" in hexadecimal (or "1C" for 28). Changing the bytes in the space I pointed out to 00 16 and saving in the hex editor will set the starting loop to 22 wave samples (the end loop can be just be dragged all the way to the end in NFSWizard) and now I can import it back to NFSWizard.

    Do you have to do this for this tutorial? No, luckily for you I have uploaded sets of edited BNK files with the starting loop points fixed, linked above. However you might have to do this process for the horn samples if you fancy editing them.

    Enough theoretical babble, let's get onto sourcing a sound sample.

    Step 1: Sourcing your samples

    You'll need to get your sounds from *somewhere* (duh), however there are a couple of considerations to take to get a decent sound:
    • You'll need to get a sound sample that's clean as possible. That means no echoing, no distortions, no foreign sounds like wind/road noise, etc.
    • It needs to be as steady as possible for at least 0.5-0.6 seconds; relatively minor pitch changes (such as accelerating/decelerating down a road) can be corrected with the Sliding Stretch tool.
    • If you can, get both acceleration and deceleration sounds. Otherwise just the acceleration sounds might suffice.

    Regardless, you can get your sounds by either recording them from another videogame (using OBS, Xbox Game Bar or Audacity's built-in loopback recorder) or by ripping it from some online video. In case you want to record it from another videogame, here's an excerpt adapted from Zpectre's first tutorial linked above:

    If you are using an analog device (like a gamepad or steering wheel), you first need to assign the throttle command to the Y axis. When the game asks you which key/button/command you want to use for the throttle, move the stick forward (I guess you all know how to do it) or press the right trigger. If you have a wheel, just use the pedals. After you customize your controls, start a race using manual transmission. When you are in control of the car, leave it at neutral gear. Now start pushing the throttle slowly until you reach an RPM value that is 1000-2000 RPM lower than the max RPM for the car (this gives better sounds). When you reach the value you want, keep the tachometer at it, then begin to record your sound. Make a 5-10 seconds long video, then stop recording.

    The second method is suitable for keyboard users and for some games which make distinction between engine and exhaust samples (like NFSU2 and NFSMW). You need to find a track with a section where the car will keep accelerating for some seconds, but won't increase RPM any further (for example, the small ramp before the first tollbooths in NFSMW's City Perimeter track). Start a race with the car you want on the track you think will be best to record sounds on, preferably with manual transmission (so you have more control over the RPM ranges). Before you reach the part of the track where the RPM will remain constant, start to record, then end it after you get the sound you wanted.
    Also it's worth adding:
    • As long as it's possible try to turn down all sounds that aren't the engine sound. In some cases you might have to mod the source game to achieve that.
    • Try to avoid recording supercharger/turbocharger sounds because they won't sound good on idle/lower revs. Again, try to turn them down/remove them. However, for NFSHS, you can also record one sound with supercharger/turbo and one without them for use with high/low rpms, respectively.
    • Avoid driving through tunnels and overpasses, the resulting echo effect can affect quality.
    • To use Audacity's loopback recorder, set the Host to Windows WASAPI, Recording Channels to "1  (Mono)", Project Sample Rate to 22050 Hz and Playback/Recording Device to your speakers or headphones (whichever is plugged) in Audio Settings. Then you can hit the Record button in the toolbar to start recording.
    • The resulting sounds might not be 100% accurate to the source sound, that's due NFS3/HS relatively primitive sound engine.

    If you're going to source sounds from internet videos, then you might have to do some legwork to get a decent one because many are not quite optimal. Flyby and dyno videos might give you a better chance but they might require additional editing that won't be covered in this tutorial. 


    Step 2: Preparing your base sounds

    Once you have your sound recorded/imported, it's time to make your base sounds. Just in case, save them as an Audacity project. Select 0.5-0.75 seconds of your recorded sounds and copy them into a new project. Then select the entirety of newly pasted sound and apply the following effects:
    • Volume and Compression > Amplify
      • Default values are usually fine but you can check the Allow clipping checkbox and set the Amplification value 1-2 dBs higher than the default
    • Volume and Compression > Limiter
      • Set Type to Soft Clip and Apply Make-up Gain to Yes
    • If you're working with a unsteady sound (like one from an accelerating/decelerating car) you can use Pitch and Tempo > Sliding stretch before using the Amplify and Limiter effects
      • Usually a value of (-)1 to (-)5 percent on one end does even out the sound.
    • Also if you want to make an interior engine sound out of your sound you can use EQ and Filters > Bass and Treble for that before using the Amplify and Limiter effects.
      • Usually a 15%-20% treble value does the job
    After that you have to set the pitch of the base sample with Effects > Pitch and Tempo > Change speed and pitch; your target is what would sound best when played at 140% speed (NFS3) or 135% speed (NFSHS); the Playback-at-Speed toolbar pretty much helps with that. As a rule of thumb, here are the percent changes you'll usually have to use per game:
    • NFS3: -30 to -35 percent change
    • NFSHS: -15 to -25 percent change

    When you're done, select your whole track, press Z to set the selection to zero points (the black line that's in the middle of the wave, this is important since that would avoid -most- instances of clicking), press Ctrl+T to trim the track and go to Tracks > Align Tracks > Start to zero to get rid of the empty space it might make. You might also want to delete any remaining sound after the 0.75 second mark by selecting it and pressing Ctrl+K.

    Save your base sound as an Audacity project because you will need to get back to it, especially if you're making a NFSHS sound


    Step 3: Making the engine sounds

    With the base sound done, copy it and paste it into a new project. Copy and paste it again, but in a new track this time and reverse it with the Special > Reverse effect. Move the new track towards the right and make sure there's at least a 0.2-0.25 second overlap between the tracks, like this:

    Also make sure the waves "match" as possible in order to not get your sound muted at the middle after the next step, you might want to zoom in with Ctrl+mouse wheel to check.

    Next select the overlapping parts of the tracks like this...
    ...then go to Effects > Fading > Crossfade tracks, set Fade TYPE to Constant Power and click OK.
     
    Try out the track loop by selecting all tracks, enable looping by pressing L and set the loop to selection by pressing Shift+Alt+L and play it back.
     
    If you hear any noticeable click/gap, you can do any of the following:
    • Go back to the beginning of this step, select one bit of the beginning (mind the zero points), delete it with Ctrl+K and do the whole process again.

      -OR-

    • Use the Special > Invert effect on the reversed track.

    Once you are satisfied, select your track, press the End key to bring the cursor to the end of the track, go to Generate > Silence, click on the arrow next to the Duration field to open the dropdown menu and select hh:mm:ss+samples. Set Duration to 00h 00m 00s + 00022 samples (for NFS3) or 00h 00m 00s + 00028 samples (for NFSHS) and click Generate. Select all tracks and press Ctrl+J to join them.

    Export your track by going to File > Export Audio , give it a filename and select a location to save it in, set format to WAV (Microsoft), set Channels to Mono, Sample Rate to 22050 Hz, Encoding to Signed 16-bit PCM and Export Range to Current Selection. Click on Export to export the file.
     
    For opponent car sounds you can select the track, go to Effects > Volume and Compression > Amplify and use a -2 to -3 dB amplification so your opponent sounds don't drown the player's.

    For NFS3 you can proceed to the next step, but for NFSHS you have to make the rest of the sounds (mid, low, idle). Go back to the beginning of this step and proceed to do the following:
    • Select your track and go to Effects > Pitch and Tempo > Change speed and pitch. Apply the following percent changes for the following:
      • -20 for the mid-rpm sound
      • -40 for the low-rpm sound
      • -60 for the idle sound
    • (If needed) Press Z to set selection to zero points, trim it with Ctrl+T and align tracks to zero
    • Select any remaining sound past the 0.75 second mark and delete it with Ctrl+K

    Then proceed as usual.

     

    Step 4: Importing samples to the BNK file

    Open the .VIV file containing the edited BNKs and your car.viv file in NFS Wizard. Go to Window > Tile Vertically to set both windows side to side and drag the files from the edited file's VIV to your CAR.VIV.
     
    Close the edited BNKs .VIV file and open the CAR.BNK/CARENG.BNK file. Select the first engine sound, right click on it and make sure Show Loop is enabled. Press Ctrl+I to import a sound file and select your engine sound.

    Once imported, click and drag the ending loop marker all the way to the right edge of the window.

    Repeat this process for the rest of the engine sound samples in the BNK file and close it. Then repeat this step with the opponent (OCAR/OCARGENG) BNK file.

    Once done, you can duplicate the CAR/CARENG.BNK file into a SCAR/SCARENG.BNK file for splitscreen player 2 sounds and for NFS3, the OCAR.BNK into OCARD.BNK. Save your car.viv file, you're done

    Remember that if for some reason you have to reimport samples, you have to reimport all of them, so it's advised to have the gear shift and horn samples exported at hand.


    That's it for this tutorial, hope you get neat sounds out of it. See you around!

    No comments:

    Post a Comment