Repository navigation
Hot Path Audio Linear Resampling
Lifecycle: Performance - Unproven · Type: Approximate shortcut
State: Source-backed; runtime value is not established.
Status: Applicable approximation candidate; not implemented, not benchmarked, and not a hardware-accuracy claim.
Mechanism class: Approximate shortcut / cheaper interpolation algorithm.
Reviewed source:
322986f4c5502b3fa887a9605ac8cd88e9b2c579Subsystem: MCPX APU voice processing.
Current xemu creates a persistent two-channel libsamplerate callback converter using SRC_SINC_FASTEST. The proposed shortcut creates selected voice resamplers with SRC_LINEAR instead, leaving the callback, channel count, source progression, and surrounding voice logic unchanged for the first experiment.
This bypasses the more expensive bandlimited sinc interpolation algorithm. It also deliberately changes output samples and frequency response. The correct acceptance model is an optional audio-quality tradeoff, not output equivalence.
flowchart TD
A[Voice needs pitch conversion] --> B[Create persistent callback resampler]
B --> C[SRC_SINC_FASTEST, 2 channels]
C --> D[Fetch source frames through callback]
D --> E[Bandlimited sinc interpolation]
E --> F[Filtering, HRTF, routing and mix bins]
The source comment notes that the hardware’s real interpolation may be simpler, but xemu currently retains sinc because its quality is good. That comment does not establish what the Xbox hardware did.
flowchart TD
A[Voice/session policy resolved] --> B{Linear approximation selected?}
B -->|No| C[Create SRC_SINC_FASTEST converter]
B -->|Yes| D[Create SRC_LINEAR converter]
C --> E[Use existing callback and voice flow]
D --> E
E --> F[Filtering, HRTF, routing and mix bins]
The shortcut removes sinc-filter computation from admitted voices and substitutes linear interpolation. It does not remove:
- source fetching;
- resampler callback and persistent state;
- pitch-ratio handling;
- loop and completion processing;
- filtering, HRTF, routing, or mixing;
- the current two-channel representation.
Mono specialization is a separate proposal documented at Mono Voice Resampling. Combining the two would make attribution and quality analysis much harder.
The converter type is selected when src_callback_new() creates persistent state. A safe first implementation should therefore be:
- startup-latched; or
- latched when a new voice resampler is created; or
- applied only after a defined voice reset that already discards current resampler history.
Changing converter type live by destroying an active SRC_STATE can alter buffered input, phase, output latency, and completion timing. A menu toggle that claims immediate application without defining that transition is misleading.
The guest can observe:
- produced audio samples;
- source consumption and playback progression;
- completion/loop timing;
- buffer state and notifications;
- underruns or missed audio deadlines.
The host algorithm is not itself guest-visible, but its numerical and buffering consequences are. Therefore the shortcut is approximate even when gameplay remains functional.
The opportunity is largest when:
- many active voices require resampling;
- pitch ratios vary over time;
- audio-worker CPU is material;
- the worker approaches its real-time deadline;
- the cheaper converter reduces callback time enough to prevent queue starvation.
The official libsamplerate converter set explicitly trades quality for computation cost. SRC_LINEAR is described as very fast but poor quality and non-bandlimited, while SRC_SINC_FASTEST remains a bandlimited sinc converter.
| Area | Role |
|---|---|
hw/xbox/mcpx/apu/vp/vp.c |
voice_resample(), callback creation, source fetching, persistent per-voice state |
| Per-voice filter state | Owns the SRC_STATE and resample buffer |
| Voice reset/off paths | Reset or retire persistent converter state |
| APU worker | Executes resampling and downstream processing |
| Snapshot/lifecycle code | Must preserve or explicitly rebuild selected converter state |
Different output is expected, so a simple hash comparison is insufficient. Required material includes:
- silence and DC;
- impulse response;
- low-, mid-, and high-frequency tones;
- logarithmic frequency sweep;
- white/pink noise;
- speech and music;
- fixed ratios such as 0.5, 1.0, and 2.0;
- continuously changing pitch ratios.
Measure:
- frequency response and alias products;
- sample discontinuities;
- output latency;
- frames consumed/generated;
- peak and RMS error relative to the current route;
- underruns and callback tails.
Exercise:
- loop boundaries;
- stream starvation and recovery;
- voice stop/start and pause/resume;
- pitch changes during active playback;
- completion notifications;
- snapshot save/restore with active converter history;
- renderer/audio device teardown and restart.
A converter that produces acceptable sound but changes guest-visible source progression or completion timing has not preserved the current playback contract.
The source-confirmed opportunity is the unconditional creation of a two-channel SRC_SINC_FASTEST converter for resampled voices. No current profile establishes that sinc interpolation is a top APU cost or that linear conversion improves whole-emulator performance.
The first diagnostic must measure voice-resampling time separately from fetching, filters, HRTF, DSP work, and SDL queue pacing.
resampler_instances_sinc
resampler_instances_linear
resampler_frames_requested
resampler_input_frames_consumed
resampler_output_frames_generated
resampler_cpu_ns
resampler_callback_p95_p99
apu_deadline_misses
audio_queue_underruns
voice_completion_delta
quality_metric_summary
Use the same executable where possible, but treat converter selection as restart/voice-lifetime state. Record the effective route rather than only the requested setting.
- Audible aliasing, especially when downsampling.
- Harsh high-frequency content or unstable pitch transitions.
- Different internal buffering and source-consumption timing.
- Loop or completion timing changes.
- Snapshot state that does not record/recreate the selected converter.
- Lower local CPU without meaningful whole-system benefit.
- Incorrectly describing the result as more Xbox-accurate without hardware evidence.
- Add a non-persistent diagnostic selection first.
- Run signal and playback-state tests before retail performance tests.
- Capture APU-worker Release profiles and bounded counters.
- Run representative audio-heavy titles and compare guest progress, frame tails, APU CPU, queue health, and listening samples.
- Use level-matched randomized listening comparisons.
- Define an acceptable quality/error budget before interpreting results.
- Keep
SRC_SINC_FASTESTas the maintained exact-current-behavior route. - Expose a user option only if the tradeoff is repeatable and understandable.
Applicable as an explicit optional approximation. It should not be merged as an invisible optimization and should not be bundled with mono-channel specialization.
- MCPX APU & Audio
- Mono Voice Resampling
- Assumption-Based Shortcut Validation
- Using Hot-Path Shortcuts
Primary reference: This subject page is the design and research reference for Linear Audio Resampling. Pull requests are implementation/test history only.
Lifecycle: Performance - Unproven · Mechanism: Explicit quality/performance approximation
Reviewed source:322986f4c5502b3fa887a9605ac8cd88e9b2c579· Acceptance class: intended exact or behavior-preserving for its admitted scope
Use libsamplerate's linear converter instead of the current sinc converter under a clearly labeled audio-quality policy.
This entry remains Unproven: the source path and opportunity are concrete, but no accepted xemu runtime result has established that the candidate improves representative workloads. The page defines what must be bypassed, what remains mandatory, and how the hypothesis can be rejected.
| File / function | Role |
|---|---|
hw/xbox/mcpx/apu/vp/vp.c |
voice_resample(), converter creation, callback and persistent resampler state |
flowchart TD
N0["Fetch source frames"]
N1["Persistent SRC_SINC_FASTEST converter"]
N0 --> N1
N2["Band-limited interpolation/history"]
N1 --> N2
N3["Filter/HRTF/mix"]
N2 --> N3
N4["Queue host audio"]
N3 --> N4
flowchart TD
N0["Fetch source frames"]
N1["Persistent SRC_LINEAR converter"]
N0 --> N1
N2["Cheaper interpolation/history"]
N1 --> N2
N3["Unchanged filter/HRTF/mix"]
N2 --> N3
N4["Queue host audio"]
N3 --> N4
The current converter is intentionally higher quality than a simple interpolator. A lower-cost converter may reduce APU worker load or deadline misses in voice-heavy scenes, but it changes samples and potentially buffering/latency. This is not an equivalence optimization and must never be described as one without hardware measurements.
- Sinc kernel evaluation and its larger interpolation history
- Some converter CPU time and potentially converter latency
- Source fetch and decode
- Pitch/envelope progression
- Voice completion and looping
- Filter/HRTF/mixing
- Converter state management
int converter_type = fast_audio_policy
? SRC_LINEAR
: SRC_SINC_FASTEST;
filter->resampler = src_callback_new(
voice_resample_callback,
converter_type,
2,
&error,
filter);The sketch defines the intended boundary; it is not a complete patch and does not replace source review, ownership design, or focused tests.
- The effective policy must be recorded with evidence; a requested fast mode that failed to create must not masquerade as a comparison.
- Converter replacement cannot silently discard active phase/history unless the experiment explicitly restarts/recreates the voice.
- Guest-visible completion, looping, and starvation behavior must remain within the stated compatibility contract.
The converter is persistent per voice/filter, so mode selection should be startup- or voice-creation-latched for the initial experiment. Live switching requires a defined state-transfer or restart boundary and should be treated as a separate problem.
The maintained reference path remains the fallback whenever admission, capability, lifetime, or validation is uncertain. A fast result with an unproven dependency is not acceptable as an exact optimization.
- Small implementation change
- Clear maintained reference route
- May reduce worker CPU and audio underruns
- Easy to test with signal analysis and listening trials
- Expected numerical and audible differences
- Converter latency/input-consumption behavior may differ
- Could introduce aliasing at high frequencies
- Cannot be accepted solely from FPS improvement
Counters must be cheap, subsystem-owned, and snapshotted outside the hot loop. Record at least:
- resampler_input_frames
- resampler_output_frames
- converter_cpu_us
- callback_count
- audio_queue_depth
- audio_deadline_misses
- underruns
- effective_converter_type
A local reduction is not enough. Evidence must connect route reachability and removed work to fixed guest progress, CPU/GPU time where applicable, and p95/p99 behavior.
- Impulse and silence
- Low/high-frequency tones
- Log sweep and noise
- Speech and music clips
- Ratios 0.5, 1.0, 2.0 and changing pitch
- Loop, stop/start, starvation, snapshot restore
- Level-matched randomized listening comparison
Correctness runs may use validation layers, detailed comparisons, and fault injection. Performance acceptance must use optimized Release builds with matching symbols and minimal instrumentation.
Accept only as an optional approximation when it delivers repeatable CPU/deadline benefit and measured artifacts remain inside a predefined quality target.
Reject as a default or exact optimization if artifacts are audible/unbounded, buffering changes guest behavior, or the APU worker was not actually CPU-bound.
MCPX-APU-and-Audio · Performance-Unproven · Hot-Path-Audio-Mono-Resampling
PR pages may be linked as supporting evidence, but they are not substitutes for this reference.
DSP tooling guide and navigation updated November 2, 2026 for experimental PR #384, source 8f51d237. Capture/replay usage and limits.
The earlier wiki-wide review was published November 1, 2026. Emulator source: b7140848. Reviewed wiki content: 1d2b671. Current status · Release availability · Publication process.
- Home
- Current status
- Stable versus main
- Implemented mechanisms
- Controls and defaults
- Measured results and limits
- Complete change register
- System
- CPU and vCPU
- Memory and DMA
- Graphics / NV2A
- APU and audio
- Timing and timers
- Platform and I/O
- Hardware observations
- Fidelity boundaries
- Methodology
- PGR2 routes
- Debugging lag / hot paths
- Tools and commands
- DSP capture, replay and fuzzing
- HLE readiness and public XISO proof
- Concurrent DSP shadow and OpenAL proof
- DSP HLE operation inventory
- DSP HLE fix examples and testing
- Development
- Upstream shortlist
- Wiki maintenance
- Research / retired work
- Optimization catalog
- Hot-path shortcuts
- Researched experiments
- Unproven proposal directory
- PR lessons
- September26 snapshot
Repository · PRs · Issues