Log inGet started
World

Torque Valley: Driving, Drift and Crash Sandbox

README.md

engineVoices.synth

The deterministic generator behind the engine voices, and the analysis that checks them. Re-run it after you change a voice's parameters in engineVoices.voices. Nothing at runtime requires it.

Each loop is one second of 32 kHz mono PCM. A loop holds a whole number of engine cycles: every band's reference rpm gives a cycle frequency that is a whole number of Hz (rpm/120 for four-strokes, rpm/60 for two-strokes and the rotary). Firing pulses (gamma-shaped pressure pulses plus combustion-noise bursts) are placed modulo the loop length. Every filter (two-pole low-pass, RBJ band-pass pipe resonances, a DC-blocking high-pass) runs over the buffer twice, so its state wraps, and the result loops with no seam. Per-cylinder imbalance, per-firing amplitude and timing jitter, misfires (kart four-stroking, rotary brap), per-bank pipes and delays (V8 cross-plane burble, V12 banks), diesel knock and valvetrain ticks shape the character. A tanh drive stage gives the on-load takes their extra harmonics. Loudness is set per take: on-load at 0.2 RMS and off-load at about 0.085.

local Synth = require("engineVoices.synth")
Synth.bakeAll()                      -- 48 loops + shared clips, about 6 s
Synth.bakeVoice("v8")                -- one voice's six loops
Synth.bakeShared()                   -- whistle, inverter, shifts, pops, skid loops
local x, ref = Synth.render("kart", 1, true)    -- samples without baking
Synth.analyze("ev_v8_2_on")          --> { peakHz = 168, firingHz = 168, peakOverFiring = 1, harmonicShare = .., rms = .. }

bakeShared builds the tarmac squeal from soundstage's generated ss_vehicles_skid_3 take when soundstage is installed. It builds the gravel and soft loops by cutting the steady middle of the generated ev_skid_*_src takes and crossfading the wrap.