From f7cc1b28ad5843fd00168870a84dfd4b82acffd1 Mon Sep 17 00:00:00 2001 From: Thomas Nixon Date: Tue, 20 Feb 2024 18:53:07 +0000 Subject: [PATCH] select_items: set HOA importances --- ear/core/select_items/hoa.py | 1 + ear/core/select_items/select_items.py | 14 ++++++++++++-- ear/core/select_items/test/test_hoa.py | 21 +++++++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/ear/core/select_items/hoa.py b/ear/core/select_items/hoa.py index f161493..54fffc3 100644 --- a/ear/core/select_items/hoa.py +++ b/ear/core/select_items/hoa.py @@ -35,3 +35,4 @@ def _get_block_format_attr(_audioPackFormat_path, audioChannelFormat, attr): get_rtime = partial(_get_block_format_attr, attr="rtime") get_duration = partial(_get_block_format_attr, attr="duration") get_gain = partial(_get_block_format_attr, attr="gain") +get_importance = partial(_get_block_format_attr, attr="importance") diff --git a/ear/core/select_items/select_items.py b/ear/core/select_items/select_items.py index 49d1861..d4728d2 100644 --- a/ear/core/select_items/select_items.py +++ b/ear/core/select_items/select_items.py @@ -734,8 +734,17 @@ def _get_RenderingItems_DirectSpeakers(state): def _get_RenderingItems_HOA(state): """Get a HOARenderingItem given an _ItemSelectionState.""" - from .hoa import (get_nfcRefDist, get_screenRef, get_normalization, - get_order, get_degree, get_rtime, get_duration, get_gain) + from .hoa import ( + get_nfcRefDist, + get_screenRef, + get_normalization, + get_order, + get_degree, + get_rtime, + get_duration, + get_gain, + get_importance, + ) states = list(_select_single_channel(state)) @@ -748,6 +757,7 @@ def _get_RenderingItems_HOA(state): orders=get_per_channel_param(pack_paths_channels, get_order), degrees=get_per_channel_param(pack_paths_channels, get_degree), gains=get_per_channel_param(pack_paths_channels, get_gain), + importances=get_per_channel_param(pack_paths_channels, get_importance), normalization=get_single_param(pack_paths_channels, "normalization", get_normalization), nfcRefDist=get_single_param(pack_paths_channels, "nfcRefDist", get_nfcRefDist), screenRef=get_single_param(pack_paths_channels, "screenRef", get_screenRef), diff --git a/ear/core/select_items/test/test_hoa.py b/ear/core/select_items/test/test_hoa.py index f3070a7..2c77e4a 100644 --- a/ear/core/select_items/test/test_hoa.py +++ b/ear/core/select_items/test/test_hoa.py @@ -160,3 +160,24 @@ def test_hoa_gains(): meta = item.metadata_source.get_next_block() assert meta.gains == gains + + +def test_hoa_importances(): + builder = HOABuilder() + + importances = [1, 2, 3, 4] + + for channel, importance in zip(builder.first_pack.audioChannelFormats, importances): + channel.audioBlockFormats[0].importance = importance + + for i, track in enumerate(builder.first_tracks, 1): + builder.create_track_uid( + audioPackFormat=builder.first_pack, audioTrackFormat=track, trackIndex=i + ) + + generate_ids(builder.adm) + + [item] = select_rendering_items(builder.adm) + meta = item.metadata_source.get_next_block() + + assert meta.importances == importances