Class ProceduralEngineAudio
Generates engine sounds procedurally without using audio files. Uses additive synthesis to create realistic engine tones based on RPM and cylinder count.
Inheritance
Namespace: YACC.Audio
Assembly: .dll
Syntax
public class ProceduralEngineAudio : MonoBehaviour
Remarks
⚠️ IMPORTANT:
Do NOT use this component together with EngineAudio on the same GameObject. OnAudioFilterRead can only work with ONE AudioSource at a time. Choose either ProceduralEngineAudio (no audio files) OR EngineAudio (sample-based).
HOW IT WORKS:
1. Calculates firing frequency: (RPM / 60) * (cylinders / 2) for 4-stroke engines
2. Generates harmonics: Base frequency + harmonics (×2, ×3, ×4, etc.) for richness
3. Adds noise and crackle for realism
4. Modulates based on throttle position
PROS: No audio files needed, fully dynamic, perfect RPM sync
CONS: More CPU intensive, harder to get "right" sound, less realistic than samples
BEST FOR: Prototyping, sci-fi vehicles, when you can't record real engines
Fields
| Name | Description |
|---|---|
| breathingNoise | |
| cylinderCount | |
| engineType | |
| harmonicCount | |
| roughness | |
| throttleModulation | |
| volume |