The kernel copy follows the new kernel: the OAMD parser reads the trim element, the speaker renderer applies warp, per-object trim and the front-back balance, and the ADM writer carries them into the BWF metadata. joc_kernel.vcxproj lists the new speaker_trim translation unit and header, and the copied joc_version.h reports kernel 1.2.0 in the session log. The component keeps its playback settings, its speaker layout table and the side/rear channel swap; the stream interface is unchanged, so the decoder wrapper needs no edit. A stream whose OAMD asks for warp 2/3 now stops at the speaker renderer with JOC_ERR_NOT_SUPPORTED, as the reference refuses it. Builds Release-Static|x64 and |Win32. layout_table_test and channel_swap_test still pass; the render harness renders a warp-1 stream and reports the unimplemented mode for the warp-3 golden stream.
92 lines
3.7 KiB
C++
92 lines
3.7 KiB
C++
#include "speaker/speaker_step.h"
|
|
|
|
#include <cstdio>
|
|
|
|
namespace joc::speaker {
|
|
|
|
Status step(SpeakerStep* context, const std::vector<float>& objects16_planar,
|
|
const oamd::OamdUpdate* update, std::string* error) {
|
|
if (context == nullptr || context->handle == nullptr) {
|
|
return Status::fail(JOC_ERR_STATE, stage::kRender, "speaker renderer is not open");
|
|
}
|
|
if (objects16_planar.size() !=
|
|
static_cast<std::size_t>(JOC_OUTPUT_CHANNELS) * JOC_FRAME_SAMPLES) {
|
|
return Status::fail(JOC_ERR_INVALID_ARGUMENT, stage::kRender,
|
|
"objects16 must be [16][1536]");
|
|
}
|
|
context->interleaved.assign(static_cast<std::size_t>(JOC_FRAME_SAMPLES) * JOC_OUTPUT_CHANNELS,
|
|
0.0f);
|
|
for (std::size_t n = 0; n < JOC_FRAME_SAMPLES; ++n) {
|
|
for (std::size_t c = 0; c < JOC_OUTPUT_CHANNELS; ++c) {
|
|
context->interleaved[n * JOC_OUTPUT_CHANNELS + c] =
|
|
objects16_planar[c * JOC_FRAME_SAMPLES + n];
|
|
}
|
|
}
|
|
context->output.assign(
|
|
static_cast<std::size_t>(JOC_FRAME_SAMPLES) * context->layout.channel_count, 0.0);
|
|
|
|
context->last_had_payload = update != nullptr;
|
|
if (!context->controls_ready) {
|
|
const Status status =
|
|
parameters_from_oamd(nullptr, context->layout, &context->controls);
|
|
if (!status.ok()) {
|
|
if (error != nullptr) {
|
|
*error = status.message();
|
|
}
|
|
return status;
|
|
}
|
|
context->controls_ready = true;
|
|
}
|
|
std::uint32_t ramp = 0;
|
|
if (update != nullptr) {
|
|
if (update->has_trim) {
|
|
const Status status = parameters_from_oamd(&update->trim, context->layout,
|
|
&context->controls);
|
|
if (!status.ok()) {
|
|
if (error != nullptr) {
|
|
*error = status.message();
|
|
}
|
|
return status;
|
|
}
|
|
}
|
|
context->state.apply(*update);
|
|
ramp = update->ramp_duration_samples;
|
|
context->last_block_offset = update->block_offset_samples;
|
|
context->last_ramp_duration = update->ramp_duration_samples;
|
|
context->last_object_count = update->object_count;
|
|
}
|
|
|
|
std::uint16_t positions[oamd::kObjects][3] = {};
|
|
context->state.object_positions_q15(positions);
|
|
for (int object = 0; object < oamd::kObjects; ++object) {
|
|
if (!context->bed_override[object]) {
|
|
continue;
|
|
}
|
|
for (int axis = 0; axis < oamd::kAxes; ++axis) {
|
|
positions[object][axis] = context->bed_positions[object][axis];
|
|
}
|
|
}
|
|
// A frame without OAMD must not touch the gains at all (no event), otherwise a
|
|
// pending ramp would snap - matching the reference exactly.
|
|
const std::uint32_t event_count = context->last_had_payload ? 1u : 0u;
|
|
const std::uint32_t offset = context->metadata_offset;
|
|
const int result = ejoc_speaker_renderer_process(
|
|
context->handle, context->interleaved.data(), JOC_FRAME_SAMPLES, event_count,
|
|
event_count != 0u ? &offset : nullptr, event_count != 0u ? &ramp : nullptr,
|
|
event_count != 0u ? &positions[0][0] : nullptr, nullptr, nullptr, nullptr,
|
|
&context->controls, context->output.data());
|
|
if (result != 0) {
|
|
const char* message = ejoc_speaker_renderer_last_error(context->handle);
|
|
const std::string text =
|
|
"ejoc_speaker_renderer_process failed (" + std::to_string(result) + "): " +
|
|
(message != nullptr ? message : "unknown");
|
|
if (error != nullptr) {
|
|
*error = text;
|
|
}
|
|
return Status::fail(JOC_ERR_RENDER_FAILED, stage::kRender, text);
|
|
}
|
|
return Status::success();
|
|
}
|
|
|
|
} // namespace joc::speaker
|