Engineering Pure Sound: Real-Time Engine Audio Synthesis & Spatial Acoustics with AVAudioEngine
ENGINEERING & AUDIOOctober 14, 2026•9 min read•Verified Technical Log

Engineering Pure Sound: Real-Time Engine Audio Synthesis & Spatial Acoustics with AVAudioEngine

In competitive high-speed motorsport, sound is not merely atmosphere — it is critical physical telemetry. Long before your eyes register a tire sliding wide over an apex curb or your thumbs counter-steer against a snap oversteer moment, your ears process the acoustic signature of your car. You hear the engine scream near redline, the intake resonance blooming under full throttle load, and the sudden pop and crackle of unburned fuel in the exhaust on overrun.

When we set out to build Velocity Unleashed natively for iOS 17+ in pure Swift 5.9, we refused to settle for standard mobile audio shortcuts. Most mobile racing games stretch a single low-quality engine audio loop across the entire rev range using a pitch shifter. The result is hollow, synthetic, and immersion-breaking: low revs sound muffled like an underwater propeller, while high revs sound thin, whiny, and disconnected from the road.

Instead, we built a modular, real-time procedural audio synthesis engine directly on Apple's low-level AVAudioEngine and Core Audio framework. Featuring an equal-power three-layer crossfade graph, 4-band dynamic EQ resonance sweeping, sub-harmonic rumble oscillators, and acoustic tunnel reverb zones, here is how we engineered console-grade racing acoustics on iPhone and iPad.

---

1. The Core Audio Graph: Architecture with AVAudioEngine

Apple's AVAudioEngine provides a low-overhead, node-based graph architecture that interfaces directly with the hardware audio output buffer at 44.1 kHz or 48 kHz. In Velocity Unleashed, the entire audio pipeline runs deterministically without third-party middleware bloat.

┌────────────────────────────────────────────────────────────────────────┐
│                   AVAUDIOENGINE MIXER GRAPH TOPOLOGY                   │
├────────────────────────────────────────────────────────────────────────┤
│  [Engine Idle Player] ──┐                                              │
│  [Engine Mid Player]  ──┼──> [3-Way Mixer] ──> [4-Band Dynamic EQ]     │
│  [Engine High Player] ──┘         │                     │              │
│                                   │ (Equal Power)       │ (Notch/Sweep)│
│  [Sub-Harmonic Rumble Osc] ───────┘                     ▼              │
│                                                [Acoustic Reverb Unit]  │
│  [Opponent Spatial Beds]  ──> [3D Panner] ─┐            │              │
│  [Surface & Kerb Noise]   ─────────────────┼──> [Master Peak Limiter]  │
│  [Turbo Whine & Wind]     ─────────────────┘            │              │
│                                                         ▼              │
│                                                [Hardware Output Node]  │
└────────────────────────────────────────────────────────────────────────┘

Why AVAudioEngine Over Traditional Samplers? - **Sub-Millisecond Latency:** Audio buffer schedules link directly to our 240Hz physics tick, eliminating the 40–80ms audio lag common with web wrappers or bulky cross-platform engines. - **Micro-Memory Footprint:** Rather than loading dozens of multi-megabyte soundbanks into RAM, our procedural engine relies on compact, prewarmed PCM sample loops (`AVAudioPCMBuffer`) decoded once during track initialization. - **Direct DSP Node Insertion:** We insert native Apple DSP units — such as `AVAudioUnitTimePitch`, `AVAudioUnitEQ`, and `AVAudioUnitReverb` — directly into the audio signal chain with zero serialization overhead.

---

2. The 3-Way Equal-Power Crossfade: Curing the Upshift Dip

The most common defect in racing game sound design is the "upshift hole." When a racing driver shifts up at 12,000 RPM, the transmission engages the next gear, dropping the crankshaft speed down to 8,500 RPM.

  • If engine volume is coupled linearly to engine RPM, the sound volume plummets precisely at the moment the car is accelerating at maximum throttle! To fix this in `EngineMix.swift`, we strictly decoupled RPM from Loudness:
  • RPM Controls Pitch & Resonance: Engine revs control playback rate, pitch cents, and harmonic shelf filters.
  • Throttle Controls Volume & Overrun: Loudness is governed almost entirely by engine load and throttle position.
// Excerpt from EngineMix.swift: Equal-Power Normalization
let midIn = smoothstep(from: midLayerOnset, to: midLayerPeak, t: rpm)
let midOut = 1 - smoothstep(from: midLayerPeak, to: 1.0, t: rpm)

let highT = min(1, max(0, (rpm - highLayerOnset) / (1 - highLayerOnset))) let highBlend = highT * highT * (3 - 2 * highT)

let idleBlend = 1 - smoothstep(from: midLayerOnset, to: 0.65, t: rpm)

// Equal-power normalization: idle² + mid² + high² ≈ 1 let sumSq = idleBlend * idleBlend + midBlend * midBlend + highBlend * highBlend let norm: Float = sumSq > 1e-8 ? 1.0 / sumSq.squareRoot() : 1

// Throttle carries volume; RPM carries pitch let level = (0.72 + 0.24 * highBlend) * (closedThrottleLevel + (1 - closedThrottleLevel) * load) ```

Equal-Power Energy Conservation When transitioning between our idle burble, mid-range growl, and high-RPM shriek, linear fading causes the combined acoustic energy to sag by up to 3 dB in the crossfade valleys. By enforcing `idle² + mid² + high² ≈ 1`, the overall sound pressure remains rock-solid as the revs sweep across the dial.

---

3. Dynamic 4-Band Parametric EQ: Shaping the V10 Screamer

Even high-quality recorded engine loops can sound flat when looped continuously under load. An authentic racing engine's acoustic spectrum changes continuously as cylinder pressure and exhaust velocity climb.

To recreate this behavior in real time, our AudioManager routes the combined engine submix through an AVAudioUnitEQ configured with four distinct frequency stages:

┌────────────────────────────────────────────────────────┐
│             4-BAND DYNAMIC ENGINE EQ PROFILE           │
├──────────────┬────────────┬─────────────┬──────────────┤
│  Band Filter │ Center Freq│ Gain Range  │ Role in Tone │
├──────────────┼────────────┼─────────────┼──────────────┤
│ 1. Low Shelf │ 120 Hz     │ +2 to +6 dB │ Sub-bass thud│
│ 2. Notch Cut │ 1,600 Hz   │ -4.5 dB     │ Tames "honk" │
│ 3. Res. Peak │ 2.8k–5.2k  │ +1 to +5 dB │ Sweeps w/ RPM│
│ 4. High Shelf│ 8,500 Hz   │ -3 to +4 dB │ Exhaust rasp │
└──────────────┴────────────┴─────────────┴──────────────┘

Eliminating the 1.6 kHz "Nasal Honk" Procedurally synthesized engine loops have a notorious acoustic artifact: an unnatural buildup of energy around 1,600 Hz that causes cars to sound like vacuum cleaners or electric razors. Inserting a narrow notch filter (-4.5 dB, Q = 2.4) at 1.6 kHz completely eliminates the synthetic honk, leaving only mechanical valve chatter and deep exhaust rumble.

RPM-Driven Resonance Sweeping As the car approaches its redline, Band 3 sweeps its center frequency dynamically from 2,800 Hz up to 5,200 Hz while increasing gain. This mimics the acoustic resonance of tuned titanium exhaust headers, delivering that spine-tingling metallic shriek as you draft an opponent down the straightaway.

---

4. Spatial Doppler Shifts & Multi-Car Grid Acoustics

In multiplayer duels and AI grid starts, having six high-revving open-wheel race cars roaring simultaneously creates a massive acoustic challenge: frequency crowding and hardware clipping.

The Master Peak Limiter Early performance profiling revealed that during 6-car grid launches, the summed output of all audio nodes was peaking at +1.72 (nearly 5 dB above digital full scale `0 dBFS`). On iOS hardware, this forced the OS audio daemon to hard-clip, causing sounds to drop out intermittently.

  • We solved this by inserting a dedicated AVAudioUnitEffect Master Peak Limiter on the output bus, dialed with:
  • Fast Attack (1.2 ms): Catches instantaneous curb clatters and backfire pops.
  • Adaptive Release (60 ms): Transparently restores dynamic range without perceptible pumping.
  • Ceiling (-0.2 dBFS): Guarantees zero digital distortion on both built-in iPhone stereo speakers and AirPods Pro.

Relative Vector Doppler Calculation Opponent car audio uses a two-tiered system. Nearby cars maintain continuous spatial beds, while high-speed overtaking maneuvers trigger directional Doppler flybys:

Relative Velocity = DotProduct(CarVelocity - CameraVelocity, CameraForwardVector)
Pitch Shift Factor = SpeedOfSound / (SpeedOfSound - RelativeVelocity)

When a rival drafts into your slipstream and pulls out to pass at a 40 km/h delta, their engine tone climbs sharply during approach, compresses into a visceral sonic punch as their nose passes your cockpit, and drops smoothly in pitch as they pull ahead into the braking zone.

---

5. Environmental Acoustics: Tunnels, Kerbs & Sub-Harmonics

Motorsport sound is defined by the environment it bounces against. A car screaming across an open desert plain sounds entirely different from the same car roaring through a concrete tunnel in Neon Cyber City.

┌────────────────────────────────────────────────────────┐
│             ENVIRONMENTAL ACOUSTIC LAYERS              │
├────────────────────────────┬───────────────────────────┤
│      Environmental Zone    │      Acoustic Response    │
├────────────────────────────┼───────────────────────────┤
│ • Neon Cyber City Tunnel   │ • Wet reverb wet-mix +65% │
│ • Apex Rumble Kerbs        │ • Rolling bed gain 1.9x   │
│ • Coastal Highway Straight │ • Stereo wind rush + DRS  │
│ • Overrun Deceleration     │ • Unburnt fuel exhaust pop│
└────────────────────────────┴───────────────────────────┘

Real-Time Tunnel Reverb Zones In `AudioManager.swift`, our track path locator continuously monitors camera and vehicle coordinates. When the car enters an enclosed tunnel or underpass: 1. The **AVAudioUnitReverb** node smoothly ramps from 0% to 65% wet mix using an exponential ease. 2. The delay taps generate rapid, slapping reflections off concrete walls that accentuate the high-frequency exhaust rasp. 3. Exiting back into open air smoothly fades the reverb back to zero over 400 milliseconds, giving players an unmistakable sense of acoustic transition.

Sub-Harmonic Rumble & Kerb Chatter To give mobile players the tactile illusion of low-end horsepower, we incorporated a dedicated sub-harmonic oscillator (38 Hz to 72 Hz) that modulates gently with throttle pedal angle. When driving over ripple strips and rumble curbs, `kerbRumble` scales the rolling surface gain by up to **1.9x**, injecting realistic physical texture into the mix.

---

6. Zero Frame Drops: Off-Thread Resource Pre-Warming

Audio hiccups directly compromise high-refresh-rate rendering. If an audio buffer decodes on the main thread during a frantic corner entry, the render loop will hitch, dropping frames on 120 FPS ProMotion displays.

  • To safeguard rock-solid 60/120 FPS gameplay:
  • Prewarmed Cues: All essential audio cues (`wind`, `rolling_asphalt`, `tire_screech`, `collision`, `boost`) are pre-decoded into uncompressed PCM buffers at race start.
  • Dedicated Music Queue: Garage music beds and menu audio are loaded on an asynchronous background queue (`vu.audio.music-load`), preventing menu navigation taps from hitching the UI.

---

7. The Result: A Living, Breathing Racing Machine

By pairing deterministic Swift physics with AVAudioEngine, we transformed Velocity Unleashed's audio from a simple background soundtrack into a vital, communicative instrument of speed. Every throttle lift, late-braking trail, and tunnel sprint produces an immediate, physically authentic acoustic reaction.

Grab a pair of AirPods or turn up your iPhone speakers, hit the starting grid, and experience the adrenaline of true procedural audio synthesis in Velocity Unleashed today!

0
LinkedIn
Sharing to LinkedIn?Rich 1200x630 Card
Copy a formatted technical post with relevant tags, or share directly.
PADDOCK CONVERSATIONS

Community Responses0

Leave a Response / Technical Question

Share feedback on this dev log, ask the engineering team a question, or discuss game mechanics with other racers.

Be respectful to fellow racers.

No comments yet.

Be the first to share your thoughts on this dev log!

Velocity Unleashed
Free on App Store
GET