Skip to content

Commit

Permalink
select_items: set HOA importances
Browse files Browse the repository at this point in the history
  • Loading branch information
tomjnixon committed Feb 20, 2024
1 parent bf52c80 commit f7cc1b2
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
1 change: 1 addition & 0 deletions ear/core/select_items/hoa.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
14 changes: 12 additions & 2 deletions ear/core/select_items/select_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand All @@ -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),
Expand Down
21 changes: 21 additions & 0 deletions ear/core/select_items/test/test_hoa.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit f7cc1b2

Please sign in to comment.