ADM Utilities¶
ADM Builder¶
The builder.ADMBuilder class makes it easier to construct basic ADM
structures which are properly linked together. For example, to make an ADM with
a single Objects channel:
from ear.fileio.adm.builder import ADMBuilder
from ear.fileio.adm.elements import AudioBlockFormatObjects, ObjectPolarPosition
builder = ADMBuilder()
builder.create_programme(audioProgrammeName="my audioProgramme")
builder.create_content(audioContentName="my audioContent")
block_formats = [
AudioBlockFormatObjects(
position=ObjectPolarPosition(azimuth=0.0, elevation=0.0, distance=1.0),
),
]
builder.create_item_objects(0, "MyObject 1", block_formats=block_formats)
# do something with builder.adm
- class ear.fileio.adm.builder.ADMBuilder(adm=NOTHING, last_programme=None, last_content=None, last_object=None, last_pack_format=None, last_stream_format=None, item_parent=None)¶
Builder object for creating ADM object graphs.
- last_programme¶
The last programme created, to which created audioContents will be linked.
- Type
Optional[AudioProgramme]
- last_content¶
The last content created, to which created audioObjects will be linked by default.
- Type
Optional[AudioContent]
- last_object¶
The last object created, to which created audioObjects or audioPackFormats will be linked by default.
- Type
Optional[AudioObject]
- last_pack_format¶
The last pack_format created, to which created audioChannelFormats will be linked by default.
- Type
Optional[AudioPackFormat]
- last_stream_format¶
The last stream_format created, to which created audioTrackFormats will be linked by default.
- Type
Optional[AudioStreamFormat]
- item_parent¶
The last explicitly created audioContent or audioObject, used as the parent for audioObjects created by create_item* functions.
- Type
Optional[Union[AudioContent, AudioObject]]
- class MonoItem(channel_format, track_format, pack_format, stream_format, track_uid, audio_object, parent)¶
Structure referencing the ADM components created as part of a mono item.
- channel_format¶
- Type
- track_format¶
- Type
- pack_format¶
- Type
- stream_format¶
- Type
- track_uid¶
- Type
- audio_object¶
- Type
- parent¶
- Type
Union[AudioContent, AudioObject]
- create_channel(parent=DEFAULT, **kwargs)¶
Create a new audioChannelFormat.
- Parameters
parent (AudioPackFormat) – parent packFormat; defaults to the last packFormat created
kwargs – see
AudioChannelFormat
- Returns
created audioChannelFormat
- Return type
- create_content(parent=DEFAULT, **kwargs)¶
Create a new audioContent.
- Parameters
parent (AudioProgramme) – parent programme; defaults to the last one created
kwargs – see
AudioContent
- Returns
created audioContent
- Return type
- create_item_direct_speakers(*args, **kwargs)¶
Create ADM components needed to represent a DirectSpeakers channel.
Wraps
create_item_mono()withtype=TypeDefinition.DirectSpeakers.
- create_item_mono(type, track_index, name, parent=DEFAULT, block_formats=[])¶
Create ADM components needed to represent a mono channel, either DirectSpeakers or Objects.
- Parameters
type (TypeDefinition) – type of channelFormat and packFormat
track_index (int) – zero-based index of the track in the BWF file.
name (str) – name used for all components
parent (Union[AudioContent, AudioObject]) – parent of the created audioObject defaults to the last content or explicitly created object
block_formats (list[AudioBlockFormat]) – block formats to add to the channel format
- Returns
the created components
- Return type
- create_item_objects(*args, **kwargs)¶
Create ADM components needed to represent an object channel.
Wraps
create_item_mono()withtype=TypeDefinition.Objects.
- create_object(parent=DEFAULT, **kwargs)¶
Create a new audioObject.
- Parameters
parent (Union[AudioContent, AudioObject]) – parent content or object; defaults to the last content created
kwargs – see
AudioObject
- Returns
created audioObject
- Return type
- create_pack(parent=DEFAULT, **kwargs)¶
Create a new audioPackFormat.
- Parameters
parent (AudioObject or AudioPackFormat) – parent object or packFormat; defaults to the last object created
kwargs – see
AudioPackFormat
- Returns
created audioPackFormat
- Return type
- create_programme(**kwargs)¶
Create a new audioProgramme.
- Parameters
kwargs – see
AudioProgramme- Returns
created audioProgramme
- Return type
- create_stream(**kwargs)¶
Create a new audioStreamFormat.
- Parameters
kwargs – see AudioChannelFormat
- Returns
created audioStreamFormat
- Return type
- create_track(parent=DEFAULT, **kwargs)¶
Create a new audioTrackFormat.
- Parameters
parent (AudioStreamFormat) – parent streamFormat; defaults to the last audioStreamFormat created
kwargs – see AudioTrackFormat
- Returns
created audioTrackFormat
- Return type
- create_track_uid(parent=DEFAULT, **kwargs)¶
Create a new audioTrackUID.
- Parameters
parent (AudioObject) – parent audioObject; defaults to the last audioObject created
kwargs – see AudioTrackUID
- Returns
created audioTrackUID
- Return type
- load_common_definitions()¶
Load common definitions into adm.
ID Generation¶
When ADM objects are created, they have their IDs set to None. Before serialisation, the IDs must be generated using generate_ids():
CHNA Utilities¶
In a BW64 file, the AXML and CHNA chunks store overlapping and related information about audioTrackUIDs:
track index: CHNA only
audioTrackFormat reference: CHNA and AXML
audioPackFormat reference: CHNA and AXML
To simplify this, the elements.AudioTrackUID class stores the track
index from the CHNA, and we provide utilities for copying data between a CHNA
and an ADM object:
- ear.fileio.adm.chna.load_chna_chunk(adm, chna)¶
Add information from the chna chunk to the adm track UIDs structure.
Any existing track UIDs in adm are checked for consistency against the data in chna; any non-existent track-UIDs are created.
The track index, pack format ref and track format ref attributes are transferred; there references are resolved, and we assume that any references in adm have already been resolved
- ear.fileio.adm.chna.populate_chna_chunk(chna, adm)¶
Populate the CHNA chunk with information from the ADM model.
All CHNA entries are replaced, and are populated from the trackIndex, audioTrackUID, and the track format/pack format references.
Since the CHNA chunk contains IDs, the IDs in the ADM must have been generated before calling this.
Common Definitions¶
The library includes a copy of the common definitions file, which can be loaded into an ADM structure: