ADM ↔ Atmos bridging: iclforge::adm¶
iclforge/adm/bridge.hpp, iclforge/adm/coordinates.hpp, iclforge/adm/iab_bridge.hpp, a part of
iclforge::adm. Two directions live here:
- Read: maps the ADM object graph
iclforge::admparses from a BW64/ADM master ontoiclforge::ac3::oba::AtmosEncoder's input shape — oneiclforge::objects::oba::ObjectPathplus one mono PCM span per bed speaker feed or dynamic object, ready to driveencode_frame()in a loop. Driven end to end byforge atmos-admandexamples/encode_adm.cpp.build_iab()does the same for a parsed IAB sequence (below), driven byforge atmos-iab. Withcodec=ac4those two commands hand the same result to the AC-4 object encoder instead (AC-4). - Write ("JOC → ADM BWF writer"): the mirror image — maps a decoded programme's own bed/object
PCM and object automation onto an
iclforge::adm::AdmDocument, ready foriclforge::adm::write_bw64(). The programme is aniclforge::ac3::Eac3Decoder's (its OAMD automation) or aniclforge::ac4::Decoder's (each object's Annex F properties and updates). Driven end to end byforge decode ... adm_out.
Both directions are the same "one place iclforge::adm and iclforge::ac3/iclforge::oba are allowed to meet"
seam this module has always been, see Commands for both commands.
Opt-in, with the parser. The bridge is built with the rest of iclforge::adm when
ICLFORGE_BUILD_ADM=ON; there is no option of its own. See ADM / BW64 reading for the
exact CMake invocation.
const auto document = iclforge::adm::parse_bw64(path);
if (!document) { /* ... */ }
const auto bridged = iclforge::adm::build(*document);
if (!bridged) {
fmt::printf("build failed: %.*s\n",
static_cast<int>(iclforge::adm::describe(bridged.error()).size()),
iclforge::adm::describe(bridged.error()).data());
return 1;
}
// The LFE bed channel(s) are not objects (see below): the encoder is built for the others, and the LFE
// goes in as its own span.
iclforge::ac3::oba::AtmosEncoder encoder{{.bitrate_kbps = 448}, static_cast<int>(bridged->object_slot_count())};
// Per frame: slice bridged->pcm[i] to the frame's sample range for each i with !bridged->is_lfe[i],
// evaluate iclforge::objects::oba::evaluate_placements(bridged->paths, t) and take those channels'
// placements, and call encoder.encode_frame(objects, placement, lfe) with the LFE channel's slice as
// `lfe` (empty when the master has none). examples/encode_adm.cpp does exactly this.
Where it lives¶
The bridge is a part of iclforge::adm (libs/adm/), which stays codec-blind: its headers name the
object model's types (iclforge::objects::oba::ObjectPath, from iclforge::objects) and the IAB reader's
(iclforge::iab), and iclforge::adm links both publicly, never iclforge::ac3. libs/ac3 is built
by every configuration and cannot depend on the opt-in, Boost-requiring iclforge::adm, which is why
the bridge stops at the object model the Atmos encoder takes. Like the rest of iclforge::adm (see
ADM / BW64 reading), it is part of the installed find_package(iclforge) package, shared
only: iclforge::adm_shared and the bare iclforge::adm alias, no _static variant.
build_iab() (iclforge/adm/iab_bridge.hpp) maps a whole parsed iclforge::iab::IABitstreamFrame
sequence — from either of iclforge::iab's two readers (libs/iab: a bare elementary .iab
file or a real MXF Track File) — onto this same ObjectPath layer, driven end to end by forge
atmos-iab (see Commands). iclforge::adm::AdmDocument and iclforge::iab::
IABitstreamFrame are therefore both input shapes here, sharing the coordinate-conversion and
ObjectPath-construction logic this module exists to keep independent of either container's own
parsing — see "Bridging IAB" below for exactly what differs between the two.
What gets mapped¶
- Bed vs. dynamic object is decided by the
TypeDefinitionof theaudioObject's own resolvedaudioPackFormat(s) —AudioObjectitself carries no type of its own.kDirectSpeakersbecomes a bed speaker feed;kObjectsbecomes a dynamic object.kMatrix,kHoa,kBinaural,kUserCustom,kUnknown, a nestedaudioPackFormat, or an object whose several packs disagree with each other all fail clearly withBridgeError::kUnsupportedTyperather than being silently mishandled — none of them map ontoAtmosEncoder's plain position+gain+lfe_send object model without a design of their own, which the bridge does not have. AtmosEncoderhas no separate bed-feeding method — its constructor takes a plain object count andencode_frame()takes one flat span of objects plus one flat span of placements, nothing in that signature distinguishing a bed channel from a dynamic object — so a bed channel is represented as an object with an unmoving, pinned placement, the only way the API allows it, the same convention every existing caller (forge'srun_atmos_encode, the GUI'sencodeObjects) already uses.- The LFE is not an object. A bed channel whose
speakerLabelidentifies it as the LFE (BS.2076-2 Table 12:LFE,LFE1,LFE2) is marked inBridgeResult::is_lfe, and a caller hands its PCM toAtmosEncoder::encode_frame(objects, placement, lfe)as thelfespan and builds the encoder for the other channels only. It cannot ride an object: an object reaches the LFE aslfe_send * gain, and the same gain pans it into the speakers, so no path can send to the LFE and nowhere else — which is why the channel's own path is inert (gain 0 /lfe_send1: fed as an object it is silent, not bass in a speaker). The LFE therefore takes none of the fifteen object slots;BridgeResult::object_slot_count()is the number that does. A stream has one LFE, so a dual-LFE bed's two channels are added together by the caller (forge atmos-admdoes, and says so). - Position/gain automation —
build_channel_path()walks a channel'saudioBlockFormatsequence into oneiclforge::objects::oba::ObjectPath, implementing BS.2076-2 §10.3'sjumpPosition/interpolationLengthstate machine:jumpPosition = 0interpolates continuously across a block's entire duration;jumpPosition = 1jumps (or ramps overinterpolationLength, when given) at the block's start and then holds for the rest of it; the first block in a sequence always holds across its own span regardless of its ownjumpPosition. This was checked directly against the standard's own text and worked Figs. 7–10 — an earlier reading of just this behaviour's name ("hold vs. glide") had the two cases backwards relative to what §10.3 actually says, corrected once the real clause text was read rather than assumed. - Coordinate conversion (
coordinates.hpp) — BS.2076-2 §8's polar (azimuth/elevation/distance, positive azimuth to the left, positive elevation up) and Cartesian (X right-positive, Y front-positive, Z top-positive,[-1, 1]unit cube) conventions, both converted toiclforge::objects::oba::Position's room-anchored[0, 1]/[0, 1]/[-1, 1]one. Checked against the standard's own axis-direction text at the cardinal points, and empirically against this project's own existing ring-position constants (libs/ac3/tests/oba/test_atmos_motion.cpp'skL/kR/kSR) — the BS.2076-2M+030/M-030/M-110speaker-label azimuths reproduce those exact values through this conversion. - Absolute timeline time for a channel's automation is
object.start_s + block.rtime_s— two levels, not three. BS.2076-2 Table 24 definesaudioObject's ownstartas relative to the programme's start directly, and §5.6.7 confirms this holds through nesting (a nested object's ownstartis never added to its parent's).audioProgramme's own optionalstart/end(Table 37) is a separate video-alignment concept, not a third term in this sum — andiclforge::adm::AudioProgrammedoes not even carry astart_sfield to add. - Channel resolution walks
audioProgramme→audioContent→audioObject(recursing through nestedaudioObjects, with a cycle guard per §5.6.7's own prohibition on reference loops) →audioPackFormat→audioChannelFormat, then resolves each channel'saudioTrackUIDRefthrough<chna>to its physical PCM channel inAdmDocument::audio.
Object extent and channel lock¶
width/height/depth map straight through to iclforge::objects::oba::ObjectSize on every keyframe this
bridge produces. BS.2076-2 Table 15/16/17's extents and TS 103 420 §5.6.1.2's
object_width/object_depth/object_height are the same normalized [0, 1] quantity on the
same three axes, so this is a rename rather than a conversion, and §10.3's interpolation of them
between blocks is exactly what KeyframePath already does with position and gain.
channelLock maps to ObjectPlacement::snap — BS.2076-2 §10.2 and TS 103 420 §5.6.1.5.1
("Channel lock") describe the same instruction to a renderer: place the object at its nearest
speaker instead of panning between speakers. maxDistance has no image: b_object_snap is one
bit with no distance to condition it on, so a conditioned channelLock becomes an unconditioned
snap, which is the closest thing the syntax can say.
Both reach the bitstream and stop there. AtmosEncoder still folds every object into its 5.1 bed
as a point source, for the reason
Spatial & Atmos objects gives: spreading
an object in the downmix would have the receiving renderer spread it a second time.
What does not get mapped¶
diffuse(§10.1) is parsed byiclforge::admand dropped. It is a direct-versus-diffuse balance, not an extent; OAMD has no field for it, and folding it intoobject_sizewould misreport a decorrelation instruction as a physical size.objectDivergence's range (§10.5):azimuthRangeandpositionRangesay where the two objects go; OAMD has no field for them (§5.2.7 spreads the energy along X by its own rule). The divergence value is carried, see below.headLockedhas no OAMD field.- A conditioned
channelLock:maxDistanceis dropped and the lock applies unconditionally, sinceb_object_snapis one bit. - A
zoneExclusionthat is not a Table B.18 preset (see below). - Matrix, HOA, Binaural and User Custom packs are refused with
BridgeError::kUnsupportedType, by design rather than as a gap:AtmosEncodertakes mono objects with a position, and a Matrix pack is a coefficient mix, HOA has no position, and Binaural is already rendered. The parser reads all three (a Matrix block's coefficients and its pack's encode/decode/input/output references included, see ADM / BW64 reading) and the writer writes them; the bridge does not apply them. A Matrix decode would be the sum of each input channel times its coefficient, with phase and delay and variables the standard leaves to the renderer, and HOA would need a loudspeaker decoder chosen and tuned: both would be written without a file from another tool or a reference renderer to check them against, so they are refused rather than guessed.
build() does not drop these silently. BridgeResult::unmapped[i] lists, for channel i, each feature
above that its blocks use, and forge atmos-adm prints one warning: line per such channel.
Divergence and screen reference¶
Both reach the bitstream through ObjectPlacement and the OAMD writer, which now writes
b_object_use_screen_ref with its screen_factor_bits and depth_factor_idx (§5.5.11) and the
extended_object_element with its obj_div_block (§5.5.13, §5.5.14). The encoder's own bed render does
not act on either, as for size and zones.
objectDivergence's value (0 to 1) becomesObjectPlacement::divergence, and the writer sends the nearest value of Table 42: a 2-bit index (object_div_mode0) when the nearest is one of Table 41's four values,object_div_mode1 when it repeats the previous block's, and the 6-bit code (object_div_mode2) otherwise. A value that rounds to no divergence sendsb_object_divergence0. TS 103 420 Annex B has no row for it, so the correspondence is a reading: ADM's value and OAMD'sobject_divergenceare both the share of the energy moved into two spread objects (§5.2.7).libs/adm/ERRATA.mdrecords it.screenRefbecomesscreen_referencewithscreen_factor1 anddepth_factor1, since ADM's flag is all or nothing. The reference screen of Annex B.2.1.3 (audioProgrammeReferenceScreen, sized by aref_screen_ratiothe OAMD syntax does not carry) is not read or written; the renderer's screen applies.- The write direction maps back: a divergence above zero becomes
objectDivergence, and a screen reference withscreen_factorof one half or more becomesscreenRef. A smaller factor reads as room-anchored, because ADM cannot say how far.
Zone constraints¶
zoneExclusion maps both ways through TS 103 420 Annex B.2.6 (Tables B.18 and B.19), since OAMD's
zone_constraints_idx and b_enable_elevation are exactly the presets that table lists:
ADM zone elements (excluded) |
ZoneConstraint |
|---|---|
ZM1 |
kBackExcluded |
ZM2_Left, ZM2_Right |
kSideExcluded |
ZM3_ScreenLeft, ZM3_SideLeft, ZM3_ScreenRight, ZM3_SideRight |
kCentreAndBackOnly |
ZM4 |
kScreenOnly |
ZM5 |
kSurroundOnly |
ZU and ZB together |
enable_elevation = false |
A zone is recognised by its label, or by its six Cartesian bounds matching Table B.19 within
kZoneBoundTolerance (0.05). Anything else — an arbitrary cuboid, only one of ZU and ZB, two
horizontal presets at once — keeps whatever part did map, and is reported in unmapped.
adm_zone_exclusion_to_constraint() and constraint_to_adm_zone_exclusion() in coordinates.hpp are
the two directions. write() emits the zone of every OAMD update as a zoneExclusion, with both
label and bounds, so a reader using either recognises it. Table B.19 prints ZM3_SideRight's minX as
0.5611; the mirrored ZM3_SideLeft has -0.51611 and every other pair is symmetric, so 0.51611 is
written (see libs/adm/ERRATA.md).
Zone and elevation are discrete decisions, so a path holds the earlier block's value until the next
block's keyframe, as it does for snap.
ObjectPlacement::zone and ObjectPlacement::enable_elevation exist and are transmitted — a
caller constructing paths directly can set them; it is only the ADM-derived route that leaves them
at their defaults.
Bridging IAB¶
build_iab(std::span<const iclforge::iab::IABitstreamFrame> frames) maps a whole parsed Immersive Audio
Bitstream sequence — iclforge::iab::parse_iabitstream() or iclforge::iab::parse_mxf_iab()'s own return value,
unmodified — onto the identical destination shape build() produces for ADM, in a new header,
iclforge/adm/iab_bridge.hpp.
IAB has no whole-file object graph the way ADM's audioProgramme → audioContent → audioObject tree
does — it is a flat sequence of self-contained IaFrames, each carrying its own Bed/Object metadata
scoped to that frame alone (§9.2/§9.4). build_iab() therefore does its own two-pass walk: an
identity pass unions every unconditionally-Activated top-level Bed channel/Object across every
frame, keyed by §10.3.1's own MetaID ("the ID that allows the system to track metadata information
between audio frames" — for a Bed channel, combined with its own ChannelID per §10.3.5's note on
ST 2098-1's Channel Identifier function) — fixing AtmosEncoder's channel count and order once, the
same role collect_leaf_objects() plays for build()'s own ADM walk. A timeline pass then builds
one ObjectPath per identity spanning the whole sequence: a frame where that identity is absent, or
only conditionally Activated (an alternate-target-environment mix per §10.3.2/§10.5.1's own
Activation/UseCase fields — the same "pick the one primary set" choice build() already makes among
several audioProgrammes), contributes no new keyframe — silence-filled PCM, the timeline simply
holds/interpolates through the gap — rather than shrinking the channel count.
Only top-level IaFrame::beds/objects are walked — nested BedDefinition/BedRemap/
ObjectDefinition/ObjectZoneDefinition19 children (§9 Table 4) are deliberately not recursed
into: Annex C.1's own nesting allowance exists for alternate/derived submixes, not the primary
content this bridge selects one of.
Bed channels have no per-block position data at all (unlike ADM's audioBlockFormat sequence)
— a Bed channel's own ChannelID (§10.3.5 Table 19) is a closed, physical-position vocabulary
resolved once via iclforge::objects::oba::bed_label_position(), the same pinned-placement convention bed
channels already get from ADM's speakerLabel; only ChannelGain (§10.3.8) can legitimately vary
frame to frame, so a Bed channel's timeline is one keyframe per frame it is present in. An LFE Bed
channel (ChannelID 0xD, or 0x86/0x87's BS.2051-2 LFE1/LFE2 aliases) is not an object, for
the reason given for ADM above: is_lfe marks it, its PCM is for encode_frame's lfe span, and
its own path is the same inert gain 0 / lfe_send 1.
Every channel Table 19 defines has a position. A bed channel reaches the encode as a pinned
position, so what the bridge needs from its ChannelID is where that loudspeaker is. The codes with an
iclforge::objects::oba::BedLabel take bed_label_position(); "Side Surround" (0x5/0x9) sits where
"Surround" (0x6/0xA) does, since a bed has one or the other, which is what lets the usual cinema bed
(L, C, R, Lss, Rss, Lrs, Rrs, LFE, Lts, Rts) through. The rest have no BedLabel and are placed from the
typical locations ST 2098-5 Annex B describes. That annex is informative and a cinema's own layout
varies, so these are this bridge's readings (libs/adm/ERRATA.md), the same status as the position
conversion below:
| ChannelID | Channel | Position (x, y, z) |
|---|---|---|
0x1 / 0x3 |
Left / Right Center | (0.25, 0, 0) / (0.75, 0, 0): between the screen's left and centre loudspeakers, and centre and right |
0xB / 0xC |
Left / Right Top Surround | (0.25, 0.5, 1) / (0.75, 0.5, 1): the ceiling, laterally between the centre and left (right) screen loudspeakers |
0x10 |
Center Height | (0.5, 0, 1): behind the screen, above the centre loudspeaker |
0x11 / 0x12 |
Left / Right Surround Height | (0 or 1, 2/3, 1): the side and rear near the ceiling, from a third of the way back |
0x13 / 0x14 |
Left / Right Side Surround Height | (0 or 1, 0.5, 1): above the side surrounds |
0x15 / 0x16 |
Left / Right Rear Surround Height | (0 or 1, 1, 1): above the rear surrounds |
0x17 |
Top Surround | (0.5, 0.5, 1): the ceiling over the middle of the room |
The reserved codes (0x18-0x7F, and everything above 0x89) have no meaning and are refused,
BridgeError::kUnsupportedIabChannel.
Position conversion needs no formula at all. iab_position_to_room() (coordinates.hpp) is a
direct passthrough: §11.1's x/y (0 left/front wall to 1 right/back wall) already match
iclforge::objects::oba::Position's own convention exactly, and its z — "0 corresponds to a horizontal plane
at... the height of the main screen Loudspeakers... 1 corresponds to the ceiling" — anchors its
zero at the same screen/ear-height reference oba::Position's own z = 0 does, just never
expressing anything below it (IAB's [0, 1] is the upper half of oba::Position::z's own
[-1 floor, +1 ceiling] range). This is this bridge's own judgement call — no clause states the
two specs share a reference height — the same status the ADM conversion's own one undocumented gap
has above.
Spread (§10.5.15-17) becomes ObjectSize: iab_spread_to_size() takes the spread on x, y and z as
width, depth and height. ST 2098-2 defines the spread as the extent of the object, in fractions of
the unit cube, and TS 103 420 §5.6.1.2 codes object_width, object_depth and object_height as
normalized [0, 1] extents on the same axes. No clause states that the two scales are the same;
this is the same rename the ADM bridge makes. A point source (OBJECT_SPREAD_NONE) is size zero.
Zone control becomes ZoneConstraint and b_enable_elevation. iab_zones_to_constraint() takes
the nine gains of §10.5.11-14 Table 24 and iab_zones19_to_constraint() the nineteen of an
ObjectZoneDefinition19 child (§10.6 Table 28), which replaces the nine when present. A gain of 0.5
or more counts as the zone being included, because TS 103 420 Table 20 includes or excludes a zone
and has no gain. The horizontal zones map to a preset only when their pattern is exactly that
preset's:
| Preset | Included horizontal zones |
|---|---|
| none | all |
| back excluded | all but the two rear zones |
| side excluded | all but the two wall zones |
| centre and back | screen centre and the two rear zones |
| screen only | the three screen zones |
| surround only | the two wall zones and the two rear zones |
Any other pattern cannot be said in OAMD, which has the six presets and nothing finer (a 3-bit
zone_constraints_idx and b_enable_elevation), so it takes the preset that includes every zone the
pattern includes and lets the object into the nearest extra zones, summed by distance in the room plan
(IabZoneMapping::exact is false). The screen's left zone alone becomes screen only, the left wall alone
becomes surround only, and the left screen with the left wall becomes back excluded. The preset never
excludes a zone the author included: what it keeps the object out of, the author kept it out of; what it
lets in beyond that is the approximation. The overhead zones set b_enable_elevation:
on when either is included, or, for the 19-zone form, when any height-layer or ceiling zone is. A
zone19 update in a sub block with no pan information has no keyframe to ride on and takes effect
at the next sub block that has one.
Both reach the bitstream and stop there, as ADM's width and zone do: AtmosEncoder folds each
object into the bed as a point.
What is carried only approximately is listed per channel in IabBridgeResult::unmapped, and
forge atmos-iab prints each as a warning, as forge atmos-adm does for ADM:
- a zone control no Table 20 preset says exactly, with the preset it was carried as;
- a zone gain strictly between 0 and 1, which Table 20 reads as included or excluded from 0.5;
ObjectDecorCoefand a bed channel'sChannelDecorCoef(§10.5.18, §10.3.10), which OAMD has no field for, as it has none for ADM'sdiffuse;- an
ObjectSnapTolerancebelow 1 (§10.5.9): OAMD's snap is the flag alone.
IabBridgeResult is a new struct, not a reuse of BridgeResult: PCM is concatenated across
many independently-parsed frames, so IabBridgeResult::pcm is owned
(std::vector<std::vector<float>>), not borrowed the way BridgeResult::pcm is from a single
caller-owned AdmDocument — there is no equivalent single upstream object here to borrow spans
from once build_iab() returns.
Write direction¶
write() takes a WriteInput — a sample rate plus one WriteChannel per channel to place in the
master, in any order — and returns an iclforge::adm::AdmDocument ready for iclforge::adm::write_bw64(). A
channel is either a bed channel (bed_label set — written as a static DirectSpeakers channel
pinned at iclforge::objects::oba::bed_label_position(), updates unused) or a dynamic object (bed_label
empty — written as an Objects channel whose audioBlockFormat sequence comes from updates).
Each audioTrackUID carries the input's sampleRate and a bitDepth of iclforge::adm::kWriteBitDepth,
the width write_bw64() stores the PCM at, and audio.bits_per_sample holds the same width, so
the returned document already describes the master it becomes.
Scoped to exactly what this project's own decoders produce: a dynamic-object-only-or-single-
bed-instance programme (Eac3Decoder never emits ISF objects, several bed instances, or
non-standard Table 13 assignments — see oamd.hpp's own Program comment; an AC-4 presentation's
objects come from iclforge::ac4::DecodedFrame::objects, which lists bed and dynamic objects and renders an
intermediate spatial format into channels instead), no nested audioObjects, cartesian positions
only. forge decode's adm_out wiring (decode.cpp) writes an E-AC-3 programme's dynamic objects
and, for a channel-based-immersive bed programme (third-party content, and what atmos-cbi
writes), its bed channels too: each JOC output is one payload object, object_indices says which,
and one below the bed's channel count is written as a bed_label channel named by its Table 12
label while a dynamic object keeps its OAMD update timeline. The LFE comes from the decoded bed. A
programme with ISF objects, a second bed instance, a Table 13 assignment or an LFE2 is warned
about and skipped, not written incorrectly: each has a channel count and no label.
WriteObjectUpdate is the write-direction input for one OAMD update, timestamped in absolute
samples from the start of the whole decode (not the access unit it arrived in) — a caller
assembles the list by walking every decoded access unit's own
DecodedAccessUnit::object_metadata->blocks in file order and adding each block's own
sample_offset to a running total of samples already emitted. build_block_formats() (internal
to bridge.cpp) turns this into one audioBlockFormat per update: TS 103 420's own per-block
model — a value takes effect at sample_offset, reached over ramp_duration samples, then held —
is already, block for block, BS.2076-2 §10.3's jumpPosition = 1 + interpolationLength case, so
this direction needs none of build_channel_path()'s own read-direction case analysis; the first
update in a channel's sequence becomes a plain hold (§10.3's "the first block covers its entire
length regardless of jumpPosition" rule), every later one an explicit jump/ramp.
room_to_adm_cartesian() (coordinates.hpp) is the algebraic inverse of adm_cartesian_to_room()
above (x_adm = 2·x_room - 1, y_adm = 1 - 2·y_room, z_adm = z_room) — this writer only ever
emits cartesian ADM, matching the Dolby Atmos Master ADM Profile's own shape, so there is no
matching polar inverse.
API¶
enum class BridgeError : std::uint8_t {
kNoProgramme, kProgrammeNotFound, kUnresolvedReference, kObjectReferenceCycle,
kUnsupportedType, kChannelTrackMismatch, kNoAudioForTrack, kEmptyBlockSequence,
kTooManyChannels, kEmptyInput,
kEmptyIabStream, kUnsupportedIabChannel, kNoIabEssenceForChannel,
kBadIabAudio, // build_iab() only
};
std::string_view describe(BridgeError error);
std::expected<iclforge::objects::oba::ObjectPath, BridgeError> build_channel_path(
const iclforge::adm::AudioChannelFormat& channel, double object_start_s, bool force_lfe);
struct BridgeResult {
std::vector<std::string> channel_ids;
std::vector<std::vector<std::string>> unmapped; // per channel: ADM features not carried
std::vector<bool> is_bed;
std::vector<bool> is_lfe; // the LFE bed channel(s): not objects - see "What gets mapped"
std::vector<iclforge::objects::oba::ObjectPath> paths; // pass directly to evaluate_placements
std::vector<std::span<const float>> pcm; // borrowed from the AdmDocument passed to build()
std::uint32_t sample_rate = 0;
std::size_t channel_count() const; // paths.size()
std::size_t lfe_count() const; // channels marked is_lfe
std::size_t object_slot_count() const; // the rest: what AtmosEncoder takes as objects
};
std::expected<BridgeResult, BridgeError> build(const iclforge::adm::AdmDocument& document,
std::string_view programme_id = {});
iclforge::adm::CartesianPosition polar_to_adm_cartesian(const iclforge::adm::PolarPosition& polar);
iclforge::objects::oba::Position adm_cartesian_to_room(const iclforge::adm::CartesianPosition& cartesian);
iclforge::objects::oba::Position adm_position_to_room(const iclforge::adm::Position& position);
iclforge::adm::CartesianPosition room_to_adm_cartesian(const iclforge::objects::oba::Position& room);
AdmZoneMapping adm_zone_exclusion_to_constraint(std::span<const iclforge::adm::ExclusionZone> zones);
std::vector<iclforge::adm::ExclusionZone> constraint_to_adm_zone_exclusion(
iclforge::objects::oba::ZoneConstraint zone, bool enable_elevation);
iclforge::objects::oba::Position iab_position_to_room(const iclforge::iab::Position& position); // direct passthrough
struct IabBridgeResult {
std::vector<std::string> channel_ids;
std::vector<bool> is_bed;
std::vector<bool> is_lfe; // as BridgeResult's: not objects
std::vector<iclforge::objects::oba::ObjectPath> paths;
std::vector<std::vector<float>> pcm; // OWNED - see "Bridging IAB" above
std::uint32_t sample_rate = 0;
std::vector<std::vector<std::string>> unmapped; // per channel: carried approximately or not at all
std::size_t channel_count() const; // paths.size()
std::size_t lfe_count() const; // channels marked is_lfe
std::size_t object_slot_count() const; // the rest: what AtmosEncoder takes as objects
};
std::expected<IabBridgeResult, BridgeError> build_iab(
std::span<const iclforge::iab::IABitstreamFrame> frames);
struct WriteObjectUpdate {
std::uint64_t sample_offset = 0;
int ramp_duration_samples = 0; // iclforge::objects::oba::UpdateBlock::ramp_duration verbatim
iclforge::objects::oba::DynamicObject state;
};
struct WriteChannel {
std::string name;
std::span<const float> pcm;
std::optional<iclforge::objects::oba::BedLabel> bed_label{}; // set: bed/LFE; empty: dynamic object
std::span<const WriteObjectUpdate> updates{}; // dynamic objects only
};
struct WriteInput {
std::uint32_t sample_rate = 0;
std::vector<WriteChannel> channels;
};
std::expected<iclforge::adm::AdmDocument, BridgeError> write(const WriteInput& input);
BridgeResult is deliberately struct-of-arrays, not one struct per channel — paths is directly
usable as the std::span<const iclforge::objects::oba::ObjectPath> iclforge::objects::oba::evaluate_placements wants, with
no projection step. object_slot_count() <= 15: AtmosEncoder's own constructor objects parameter
is dynamic objects only, with the bed's own LFE bookkeeping as an implicit, always-present 16th
(TS 103 420 §8.3.2.2 caps the total at 16) — the same cap forge's run_atmos_encode/
run_atmos_path already enforce, reused here rather than re-derived. The LFE channels (lfe_count()
of them, is_lfe) are that 16th and are not counted: a 9.1.6 bed is fifteen speaker feeds and an LFE,
which fits, and channel_count() of it is 16. build() and build_iab()
refuse more objects than that whatever consumes the result, so atmos-adm and atmos-iab with
codec=ac4 are held to 15 as well, though the AC-4 object encoder takes 64. sample_rate is the raw
iclforge::adm::PcmAudio::sample_rate, unconverted — mapping it to iclforge::ac3::SampleRate (and rejecting an
unsupported rate) is left to the caller, the same way every existing WAV-reading entry point
already does that itself.
bitrate_kbps/dialnorm and every other AtmosConfig field are encoding choices ADM data does
not carry at all — build() deliberately does not invent defaults for them; constructing
AtmosConfig is the caller's job.
Tests¶
libs/adm/tests/test_adm_bridge.cpp covers coordinate conversion (against BS.2076-2 §8's cardinal points
and this project's own existing ring constants), build_channel_path's full §10.3 state machine
(single block, continuous-glide blocks, instant-jump blocks, ramp-then-hold blocks, the
first-block-always-holds override, the LFE override), build()'s graph-walking error paths
(unresolved references, a reference cycle, an unsupported pack type, a channel/track-count
mismatch, the 15-channel cap, default programme selection), and one flagship test that builds a
real byte-level BW64 fixture (two DirectSpeakers bed channels plus one Objects channel that holds
at one ring position and then jumps to another), parses it with the real iclforge::adm::parse_bw64(),
bridges it, and drives a real iclforge::ac3::oba::AtmosEncoder/iclforge::ac3::Eac3Decoder round trip — confirming
the decoded bitstream's channel energy actually lands where the authored ADM positions and hold/
jump timing say it should, the same standard libs/ac3/tests/oba/test_atmos_motion.cpp's own flagship test
holds itself to.
apps/forge/cli/tests/test_cli_atmos_adm.cpp covers the same fixture shape one level up: it runs the
real, built forge binary's atmos-adm command as a subprocess against a real ADM BWF file on
disk, then decodes what that binary actually wrote and checks the same channel-energy assertions —
proving the CLI's own argument parsing and its parse_bw64 → build → AtmosEncoder wiring, not
just the library API in isolation — plus two error-path cases (BridgeError::kNoProgramme, a
malformed/non-RIFF file) confirming describe() reaches the terminal rather than an opaque crash
or exit code.
libs/adm/tests/test_iab_bridge.cpp covers iab_position_to_room's cardinal points, the Table 19
→ position mapping (every defined code, the reserved ones build_iab() refuses, and the usual cinema
9.1 bed), the zone mapping for every one of the 127 horizontal patterns (the preset never excludes an
included zone, and is exact only for the six presets' own patterns), the unmapped notes, MetaID
cross-frame identity (the same MetaID+ChannelID across several frames is one channel, not several;
an absent frame silence-fills rather than shrinking the channel count), sub-block keyframe timing
(a dedicated fixture proving each active sub block's keyframe lands at its own end time, not its
start), and one flagship test with the identical rigor test_adm_bridge.cpp's own holds itself to
— a real byte-level IAB fixture (one Bed Center channel, one Object holding hard right then
jumping hard left), parsed with the real iclforge::iab::parse_iabitstream(), bridged, and driven through
a real AtmosEncoder/Eac3Decoder round trip confirming decoded channel energy lands where
authored. apps/forge/cli/tests/test_cli_atmos_iab.cpp covers the same fixture shape one level up, the same
way test_cli_atmos_adm.cpp does for atmos-adm.
See also: ADM / BW64 reading — the phase-1 parser this module consumes; IAB
reading — iclforge::iab, the other parser this module consumes (phases 1-2); Spatial &
Atmos objects — iclforge::ac3::oba::AtmosEncoder, iclforge::objects::oba::motion, and
iclforge::objects::oba::Position's own room-anchored coordinate convention this module's coordinates.hpp
converts into.