An easy way to simulate engine sound is to just play a looped recording of a real car at a certain RPM, and then pitch-shift it based on your vehicle’s RPM in the game. That’s what I’m doing right now — and it works... kinda.
The problem is, it’s just one sound loop getting stretched up and down in pitch. No single recording really covers the whole RPM range cleanly, so it starts to fall apart at the extremes — super low RPM sounds muddy, and high RPM gets whiny or robotic. It’s passable, but not great.
To improve it a bit, I tried a couple things. Here's what helped:
Semitone mapping
At first, I just mapped pitch linearly to the RPM range. It technically worked, but sounded weird — like the engine wasn’t really accelerating in a believable way. I didn’t know why at the time, but after asking ChatGPT, I found out that pitch perception is logarithmic, not linear.
So instead of scaling pitch directly, you can map RPM to semitones, which are musical intervals that step evenly on a log scale. This gives you more natural-sounding pitch changes — especially when the RPM is sweeping up or down quickly. I have zero music or audio background, so I basically just trusted the answer and gave it a shot... and surprisingly, it worked. It sounds way smoother and more realistic now.
Below a somewhat unfair comparison, but I hope you get the idea. LinearNon-linear Onload/Offload Another trick is to have 2 versions of your recording, one where the engine is under stress ( throttle on ) and another where throttle is off. Simply blending between these 2 gives a pretty nice effect, you can hear the engine engaging and disengaging based on throttle/load.
Multiple clips A lot of implementations out there have several recordings, at different RPM ranges and smoothly blend between them. Codewise this was easy to implement but I had a hard time finding good recordings and then especially hard to setup the transitions between them. Something like this is very easy in FMOD, where you can visually see where the transistions are. I'm sure one could build something like this in Sandbox, but I haven't touched any editor stuff yet.
This is the nicest implementation of it I could find and once I'm a little less lazy I'll try to implement it: https://markeasting.github.io/engine/
Apparently there’s something called Granular Synth, which — at the risk of sounding naive — I’d never heard of before. The way I understand it: you take a single engine recording, from low to high RPM, and basically play it back like you’re scrubbing through the audio file. So instead of pitch-shifting, you just feed in your current RPM, and it plays the right part of the clip.
Sounds simple, but it’s not. You can’t actually scrub audio like that in real-time. The trick is to slice the clip into a bunch of tiny chunks (I tried 30, 60, even 120), which they call grains. Then you blend those grains together while playing them back. When it works (which I didn’t quite nail yet), you end up with a single recording that can accurately follow your RPM input forever.
Here’s a Unity implementation someone made that shows the idea really clearly. Audio Processor
I figured the Audio Processor might be the best place to do this, but I ran into issues with noise getting into the final output. I couldn’t tell if it was my code or something deeper in the engine, so I ended up putting it aside and trying SoundStream instead.
SoundStream
This went a lot smoother. I had to manually load the .wav file though, since I don’t think you can access the raw buffers from a SoundHandle. That part kinda sucked — it’s just another place where stuff can break. But I managed to get the original sound playing back by extracting the buffer and feeding it directly into the stream.
Grains
This is where things really fell apart. I couldn’t get the grains scheduled cleanly — there was clicking and popping between them no matter what I tried. Some of the better implementations out there fade multiple grains together with such clean timing that it almost sounds like scrubbing the original file. Mine… did not.
Overall, this was a fun experiment. I learned a lot about audio — even if I ended up with the most basic version: one loop pitched up and down.
Below is an (old) recording of how close I got. As you can hear, it’s super glitchy and noisy. The sound is nothing like the original clip, unfortunately. Still, I was kind of proud of the result at the time.
I can’t talk about car engine sounds without posting this. The video explains it better than I ever could, but the TL;DR is: what if you simulate every single part of a real engine? The result is honestly amazing. I'm sure I missed or messed some things up, if so, please feel free to let me know :)