Keep only the Rosella and .jochrtf binaural paths
ci / ubuntu-latest (push) Failing after 18s
ci / macos-latest (push) Canceled after 0s
ci / windows-latest (push) Canceled after 0s
ci / release (push) Canceled after 0s

The kernel renders two inputs now: the Rosella .personalized_headphone model and
an already compiled .jochrtf field. The SOFA reader, its compile cache and the
field fit leave the kernel, and the direct SOFA runtime built on them goes with
them: the point-source distance reference, the shoebox image-source model, the
generated FDN tables and the asset archives are all gone. Fitting a SOFA into a
.jochrtf belongs to the offline toolchain.

The compiled-field runtime is the one that predates that work: 64-QMF analysis,
77 hybrid bands, per-object path delays and the project room (image sources plus
the shared unitary FDN) computed in code. It keeps its behaviour and takes the
.jochrtf name throughout: sofa_binaural_renderer.cpp -> jochrtf_renderer.cpp,
binaural_runtime.* -> jochrtf_runtime.*, SofaBinauralRuntime -> JochrtfRuntime,
ejoc_sofa_binaural_* -> ejoc_jochrtf_*.

The room becomes a switch. --jochrtf-room on|off (default on) drives the
enable_early_reflections and enable_late_room flags of the existing room
configuration; off renders the field's direct binaural sound only.
joc_task_config and joc_stream_config drop hrtf_sofa_path, hrtf_cache_dir,
hrtf_cache_policy and hrtf_radius_m, and gain jochrtf_room. The CLI no longer
accepts --sofa-hrtf, --hrtf-cache-policy, --hrtf-cache-dir or --hrtf-radius-m;
without an explicit input the renderer uses HRTF/binaural.personalized_headphone,
and a .jochrtf has to be named through --compiled-hrtf-cache. The SOFA-only unit
tests go with the reader.

Rosella parsing, filterbank, room and timing are untouched. Both .jochrtf modes
reproduce the Python reference sample for sample, and ctest passes.
This commit is contained in:
TheM14 committed 2026-11-01 19:19:00 +08:00
1 parent 29f4f83c29
commit 20f2e77664
46 files changed
+1180 -8377

No files matched your search

+6 -69
View File
@@ -7,9 +7,7 @@
#include "adm/adm_metadata.h"
#include "foundation/status.h"
#include "hrtf/jochrtf.h"
#include "binaural/direct_sofa_runtime.h"
#include "hrtf/rosella_model.h"
#include "hrtf/sofa_cache.h"
#include "joc_bitstream/bed_layout_map.h"
#include "joc_bitstream/joc_parser.h"
#include "joc_core/objects16.h"
@@ -65,9 +63,6 @@ void Stream::reset_state() {
if (binaural_ready_) {
binaural_.reset();
}
if (sofa_direct_ready_) {
sofa_direct_.reset();
}
if (rosella_ready_) {
rosella_.reset();
}
@@ -147,30 +142,6 @@ Status Stream::create(const Config& config) {
hrtf::Field field;
hrtf::Kernels kernels;
Status status = Status::success();
if (!config_.hrtf_sofa_path.empty()) {
// A SOFA renders from its full HRIRs; the .jochrtf stays the
// compiled input of hrtf_path.
binaural::DirectSofaOptions options;
options.mode = config_.binaural_mode == JOC_BINAURAL_NEAR
? "near"
: (config_.binaural_mode == JOC_BINAURAL_FAR ? "far" : "mid");
options.has_reference_distance = config_.source_reference_distance_m > 0.0;
options.reference_distance_m = config_.source_reference_distance_m;
options.has_shell_radius = config_.hrtf_radius_m > 0.0;
options.shell_radius_m = config_.hrtf_radius_m;
options.sofa_room = config_.sofa_room != 0u;
options.room_preset = config_.sofa_room_preset;
options.object_delay_samples = config_.object_delay_samples;
options.tail_seconds = config_.tail_seconds;
status = sofa_direct_.open(config_.hrtf_sofa_path, options);
if (status.ok()) {
sofa_direct_ready_ = true;
output_channels_ = 2;
return Status::success();
}
return Status::fail(status.code(), stage::kRender,
"binaural setup failed: " + status.message());
}
status = hrtf::load_jochrtf(config_.hrtf_path, &field);
if (status.ok()) {
status = config_.kernels_path.empty()
@@ -184,7 +155,10 @@ Status Stream::create(const Config& config) {
profile = binaural::Profile::Far;
}
if (status.ok()) {
status = binaural_.open(field, kernels, profile);
binaural::RoomConstants room;
room.enable_early_reflections = config_.jochrtf_room ? 1u : 0u;
room.enable_late_room = room.enable_early_reflections;
status = binaural_.open(field, kernels, profile, room);
}
if (!status.ok()) {
return status;
@@ -222,9 +196,6 @@ void Stream::apply_bed_positions(const FrameMetadata& entry) {
if (binaural_ready_) {
binaural_.set_fixed_position(static_cast<int>(slot) + 1, xyz);
}
if (sofa_direct_ready_) {
sofa_direct_.set_fixed_position(static_cast<int>(slot) + 1, xyz);
}
if (rosella_ready_) {
rosella_.set_fixed_position(static_cast<int>(slot) + 1, xyz);
}
@@ -233,8 +204,8 @@ void Stream::apply_bed_positions(const FrameMetadata& entry) {
continue;
}
std::uint16_t q15[3] = {0, 0, 0};
// bed 声道是固定位置的源:方位由声道标签决定,与目标布局无关。
if (!::joc::joc::bed_channel_q15(channel, q15)) {
if (!::joc::joc::layout_bed_anchor(speaker_.layout.out_ch_config, channel, q15) &&
!::joc::joc::bed_channel_q15(channel, q15)) {
continue;
}
speaker_.bed_override[slot] = true;
@@ -623,27 +594,6 @@ Status Stream::render_objects16(const std::vector<float>& objects16) {
if (rosella_ready_) {
return render_rosella_objects16(objects16);
}
if (sofa_direct_ready_) {
const Status submitted =
sofa_direct_.submit_frame(objects16.data(),
pending_metadata_.has_update
? &pending_metadata_.update
: nullptr,
static_cast<std::int64_t>(info_.frames_out),
pending_metadata_.outer_offset,
static_cast<std::int64_t>(config_.object_delay_samples));
if (!submitted.ok()) {
return submitted;
}
sofa_direct_.take_output(&produced_);
output_.reserve(output_.size() + produced_.size());
for (const double value : produced_) {
output_.push_back(static_cast<float>(value));
}
info_.frames_out++;
info_.samples_out += produced_.size() / 2u;
return Status::success();
}
const Status submitted =
binaural_.submit_frame(objects16.data(),
@@ -758,19 +708,6 @@ Status Stream::flush() {
if (!objects.ok()) {
return objects;
}
if (sofa_direct_ready_) {
std::vector<double> tail;
const Status drained =
sofa_direct_.finish(sofa_direct_.finish_capacity(config_.tail_seconds), &tail);
if (!drained.ok()) {
return drained;
}
output_.reserve(output_.size() + tail.size());
for (const double value : tail) {
output_.push_back(static_cast<float>(value));
}
info_.samples_out += tail.size() / 2u;
}
if (binaural_ready_) {
std::vector<double> tail;
const Status drained =