diff --git a/src/binaural/binaural_runtime.cpp b/src/binaural/binaural_runtime.cpp index deb3ac1..a25ace0 100644 --- a/src/binaural/binaural_runtime.cpp +++ b/src/binaural/binaural_runtime.cpp @@ -205,7 +205,7 @@ Status SofaBinauralRuntime::reset() { if (ejoc_sofa_binaural_reset(handle_) != 0) { return Status::fail(JOC_ERR_RENDER_FAILED, stage::kRender, "sofa reset failed"); } - timeline_ = timeline::OamdPositionTimeline(); + timeline_.reset(); output_.clear(); staged_ = 0; input_samples_ = 0; diff --git a/src/hrtf/rosella_renderer.cpp b/src/hrtf/rosella_renderer.cpp index 8a08839..87e73d1 100644 --- a/src/hrtf/rosella_renderer.cpp +++ b/src/hrtf/rosella_renderer.cpp @@ -1329,7 +1329,7 @@ Status RosellaRuntime::reset() { impl_->raw_output_samples = 0u; impl_->metadata_block_updates = 0u; impl_->finished = false; - impl_->timeline = timeline::OamdPositionTimeline(timeline::kTimelineObjects); + impl_->timeline.reset(); return Status::success(); } @@ -1355,4 +1355,8 @@ std::uint64_t RosellaRuntime::metadata_block_updates() const { } const timeline::OamdPositionTimeline& RosellaRuntime::timeline() const { return impl_->timeline; } +void RosellaRuntime::set_fixed_position(int object_index, const double position[3]) { + impl_->timeline.set_fixed_position(object_index, position); +} + } // namespace joc::hrtf diff --git a/src/hrtf/rosella_renderer.h b/src/hrtf/rosella_renderer.h index 7922df7..c822e3a 100644 --- a/src/hrtf/rosella_renderer.h +++ b/src/hrtf/rosella_renderer.h @@ -56,6 +56,9 @@ public: std::uint64_t metadata_block_updates() const; const timeline::OamdPositionTimeline& timeline() const; + // bed 声道是固定通道:OAMD 不给位置,方位由声明的 bed 布局给出。 + void set_fixed_position(int object_index, const double position[3]); + private: struct Impl; std::unique_ptr impl_; diff --git a/src/stream/stream.cpp b/src/stream/stream.cpp index c00ba2f..f2a468a 100644 --- a/src/stream/stream.cpp +++ b/src/stream/stream.cpp @@ -206,8 +206,13 @@ void Stream::apply_bed_positions(const FrameMetadata& entry) { ++slot) { const ::joc::joc::BedChannel channel = bed.channels[slot]; double xyz[3] = {0.0, 0.0, 0.0}; - if (binaural_ready_ && ::joc::joc::bed_channel_adm_position(channel, xyz)) { - binaural_.set_fixed_position(static_cast(slot) + 1, xyz); + if (::joc::joc::bed_channel_adm_position(channel, xyz)) { + if (binaural_ready_) { + binaural_.set_fixed_position(static_cast(slot) + 1, xyz); + } + if (rosella_ready_) { + rosella_.set_fixed_position(static_cast(slot) + 1, xyz); + } } if (!speaker_enabled_) { continue; diff --git a/src/task/task.cpp b/src/task/task.cpp index 247eafb..6ec5210 100644 --- a/src/task/task.cpp +++ b/src/task/task.cpp @@ -1780,6 +1780,10 @@ Status run(const joc_task_config& raw, const joc_event_sink* sink, joc_task_resu binaural.set_fixed_position( static_cast(slot) + 1, xyz); } + if (rosella_enabled) { + rosella.set_fixed_position( + static_cast(slot) + 1, xyz); + } } if (!speaker_enabled) { continue; diff --git a/src/timeline/position_timeline.h b/src/timeline/position_timeline.h index cf87d39..55e7763 100644 --- a/src/timeline/position_timeline.h +++ b/src/timeline/position_timeline.h @@ -60,6 +60,23 @@ public: fixed_xyz_[object_index - 1][2] = position[2]; } + // Drops the OAMD state and every transition but keeps the fixed bed positions: + // they describe the content, not the playback position. + void reset() { + state_.reset(); + for (int index = 0; index < kTimelineObjects; ++index) { + tracks_[index] = ObjectPositionTrack(); + has_previous_[index] = false; + for (int axis = 0; axis < 3; ++axis) { + previous_targets_[index][axis] = 0.0; + } + } + initialized_ = false; + payload_count_ = 0; + transition_count_ = 0; + last_coded_event_sample_ = -1; + } + std::uint64_t payload_count() const { return payload_count_; } std::uint64_t transition_count() const { return transition_count_; } bool initialized() const { return initialized_; }