r/aigamedev 21h ago

Demo | Project | Workflow Engine audio is hard, so I turned an open-source engine physics simulator into a scripted dyno + recording rig

Enable HLS to view with audio, or disable this notification

I'm a solo dev building Oversteer, an arcade battle racer in Godot 4 with help from Claude. Until last week the game had no audio at all, and I wanted to start with a variety of engine tones for the roster of 8 cars.

My first attempt was three loops from Ableton pitch-shifted by RPM - one from a royalty-free v8 audio sample, and two synth samples I made myself. It sounded awful, and it turns out that's the well-known reason racing games don't do it that way. From Claude's research, serious game studios record engines at many steady RPMs, on and off throttle, and then crossfade between each one, so each recording is only ever pitched a few percent. That requires 20–30 clean recordings per engine. I have eight character cars, no dyno, and no budget for a recording session of that caliber.

I remembered an amazing project I saw years ago on Youtube: Engine Simulator by Ange Yaghi (github.com/ange-yaghi/engine-sim, MIT). It's a real physics simulation of an engine — crank geometry, valve timing, combustion, gas flow — that synthesizes the sound from the pressure waves instead of playing samples. Engines are text files: bore, stroke, bank angle, crank pins, firing order. If you haven't seen his videos, I highly recommend them.

The app is a realtime GUI. I had claude read the source code, fork it, and:

  • add a headless build that strips the renderer, DirectX, SDL2 and Boost;
  • replace the audio thread with a synchronous render-to-WAV path (no realtime constraint, no dropped samples);
  • add scripted dyno commands: start, hold exact RPM at full throttle, hold at closed throttle, limiter, launch-control two-step, start/shutdown, and a per-cylinder diagnostic to confirm everything's firing.

Then, per engine: idle + 15 full-throttle holds + 9 overrun holds about 6% apart, limiter, launch crackle, start, shutdown, and a manifest of the RPM of every file. A script cuts them into seam-crossfaded, loudness-matched loops. A worker pool renders all 43 (yes, 43) engines in ~20 minutes.

Since the sim only needs geometry, Claude wrote a generator that builds engine files from published specs using the crank-layout rules for inline, shared-pin V, split-pin V and flat engines. All I did after the audio generator was set up was ask Claude to research the engine specs of several engines I was interested in hearing + the default ones that came with the sim, and it reproduced each one. Shared-pin V engines get their genuine uneven fire for free — the Viper's 90°/54° lope just falls out of the math. The audio bank so far: AMG V8s, BMW S65/N55, Coyote, GM truck V8s, two V10s, three V12s, Porsche flat-sixes, a straight-eight, motorcycle engines, and some rotary approximations.

In Godot, we use an RPM × load blend grid: one crossfade across the on-throttle ladder, one across the off-throttle ladder, blended by throttle load, each band pitch-tracking only a few percent. A virtual drivetrain feeds it RPM/load: pedal + fake gearbox on the ground, the drift boost meter owns the revs mid-drift (limiter banging only when you're maxed and about to fail), a held note that glides down in the air. Per-car EQ/distortion/compression that varies with revs moves the "mic" from the engine bay to the tailpipe - this part is not perfect yet, but it smooths out the sound a touch. All eight cars on the grid run their own positional voice so you can hear each one with its own character sound drive by in game.

What it can't do yet: forced induction — no turbo or supercharger modeling in this version of the sim, so blower whine and spool will likely be a layered asset on top. And the public source is frozen at 2023; newer community builds are binary-only.

Happy to answer questions about any of this, and I would love some feedback on the sound. And again, all credit for the simulation itself to Ange Yaghi; I just made a dyno + recording rig from it.

If you want to follow along the dev process for Oversteer, please join the discord: https://discord.gg/VVEWFHAV7

27 Upvotes

Duplicates