NFSAddons Forums

Team RSR Forums => NFS:HS Workshop => Topic started by: AJ_Lethal on Dec 30, 2023, 8:40 AM

Title: NFS3/HS Car Sound Tutorial
Post by: AJ_Lethal on Dec 30, 2023, 8:40 AM
(this tutorial is also available at my modding blog (https://nfsmodderscorner.blogspot.com/2023/12/nfs3nfshs-car-sound-tutorial.html)) 

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 (https://manual.audacityteam.org/index.html)

Intro
There's a cou (https://www.nfsaddons.com/forums/index.php?topic=512.0)ple (https://www.nfsaddons.com/forums/index.php?topic=1643.0) 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 (alongside the advent of new software for better BNK 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 (or stream) 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 alternate streams which NFSWizard cannot read, but NFS2 .BNKs can be used as-is).

NFS3 car sound structure
File Description Samples [streams] Notes
car.bnk
 
Player car sound bank
 
  • Engine accelerating (0)
  • Engine decelerating [1]
  • Gear shift [2]
  • Horn [3]
     
  • Samples 1, 2 and 4 are looped
  • Samples 1 and 2 are normally stereo but mono samples can be used without issues
  • Samples 1 and 2 might also come with alternate streams for interior sounds, though they aren't mandatory
     
ocar.bnk
 
Opponent car sound bank
 
  • Engine accelerating (0)
  • Horn [3]
     
  • 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 [streams] Notes
careng.bnk
 
Player car sound bank
 
  • Gear shift [2]
  • Horn [3]
  • Idle (decelerating) [32]
  • Low-RPM (decelerating) [33]
  • Mid-RPM (decelerating) [34]
  • High-RPM (decelerating) [35]
  • Idle (accelerating) [48]
  • Low-RPM (accelerating) [49]
  • Mid-RPM (accelerating) [50]
  • High-RPM (accelerating) [51]
  • Idle (decelerating, interior) [64]
  • Low-RPM (decelerating, interior) [65]
  • Mid-RPM (decelerating, interior) [66]
  • High-RPM (decelerating, interior) [67]
  • Idle (accelerating, interior) [80]
  • Low-RPM (accelerating, interior) [81]
  • Mid-RPM (accelerating, interior) [82]
  • High-RPM (accelerating, interior) [83]
  • 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
 
  • Engine accelerating (0)
  • Horn [3]
     
  • 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:
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 (until very recently) that could 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:
(https://blogger.googleusercontent.com/img/a/AVvXsEhGPrUYLZhESEUHM5RWQO5sxddMFiJ68TrdpA_GKUpsHVQgGRY8wBGGlsy_9dph2vQKgU2jgADU7dve1lyYS02QJVtrz1mvGdHL7DqJS0hYmWTGBLHy3aeLY7_xxTu89tdQDf5PTyNYFITIWEHXFX7Qni3sgcHFMUBW4hUDhhEJPYJDPU3EQwqUapql6GY)
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:

(https://blogger.googleusercontent.com/img/a/AVvXsEgICaj2pR9IZ01CzT03Slr93yLdrWqc98S_GA1dBJN3B1ZUaPFt1AfL9xxK4AzDDRUPVxEMCOnF6giGufiHA--faPrtZuLx47qYiRay5Eug7pK8aIqxtQYhDq5tyRVBvVp286b0_I5XUFdVJ_s2zdoJq6IFVQYIBAdqOLIx8VAIrFWJBzTQ5vtwIUZR8po)
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:
(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXcOKVzjr8k_SgDnGhVwciWir2UE1gA5Ox0jVjgTdC32snkfPahBMDcogCd1yun4bgBHrhIKrHHmS8ccBPyK5oKenG5Nr7IuLXdCxe83WZ7trMc8DCEyzGInObSEY6wdgkRphvPN1jSZPuzrm7rHz4vjAsrg-kfRTINSNH8Qf2r36Z5qsVCCDC16KF13U/s320/vasv.jpg)

"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 (or just use Vivianne, lmao). Though you might want as well to use the BNK horn loop tweaker for setting the horn samples precisely if you're using NFSWizard.

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:

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:
Quote from: Zpectre on Jul 15, 2007,  2:10 PMIf 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:
 
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:
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:

Sometimes after applying speed/pitch changes might result in distotions such as crackling or clipping; if that's the case, undo the speed/pitch change, use Volume and Compression > Amplify with a value of -0.5 to -1, apply speed/pitch changes again then use Legacy Limiter in Hard Limiter or Soft Clip mode to bring volume back up.

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


(continues below)
Title: Re: NFS3/HS Car Sound Tutorial
Post by: AJ_Lethal on Dec 30, 2023, 8:43 AM
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:
(https://blogger.googleusercontent.com/img/a/AVvXsEgxAv4N7EL3zBZcPetZMXhuhWmvGMF9ZCxNe58pFPAxGcmyF_Gdz01Rl-hj4Hht1p5khth_NvmJn2B4-0rdrYhXoFcu3vW-V6XpHLJhurdPWTx93gKUxIbMSeKo70JqvrdYZyvj9KyY0n_kis6kO4AUSc-PJL1uuT7q7kWDEW_iJpiK9hmaQcloWFtjSSo)
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.

(https://blogger.googleusercontent.com/img/a/AVvXsEgjJntwNXO7vkrZ8kAVS9ujYDbBShJLwkBo2k6SonJJwjj5VQ5sBaTRjumiyXIdnkFmAdI3nUodGnwE4820dL61xVsQBqhV4URqr3MXKskiyUZtqP7PqhzZCkjd1oB3NnAnzcps2z6BpODuYwGjAKhTWZ9tV6ASiNDTRTMqCnabP4M-T17Au6q4_A8UfUY)
Next select the overlapping parts of the tracks like this...

(https://blogger.googleusercontent.com/img/a/AVvXsEh4t3ztfMFrr2t-t7u2sfaH_Etu4S5TWGpqn5c52F5q_fGrqVbRh6jAACHQZ4UZrKrymhMGgstAh7ESQTM7rOdL1SUqqEhIsoxfpF7iBrsm3zs5xvS9K-CMvnkU4QiX2qrFQ-juaioMsMoRyyZPCnGArOyt_Dg8iEnYV0fMqQeFgaOzxQaW19GJo0gbvik)
...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:


QuoteIf you're using NFSWizard for importing the sounds: 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:

Then proceed as usual.

Step 4: Importing samples to the BNK file
If you're using Vivianne:

If you're using NFS Wizard:


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!