Skip to content

Commit

Permalink
ableton: Support Live10 empty locators
Browse files Browse the repository at this point in the history
  • Loading branch information
offlinemark committed Oct 28, 2024
1 parent 9584892 commit 44f3e19
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
11 changes: 6 additions & 5 deletions dawtool/daw/ableton.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,14 @@ def _parse_locators(self, contents):
"""
returns empty bytes if no locators
"""
# For some reason inside the first Locators tag, there is another
# identical Locators tag. However, if there are no locators, inside
# the first Locators tags there is simple another *closing* Locators
# tag.
# If there are locators, then there is an outer pair of Locators tags, and an
# inner pair that wraps that actual Locators elements.
# If there are no locators, then there is the outer pair of tags, and a
# `<Locators/>` inside.
outer_chunk = self._find_tag(contents, self.LOCATORS_TAG)
inner_chunk = self._find_tag(outer_chunk[1:], self.LOCATORS_TAG)
if inner_chunk.startswith(b'<Locators />'):
# The latter was observed in Live10. This could be improved, but it works for now.
if inner_chunk.startswith(b'<Locators />') or inner_chunk.startswith(b'<Locators/>'):
return b''
return inner_chunk

Expand Down
5 changes: 5 additions & 0 deletions tests/test_ableton.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,11 @@ def test_tag_empty_locators():
proj = AbletonProject('test.als', BytesIO(), require_gzip=False)
proj._parse_markers(als)

def test_tag_empty_locators_Live10():
als = b'<Locators><Locators/></Locators>'
proj = AbletonProject('test.als', BytesIO(), require_gzip=False)
proj._parse_markers(als)

def test_als_malformed_master():
p = AbletonProject('f', BytesIO())
p.version = AbletonSetVersion(None, None, 10, None, None, None, None, None)
Expand Down

0 comments on commit 44f3e19

Please sign in to comment.