Add --rosella-filterbank and restore the public bank as the default
ci / ubuntu-latest (push) Failing after 16s
ci / macos-latest (push) Canceled after 0s
ci / windows-latest (push) Canceled after 0s
ci / release (push) Canceled after 0s

The Rosella path picks its analysis and synthesis bank instead of
hard-coding one. Bank 1 is the shared public bank the renderer used
before the captured variant landed: 13-tap hybrid filters, the 6-slot
high-band delay and 961 samples of latency. Bank 2 is the captured
Rosella bank: 11-tap filters, the 3-slot delay and 448 samples. Both
keep their own coefficients, histories and flush behaviour.

- Drive either bank through one RosellaBank interface, and derive the
  startup skip and the flush capacity from the selected bank
- Add joc_rosella_filterbank to joc_task_config and joc_stream_config
  by replacing the reserved words (struct sizes unchanged, config
  version 3 -> 4)
- Reject an out-of-range value and bank 2 without a Rosella model
  instead of silently falling back
- Expose --rosella-filterbank 1|2 in the CLI with bank 1 as default,
  and reject it outside the personalized headphone path
- Cover bank identity, chunking, reset and per-bank latency in tests
- Document both banks, the selector and the CLI help

Renders of --rosella-filterbank 1 (and the default) match the pre-merge
reference byte for byte; --rosella-filterbank 2 matches the PR #3
reference byte for byte.
This commit is contained in:
TheM14 committed 2026-10-31 01:11:44 +08:00
1 parent 6674cb5386
commit 34a722f56a
19 files changed
+477 -34

No files matched your search

+89
View File
@@ -0,0 +1,89 @@
#include "hrtf/rosella_bank.h"
#include <utility>
#include "hrtf/rosella_filterbank.h"
namespace joc::hrtf {
namespace {
// The shared public bank. It is also what the SOFA field compiler runs, and it
// is the bank the Rosella renderer used before the Rosella-specific one was
// captured.
class PublicBank final : public RosellaBank {
public:
explicit PublicBank(std::size_t channels) : bank_(builtin_kernels(), channels) {}
void reset() override { bank_.reset(); }
void analyze_qmf(const std::vector<double>& hops, std::size_t slots,
std::vector<Complex>* qmf) override {
bank_.analyze_qmf(hops, slots, qmf);
}
void analyze_hybrid(const std::vector<Complex>& qmf, std::size_t slots,
std::vector<Complex>* hybrid) override {
bank_.analyze_hybrid(qmf, slots, hybrid);
}
void synthesize_hybrid(const std::vector<Complex>& hybrid, std::size_t slots,
std::vector<Complex>* qmf) override {
bank_.synthesize_hybrid(hybrid, slots, qmf);
}
void synthesize_qmf(const std::vector<Complex>& qmf, std::size_t slots,
std::vector<double>* hops) override {
bank_.synthesize_qmf(qmf, slots, hops);
}
private:
PublicFilterbank bank_;
};
// The bank captured from the Rosella headphone renderer.
class CapturedBank final : public RosellaBank {
public:
explicit CapturedBank(std::size_t channels) : bank_(channels) {}
void reset() override { bank_.reset(); }
void analyze_qmf(const std::vector<double>& hops, std::size_t slots,
std::vector<Complex>* qmf) override {
bank_.analyze_qmf(hops, slots, qmf);
}
void analyze_hybrid(const std::vector<Complex>& qmf, std::size_t slots,
std::vector<Complex>* hybrid) override {
bank_.analyze_hybrid(qmf, slots, hybrid);
}
void synthesize_hybrid(const std::vector<Complex>& hybrid, std::size_t slots,
std::vector<Complex>* qmf) override {
bank_.synthesize_hybrid(hybrid, slots, qmf);
}
void synthesize_qmf(const std::vector<Complex>& qmf, std::size_t slots,
std::vector<double>* hops) override {
bank_.synthesize_qmf(qmf, slots, hops);
}
private:
RosellaFilterbank bank_;
};
} // namespace
std::uint32_t rosella_bank_latency(RosellaBankKind kind) {
return kind == RosellaBankKind::Captured
? static_cast<std::uint32_t>(RosellaFilterbank::kLatencySamples)
: static_cast<std::uint32_t>(kLatencySamples);
}
std::unique_ptr<RosellaBank> RosellaBank::create(RosellaBankKind kind, std::size_t channels) {
if (kind == RosellaBankKind::Captured) {
return std::make_unique<CapturedBank>(channels);
}
return std::make_unique<PublicBank>(channels);
}
} // namespace joc::hrtf