diff --git a/CHANGELOG.md b/CHANGELOG.md index eed7d10..8565587 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - Padding after data chunks in bw64 files was not written, and this error was silently ignored in the reader. This can be fixed with the new `ear-utils rewrite` command. - Mutable default parameters in ADMBuilder could cause unexpected extra blocks to be added when this was used from other programs. - ADM elements outside the `audioFormatExtended` were parsed, causing errors for some files containing non-standard ADM data. +- Generated IDs for audioStreamFormat and audioTrackFormat included the format (i.e. always PCM, or 0001), but should include the type of the linked channel/pack format. See [#78]. ### Changed - Added a warning for audioBlockFormats which have a duration but no rtime; previously these were fixed silently. See [#54]. @@ -163,6 +164,7 @@ Initial release. [#62]: https://github.com/ebu/ebu_adm_renderer/pull/62 [#59]: https://github.com/ebu/ebu_adm_renderer/pull/59 [#58]: https://github.com/ebu/ebu_adm_renderer/issues/58 +[#78]: https://github.com/ebu/ebu_adm_renderer/pull/78 [34b738a]: https://github.com/ebu/ebu_adm_renderer/commit/34b738a [04533fc]: https://github.com/ebu/ebu_adm_renderer/commit/04533fc [222374a]: https://github.com/ebu/ebu_adm_renderer/commit/222374a diff --git a/ear/fileio/adm/generate_ids.py b/ear/fileio/adm/generate_ids.py index f1e7812..2cacf2d 100644 --- a/ear/fileio/adm/generate_ids.py +++ b/ear/fileio/adm/generate_ids.py @@ -10,6 +10,19 @@ def _stream_track_formats(adm, stream_format): yield track_format +def _stream_type_definition(stream_format): + """get the TypeDefinition from the channel or pack format linked to a stream format""" + if stream_format.audioChannelFormat is not None: + return stream_format.audioChannelFormat.type + elif stream_format.audioPackFormat is not None: + return stream_format.audioPackFormat.type + else: + assert False, ( + "can not generate IDs for an audioStreamFormat not linked" + "to an audioChannelFormat or an audioPackFormat; run validation first" + ) + + def generate_ids(adm): """regenerate ids for all elements in adm @@ -42,10 +55,14 @@ def generate_ids(adm): block.id = "AB_{type.value:04X}{id:04X}_{block_id:08X}".format(id=id, type=element.type, block_id=block_id) for id, element in enumerate(non_common(adm.audioStreamFormats), 0x1001): - element.id = "AS_{format.value:04X}{id:04X}".format(id=id, format=element.format) + type_id = _stream_type_definition(element).value + + element.id = "AS_{type_id:04X}{id:04X}".format(id=id, type_id=type_id) for track_id, element in enumerate(_stream_track_formats(adm, element), 0x1): - element.id = "AT_{format.value:04X}{id:04X}_{track_id:02X}".format(id=id, format=element.format, track_id=track_id) + element.id = "AT_{type_id:04X}{id:04X}_{track_id:02X}".format( + id=id, type_id=type_id, track_id=track_id + ) for id, element in enumerate(adm.audioTrackUIDs, 0x1): element.id = "ATU_{id:08X}".format(id=id) diff --git a/ear/fileio/adm/test/test_adm_files/defaults_v1.xml b/ear/fileio/adm/test/test_adm_files/defaults_v1.xml index 41d26c4..3ae038f 100644 --- a/ear/fileio/adm/test/test_adm_files/defaults_v1.xml +++ b/ear/fileio/adm/test/test_adm_files/defaults_v1.xml @@ -21,15 +21,15 @@ AC_00031001 - - AT_00011001_01 + + AT_00031001_01 AC_00031001 - - AS_00011001 + + AS_00031001 - AT_00011001_01 + AT_00031001_01 AP_00031001 diff --git a/ear/fileio/adm/test/test_generate_ids.py b/ear/fileio/adm/test/test_generate_ids.py index 978b230..ffb0709 100644 --- a/ear/fileio/adm/test/test_generate_ids.py +++ b/ear/fileio/adm/test/test_generate_ids.py @@ -36,8 +36,8 @@ def test_generate_ids(): assert acf.id == "AC_00031001" assert acf.audioBlockFormats[0].id == "AB_00031001_00000001" - assert builder.adm.audioStreamFormats[0].id == "AS_00011001" + assert builder.adm.audioStreamFormats[0].id == "AS_00031001" - assert builder.adm.audioTrackFormats[0].id == "AT_00011001_01" + assert builder.adm.audioTrackFormats[0].id == "AT_00031001_01" assert builder.adm.audioTrackUIDs[0].id == "ATU_00000001" diff --git a/ear/test/data/test_bwf.wav b/ear/test/data/test_bwf.wav index d601d0f..e67e02d 100644 Binary files a/ear/test/data/test_bwf.wav and b/ear/test/data/test_bwf.wav differ