The OAMD warp field is two bits wide; modes 2 and 3 now render instead of failing. For a 5.1, 5.1.2 or 5.1.4 target the speaker renderer pans objects in the corresponding 7.1, 7.1.2 or 7.1.4 intermediate layout and folds the rear pair into the target surround pair: mode 2 uses the PLIIx coefficients (sqrt(3)/2 and 1/2), mode 3 the Standard (Lo/Ro) coefficients (1 and 0). 4.0 gains a rear pair the same way, built from the 7.1 geometry without a centre or LFE channel. Layouts that already have both surround pairs, or none, render directly. The intermediate layout only changes geometry and panning. Trim configuration selection, both balance layers and the automatic position compensation stay with the final target layout, so 5.1.2 keeps configuration 4 and its compensation while panning on 7.1.2. Per-object bypass drops balance and trim but keeps the fold, and LFE still passes through. The folded object vector enters the existing gain ramp and mix unchanged; the public API and the ADM metadata do not change. parameters_from_oamd accepts the whole two-bit warp field and rejects values above 3; the renderer builds the fold matrices once per layout and keeps the 4.0 intermediate geometry internally. The bilingual notes describe the fold and the evaluation order, and the READMEs no longer call 2/3 unsupported. ctest covers PLIIx and Lo/Ro on 5.1, 5.1.2, 5.1.4 and 4.0, the target-layout calibration, bypass, LFE and the event path; speaker output over the shared objects16 stream is byte-identical to the reference for all layouts in both warp modes 2 and 3.
51 lines
2.0 KiB
C++
51 lines
2.0 KiB
C++
// Port of src/trim_balance.py.
|
|
|
|
#pragma once
|
|
|
|
#include <cstdint>
|
|
|
|
#include "eac3joc_core.h"
|
|
#include "foundation/status.h"
|
|
#include "oamd/oamd_parser.h"
|
|
#include "speaker/speaker_layout_lookup.h"
|
|
|
|
namespace joc::speaker {
|
|
|
|
// Front-back balance keeps a 5 percent wall band at each end unmapped.
|
|
inline constexpr double kBalanceWall = 0.05;
|
|
// bal3d_y is coded on a 1/16 grid, so a balance is quantised to that grid.
|
|
inline constexpr int kBalanceSteps = 16;
|
|
|
|
// Trim configuration a layout selects, from its surround and height counts:
|
|
//
|
|
// cfg = kappa_f(surrounds) + 3 * kappa_h(heights)
|
|
// kappa_f: 0 -> 0, 2..3 -> 1, otherwise 2
|
|
// kappa_h: 0 -> 0, 2 -> 1, otherwise 2
|
|
int trim_config_index(const LayoutInfo& layout);
|
|
|
|
// Converts OAMD calibration to the speaker controls of one layout. Warp 0
|
|
// renders directly, 1 scales the floor Y, and 2/3 render through an expanded
|
|
// surround layout before folding; the reserved global trim mode is reported as
|
|
// unsupported. A null trim selects warp 0 and automatic trim, or disabled trim
|
|
// for a layout that carries no trim semantics.
|
|
Status parameters_from_oamd(const oamd::OamdTrim* trim, const LayoutInfo& layout,
|
|
ejoc_speaker_controls* out);
|
|
|
|
// Reparameterises a front-back coordinate in [0, 1] by ``balance``: 0 is the
|
|
// front wall and 1 the back wall, and the two wall bands pass through
|
|
// unchanged.
|
|
double front_back_balance(double position, double balance);
|
|
|
|
// Blends the listener-plane and overhead balance by height: 0 at the listener
|
|
// plane, 1 at the top layer.
|
|
double apply_balance(double position, double height, double listener, double overhead);
|
|
|
|
// Position-dependent object trim at the balanced original Y. Surround fades
|
|
// in with Y and out towards Z=1, height fades in with Z, and the centre trim is
|
|
// local to the front-centre region. The scalar multiplies the object's whole
|
|
// panning vector before accumulation.
|
|
double explicit_position_gain(const ejoc_speaker_controls& controls, double x, double y,
|
|
double z);
|
|
|
|
} // namespace joc::speaker
|