Files
FluidSimCpp/verification/AUDIO_RENDERING.md

98 lines
5.5 KiB
Markdown

# Static outdoor audio and two-stroke verification
Verified on Linux in Release mode, 2026-10-23. The target remains fluid-derived
sound at 44.1 kHz. No synthetic bang, saturation, or combustion event is added
by the audio renderer. Acoustic processing does not feed energy into the solver.
## Renderer
`OutdoorAudio` replaces the active twin and two-stroke legacy reverb paths.
Each intake/exhaust mass-flow derivative drives a compact monopole. Separate
left/right paths use inverse distance and fractional-sample delays at 343 m/s.
The listener and sources are static. Default listener position is (1.6, 1, 2) m;
intake is (-0.2, .7, 0), exhaust (.55, .5, 0), ground y=0, wall x=-1.5.
Ground and wall reflection coefficients are .35 and .65. These are configurable
assumptions rather than measurements of a particular location.
A second-order 6 kHz monitoring low-pass reduces sharp acquisition transients;
it is linear and does not create afterfire. Early ground/wall reflections use
image paths. Woodland uses six approximate scatterers. A stable four-line
feedback-delay network supplies an empirical diffuse tail; it does not solve
outdoor wave propagation or vegetation scattering. Scene changes smooth over
20 ms. The old `OutdoorExhaustReverb` remains for legacy tests but is inactive
in both engine scenarios.
Pipe-end radiation impedance, calibrated directivity, alias-free acquisition,
and exhaust afterfire chemistry remain unresolved. PCM output is not calibrated
speaker SPL. The monitoring filter cannot recover information lost to aliasing.
## Measured captures
Four seconds at full pedal, wall environment, 44.1 kHz stereo. Each row's raw
and rendered signals come from the same simulation run. Measurements are
before PCM clipping; the raw signal includes direct spatial propagation.
| Engine | Raw maximum adjacent-sample change | Rendered change | Rendered peak | Clipping samples |
| --- | ---: | ---: | ---: | ---: |
| Twin | .569144 | .0881295 | .119947 | 0 |
| Two-stroke | .412956 | .138741 | .390789 | 0 |
These measurements establish transient reduction, not a subjective judgment
that limiter events sound like realistic bangs. Listening on the target audio
device is still required. Reproduce from the repository root:
```sh
cmake --build build-audit --target fluidsim_audio_capture -j 4
./build-audit/fluidsim_audio_capture --scenario twin --out build/audio/twin-wall --seconds 4 --throttle 1 --scene wall
./build-audit/fluidsim_audio_capture --scenario two-stroke --out build/audio/two-stroke-wall --seconds 4 --throttle 1 --scene wall
```
Each produces `-rendered.wav`, `-dry.wav` (filtered direct paths) and
`-unfiltered.wav` for comparison. Capture files are build artifacts.
## Two-stroke and regression checks
The existing 125 cc geometry now uses the shared ECU and finite-response
throttle, fuel dosing after the last scavenging port closes, 3000 RPM idle
control with ignition trim, and a dynamic damped cantilever reed with contacts.
Cylinder/crankcase geometry work uses adiabatic energy differences. An active
charge finishes combustion when a fuel cut begins. Ignition event crossing
handles wraparound without spuriously firing retarded ignition at zero degrees.
Reed parameters, combustion, scavenging and controller calibrations have not
been validated against a measured engine.
Both desktop engines share `MotorcycleTest` for clutch/vehicle integration,
common control dispatch and a common dashboard/dyno renderer. The two-stroke
limiter is disabled explicitly in the ECU and cylinder; the twin limiter is
unchanged. Idle and overrun controls remain enabled. The motorcycle and gearing
reuse the existing twin test configuration, not a measured 125 cc motorcycle.
The rolling peak dyno reports crank power and torque versus RPM.
All five CTest suites passed: basic physics/control, fluid boundary validation,
intake regression, outdoor audio, and two-stroke regression. Audio tests cover
fractional direct arrival, image reflection arrival, stereo ordering, distance
gain, linearity, filtering, causal decaying tails, and reed static compliance
and seating. The two-stroke sequence idles for two seconds, holds .6 pedal for
four, then releases for eight. It checks fuel stays enabled at open pedal above
the old limit, reed opening/seating, positive states, finite audio and idle
recovery, with no pipe positivity repairs. It then launches the motorcycle for
six seconds and checks shifting, neutral and positive dyno power/torque.
Latest Release results: free-rev maximum 22471.3 RPM, recovered idle 3236.08 RPM,
free-rev audio peak .512784, motorcycle speed 51.3773 km/h after launch. The high
unloaded RPM exposes the uncalibrated high-speed friction/combustion behavior;
removing the limiter does not validate this as realistic engine performance.
Unit checks also verify disabling an already latched limiter restores fueling.
The earlier four-second capture table above predates limiter removal and is
retained as an audio-renderer measurement, not a current engine baseline.
Windows execution of the latest changes is pending.
## Reference basis
- [Image source geometry](https://www.acs.psu.edu/noahparker/acs/img-src/img-src.html)
- [Feedback delay networks](https://msp.ucsd.edu/techniques/latest/book-html/node111.html)
- [Beam theory](https://mechanics.ju.se/SolidMechanics/BeamTheory.html), including uniform-load cantilever deflection used for reed compliance.
The later YZ125 baseline changes these engine calibrations and measurements; see
[YZ125 baseline verification](YZ125_BASELINE.md) for current results.