1414class WavADMReader :
1515 """
1616 Reads XML data from an EBU ADM (Audio Definiton Model) WAV File.
17+
1718 """
1819
1920 def __init__ (self , axml_data : bytes , chna_data : bytes ):
@@ -26,7 +27,12 @@ def __init__(self, axml_data: bytes, chna_data: bytes):
2627 _ , uid_count = unpack (header_fmt , chna_data [0 :4 ])
2728
2829 #: A list of :class:`ChannelEntry` objects parsed from the
29- #: `chna` metadata chunk.
30+ #: `chna` metadata chunk.
31+ #:
32+ #: .. note::
33+ #: In-file, the `chna` track indexes start at 1. However, this interface
34+ #: numbers the first track 0, in order to maintain consistency with other
35+ #: libraries.
3036 self .channel_uids = []
3137
3238 offset = calcsize (header_fmt )
@@ -36,7 +42,7 @@ def __init__(self, axml_data: bytes, chna_data: bytes):
3642
3743 # these values are either ascii or all null
3844
39- self .channel_uids .append (ChannelEntry (track_index ,
45+ self .channel_uids .append (ChannelEntry (track_index - 1 ,
4046 uid .decode ('ascii' ) , track_ref .decode ('ascii' ), pack_ref .decode ('ascii' )))
4147
4248 offset += calcsize (uid_fmt )
@@ -97,7 +103,7 @@ def track_info(self, index):
97103 :returns: a dictionary with *content_name*, *content_id*, *object_name*, *object_id*,
98104 *pack_format_name*, *pack_type*, *channel_format_name*
99105 """
100- channel_info = next ((x for x in self .channel_uids if x .track_index == index + 1 ), None )
106+ channel_info = next ((x for x in self .channel_uids if x .track_index == index ), None )
101107
102108 if channel_info is None :
103109 return None
@@ -152,7 +158,7 @@ def to_dict(self):
152158
153159 def make_entry (channel_uid_rec ):
154160 rd = channel_uid_rec ._asdict ()
155- rd .update (self .track_info (channel_uid_rec .track_index - 1 ))
161+ rd .update (self .track_info (channel_uid_rec .track_index ))
156162 return rd
157163
158164 return dict (channel_entries = list (map (lambda z : make_entry (z ), self .channel_uids )),
0 commit comments