Files
JustOneCacophony/docs/rosella_filterbank.en.md
T
TheM14 0e98e91762 Add the captured Rosella filterbank and select it per bank
The Rosella path now chooses its filterbank. Bank 1 is the public bank
the reference implementation has always used (13 taps / 6 slots,
961 samples); bank 2 is the captured bank the reference headphone
renderer actually runs (11 taps / 3 slots, 448 samples).

- src/rosella_captured_filterbank.py implements the four half-steps in
  float64/complex128; the captured prototype, rotation and hybrid
  coefficients live in data/rosella_captured_kernels.npz
- src/rosella_bank.py owns the choice: both banks expose the same four
  stages, each with its own coefficients, history and latency
- RosellaBinauralRenderer takes filterbank= and derives the startup
  skip, the flush capacity and the report fields from it
- --rosella-filterbank 1|2 selects the bank, default 1; it is rejected
  for the SOFA and .jochrtf inputs instead of being ignored
- document both banks in docs/rosella_filterbank.{md,en.md}, and point
  the binaural docs, the data README and the options tables at it

Checked: the captured stages reproduce the reference vectors the C++
core checks (within 1e-10), an impulse returns at 961 and 448 samples,
and chunking, reset and bank independence hold for both.
2026-10-31 02:26:55 +08:00

4.2 KiB

Rosella filterbank

中文 · Back to README

The Rosella .personalized_headphone path can run either of two 64-QMF / 77-hybrid filterbanks: the shared public bank (the default) or the Rosella bank captured from the reference renderer. The SOFA and .jochrtf paths always use the public bank and never consult the selector.

Which bank runs

--rosella-filterbank 1|2 selects the bank of the Rosella path; the library form is RosellaBinauralRenderer(..., filterbank=...), where omitting the argument means 1.

Value Implementation Low-band hybrid High-band delay Latency
1 (default) rosella_filterbank.py 13 taps 6 slots 961 samples
2 rosella_captured_filterbank.py 11 taps 3 slots 448 samples

Both banks expose the same four stateful half-steps (QMF analysis, hybrid analysis, hybrid synthesis, QMF synthesis), so the choice switches the coefficients, the high-band delay, the history layout, the startup skip and the flush capacity together. The analysis and synthesis stages keep their own state and never share it. Any other value is rejected, and the option is an error when the binaural input is not a Rosella model: a SOFA or .jochrtf render must not silently ignore it.

Why the banks differ

The reference headphone renderer selects its analysis and synthesis callbacks during preparation, after initialization. Capturing only the initial callbacks identified the wrong filterbank variant. Runtime buffer captures gave these parameters:

Parameter Captured Rosella bank Public bank
QMF prototype 640 asymmetric coefficients polyphase reorder of the public 640-tap prototype
Low-band hybrid filter 11 taps 13 taps
High-band hybrid delay 3 slots 6 slots
Analysis/synthesis latency 448 samples 961 samples

The wrong variant produced a frequency-dependent room-tail error. With the captured room send as input, the existing room recursion already matched the reference, so the fix changes only the filterbank: not the room coefficients, the direct HRTF calculation, the phase mapping, or the output EQ. The public bank stayed as bank 1 so historical renders remain reproducible; the captured bank is bank 2.

Implementation

rosella_captured_filterbank.py reproduces the four half-steps of the captured bank in float64/complex128:

  • QMF analysis keeps a 9-slot ring history, reads (position + tap + 1) mod 10, and writes spectrum[2b] = F[b]/64, spectrum[2b+1] = conj(F[63-b])/64;
  • hybrid analysis keeps a 10-slot history, transforms the three low bands with 8/4/4-point transforms, reorders them with a fixed map, conjugates bands 1 and 3, and passes the high bands through delayed by 3 slots;
  • QMF synthesis keeps a 9-slot history and accumulates 10 prototype-matched lags, taking the imaginary part on odd lags.

data/rosella_captured_kernels.npz stores the captured prototype (float32[64,10]), rotation (complex64[64]) and hybrid coefficients (complex64[22]); they are promoted to float64/complex128 on load. The values are the ones the C++ core compiles in as src/hrtf/rosella_filterbank_tables.h and contain no personalized HRTF or room tuning.

The startup skip and the flush capacity both come from the selected bank (961 or 448 samples). .report.json records the actual choice in binaural_renderer_backend, as filterbank, filterbank_name and latency_compensated_samples.

Validation

The local regression script lives in tests/, which this repository does not track (like the rest of its local checks). It covers:

  • reference vectors for the four captured half-steps, the same samples the C++ core checks, generated by an independent NumPy implementation, to within 1e-10 per sample;
  • an impulse roundtrip peak at 961 and 448 samples for the two banks;
  • chunk invariance (including zero-length and unequal chunks) and reset();
  • independence: processing one bank never changes the other bank's state;
  • rejection of out-of-range values.

The public filterbank formulas and .jochrtf direction field described in docs/binaural.md are unchanged; the captured bank only affects the Rosella path.