all of the changes

This commit is contained in:
2026-10-23 18:29:51 +02:00
parent 4c435fdd76
commit 5607dcf2b5
73 changed files with 4365 additions and 2059 deletions

View File

@@ -1,97 +1,112 @@
# Static outdoor audio and two-stroke verification
# Audio rendering notes
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.
The desktop and capture tool produce sound at 44.1 kHz. Intake and exhaust
ambient-density-scaled volume-flow derivatives drive the compact-monopole source, with static
source/listener positions, fractional-sample propagation, inverse-distance
spreading, and separate left/right ear paths. The monitor uses a second-
order 6 kHz low-pass; desktop playback removes DC and applies PCM clipping
protection.
## Renderer
## Outdoor scenes
`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.
`OutdoorAudio` renders direct sound, image-source ground and wall reflections,
and six approximate woodland scatter paths. The tunnel profile adds image
paths for a nominally 6 m wide, 4 m high hard-surface enclosure. Its late tail
uses the live eight-line feedback-delay network in `OutdoorExhaustReverb`. The
five scene profiles set different reflection paths, tail levels, and
frequency-dependent decay times. Scene changes smooth over 20 ms. These
profiles are intended for listening comparisons, not as validated models of
particular locations.
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.
The direct source remains prominent, so scene differences are clearest in the
reflections and decay after transients. Ground effects depend on surface,
geometry, and frequency; the current coefficients are illustrative settings,
not measured material data. The feedback-delay network gives a diffuse late
tail, but does not simulate outdoor wave propagation or vegetation in detail.
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.
Calibrated directivity, alias-free acquisition,
and exhaust afterfire chemistry remain unresolved. Filtering cannot restore
source information lost to aliasing. Mechanical sound synthesis has been
removed; no mechanical source is currently rendered.
## Measured captures
## Listening and capture
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:
Run the desktop with `--scenario v8 --scene tunnel` and press **R** to cycle
through Dry, Field, Wall, Woodland, and Tunnel. Use 1x playback when judging
the audio.
To write comparable WAVs for one scene, build and run:
```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
cmake --build build-desktop --target fluidsim_audio_capture -j 4
./build-desktop/fluidsim_audio_capture --scenario v8 --scene field --seconds 1 --throttle .7 --out /tmp/v8-field
```
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.
The capture tool writes rendered, dry-filtered, and unfiltered WAV files. The
dry and unfiltered outputs omit the outdoor reflections and reverb, which helps
separate source filtering from scene processing.
## 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.
- [FHWA ground-effect guidance](https://www.fhwa.dot.gov/Environment/noise/noise_barriers/design_construction/design/design03.cfm)
- [Feedback delay networks in artificial reverberation](https://theses.eurasip.org/document/feedback-delay-networks-in-artificial-reverberation-and-reverberation-enhancement/)
The later YZ125 baseline changes these engine calibrations and measurements; see
[YZ125 baseline verification](YZ125_BASELINE.md) for current results.
## Pipe mouth boundary
All scenario pipe mouths use `add_radiating_open_end`. The intake atmosphere
component/orifice has been replaced by the same boundary used at exhaust mouths.
Physical intake plenums and exhaust collectors remain finite storage volumes.
The older `add_open_end` pressure-release boundary remains for idealized tests.
The unflanged circular-mouth reflection follows the causal second-order rational
fit in Silva et al., Eq. 16, with the low-frequency constraints in Eq. 17.
Its pressure reflection tends to -1 at low frequency, includes the 0.6133-radius
end correction, and loses reflected energy as frequency rises. Two scalar states
are integrated with the trapezoidal rule at each actual CFL substep; no history
buffers or allocations are needed. The filtered incoming characteristic combines
with the outgoing duct characteristic to determine the face state. One face flux
updates the pipe. The same face velocity and area supply the audio volume-flow
source, scaled by ambient density. Ambient inflow carries
fresh air, zero fuel, and 300 K stagnation enthalpy.
This is a plane-wave, no-flow radiation approximation coupled to a nonlinear
Euler duct. It does not establish accurate hot-jet/high-Mach radiation, vortex
shedding, flange effects, or higher duct modes. The published continuous model
has errors below 8 percent for reflection magnitude/end correction at ka <= 2;
mesh damping and time discretization introduce additional simulation error.
The audio renderer still uses a compact monopole approximation, so this boundary
upgrade alone does not calibrate external SPL or directivity.
Source: [Silva et al., acoustic radiation impedance](https://arxiv.org/html/0811.3625).
Recorded Linux Release check after this change: all seven CTest suites passed
(27.83 s). Tests cover the reflection fit's amplitude and phase at ka=0.1, 0.5,
1 and 2, inverted returning pulses at both orientations, reported mass exchange,
and fresh-air inflow stagnation enthalpy. These are implementation checks, not
experimental validation of strong-flow radiation. The B205 regression now checks
only its four active cylinders instead of the unused slots added for the V8.
A four-second V8 4500-RPM loaded benchmark took 0.395, 0.387, 0.403 and 0.403
wall seconds per simulated second (mean 0.397). This is headless runtime evidence
on this machine, not a measurement of audio device underruns. A four-second
V8/tunnel capture at 50 percent pedal had rendered peak 0.1011, RMS 0.02027,
and zero clipped samples. Capture files are under `build-desktop/audio/open-end-v8-*`.
## Light-load mouth-source correction
The radiating mouth previously sent actual mass flow to the sound renderer.
Switching between hot exhaust and cool ambient inflow introduces a donor-density
change into that signal. The renderer now differentiates ambient-density-scaled
volume flow, following the compact monopole formulation in the
[openCFS acoustic documentation](https://opencfs.gitlab.io/userdocu/PDEExplanations/Singlefield/AcousticPDE/).
Physical mass and energy fluxes and the causal reflection model are unchanged.
This remains a compact, no-mean-flow acoustic approximation.
A prescribed 4500 RPM Saab run, with one second of warmup and two seconds of
capture, compared the same straight-through exhaust before and after this audio
change. At 5% pedal, rendered RMS changed from 0.022763 to 0.024120; the fraction
of power above 2 kHz fell from 0.0475% to 0.0003%. At 15% pedal, maximum sample
change divided by RMS fell from 0.607 to 0.086. These are signal measurements,
not confirmation of perceived realism or a complete road-transient validation.
A regression checks that prescribed mouth velocity produces the same acoustic
volume source at hot and ambient donor densities, in both pipe orientations.