mirror of
https://github.com/iluvcapra/ptulsconv.git
synced 2025-12-31 17:00:46 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
17b87b6e69 | ||
|
|
a636791539 | ||
|
|
dfde3c4493 | ||
|
|
81909c8a51 | ||
|
|
e2b9a20870 |
@@ -2,7 +2,7 @@
|
|||||||
Parse and convert Pro Tools text exports
|
Parse and convert Pro Tools text exports
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__version__ = '2.0.1'
|
__version__ = '2.1.0'
|
||||||
__author__ = 'Jamie Hardt'
|
__author__ = 'Jamie Hardt'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = "%s %s (c) 2023 %s. All rights reserved." \
|
__copyright__ = "%s %s (c) 2023 %s. All rights reserved." \
|
||||||
|
|||||||
@@ -20,6 +20,9 @@ class SessionDescriptor:
|
|||||||
self.markers = kwargs['markers']
|
self.markers = kwargs['markers']
|
||||||
|
|
||||||
def markers_timed(self) -> Iterator[Tuple['MarkerDescriptor', Fraction]]:
|
def markers_timed(self) -> Iterator[Tuple['MarkerDescriptor', Fraction]]:
|
||||||
|
"""
|
||||||
|
Iterate each marker in the session with its respective time reference.
|
||||||
|
"""
|
||||||
for marker in self.markers:
|
for marker in self.markers:
|
||||||
marker_time = Fraction(marker.time_reference,
|
marker_time = Fraction(marker.time_reference,
|
||||||
int(self.header.sample_rate))
|
int(self.header.sample_rate))
|
||||||
@@ -28,6 +31,9 @@ class SessionDescriptor:
|
|||||||
|
|
||||||
def tracks_clips(self) -> Iterator[Tuple['TrackDescriptor',
|
def tracks_clips(self) -> Iterator[Tuple['TrackDescriptor',
|
||||||
'TrackClipDescriptor']]:
|
'TrackClipDescriptor']]:
|
||||||
|
"""
|
||||||
|
Iterate each track clip with its respective owning clip.
|
||||||
|
"""
|
||||||
for track in self.tracks:
|
for track in self.tracks:
|
||||||
for clip in track.clips:
|
for clip in track.clips:
|
||||||
yield track, clip
|
yield track, clip
|
||||||
@@ -37,7 +43,10 @@ class SessionDescriptor:
|
|||||||
Fraction, Fraction, Fraction]
|
Fraction, Fraction, Fraction]
|
||||||
]:
|
]:
|
||||||
"""
|
"""
|
||||||
:return: A Generator that yields track, clip, start time, finish time,
|
Iterate each track clip with its respective owning clip and timing
|
||||||
|
information.
|
||||||
|
|
||||||
|
:returns: A Generator that yields track, clip, start time, finish time,
|
||||||
and timestamp
|
and timestamp
|
||||||
"""
|
"""
|
||||||
for track, clip in self.tracks_clips():
|
for track, clip in self.tracks_clips():
|
||||||
@@ -115,6 +124,7 @@ class HeaderDescriptor:
|
|||||||
|
|
||||||
|
|
||||||
class TrackDescriptor:
|
class TrackDescriptor:
|
||||||
|
index: int
|
||||||
name: str
|
name: str
|
||||||
comments: str
|
comments: str
|
||||||
user_delay_samples: int
|
user_delay_samples: int
|
||||||
@@ -123,6 +133,7 @@ class TrackDescriptor:
|
|||||||
clips: List["TrackClipDescriptor"]
|
clips: List["TrackClipDescriptor"]
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
|
self.index = kwargs['index']
|
||||||
self.name = kwargs['name']
|
self.name = kwargs['name']
|
||||||
self.comments = kwargs['comments']
|
self.comments = kwargs['comments']
|
||||||
self.user_delay_samples = kwargs['user_delay_samples']
|
self.user_delay_samples = kwargs['user_delay_samples']
|
||||||
|
|||||||
@@ -108,8 +108,12 @@ def parse_document(session_text: str) -> SessionDescriptor:
|
|||||||
|
|
||||||
class DocParserVisitor(NodeVisitor):
|
class DocParserVisitor(NodeVisitor):
|
||||||
|
|
||||||
@staticmethod
|
def __init__(self):
|
||||||
def visit_document(_, visited_children) -> SessionDescriptor:
|
self.track_index = 0
|
||||||
|
|
||||||
|
# @staticmethod
|
||||||
|
def visit_document(self, _, visited_children) -> SessionDescriptor:
|
||||||
|
self.track_index = 0
|
||||||
files = next(iter(visited_children[1]), None)
|
files = next(iter(visited_children[1]), None)
|
||||||
clips = next(iter(visited_children[2]), None)
|
clips = next(iter(visited_children[2]), None)
|
||||||
plugins = next(iter(visited_children[3]), None)
|
plugins = next(iter(visited_children[3]), None)
|
||||||
@@ -166,8 +170,8 @@ class DocParserVisitor(NodeVisitor):
|
|||||||
count_instances=child[10]),
|
count_instances=child[10]),
|
||||||
visited_children[2]))
|
visited_children[2]))
|
||||||
|
|
||||||
@staticmethod
|
# @staticmethod
|
||||||
def visit_track_block(_, visited_children):
|
def visit_track_block(self, _, visited_children):
|
||||||
track_header, track_clip_list = visited_children
|
track_header, track_clip_list = visited_children
|
||||||
clips = []
|
clips = []
|
||||||
for clip in track_clip_list:
|
for clip in track_clip_list:
|
||||||
@@ -179,7 +183,11 @@ class DocParserVisitor(NodeVisitor):
|
|||||||
for plugin in plugin_opt[1]:
|
for plugin in plugin_opt[1]:
|
||||||
plugins.append(plugin[1])
|
plugins.append(plugin[1])
|
||||||
|
|
||||||
|
this_index = self.track_index
|
||||||
|
self.track_index += 1
|
||||||
|
|
||||||
return TrackDescriptor(
|
return TrackDescriptor(
|
||||||
|
index=this_index,
|
||||||
name=track_header[2],
|
name=track_header[2],
|
||||||
comments=track_header[6],
|
comments=track_header[6],
|
||||||
user_delay_samples=track_header[10],
|
user_delay_samples=track_header[10],
|
||||||
|
|||||||
@@ -88,7 +88,9 @@ class TestTagCompiler(unittest.TestCase):
|
|||||||
state='Unmuted',
|
state='Unmuted',
|
||||||
timestamp=None),
|
timestamp=None),
|
||||||
]
|
]
|
||||||
test_track = doc_entity.TrackDescriptor(name="Track 1 [A] {Color=Red} $Mode=1",
|
test_track = doc_entity.TrackDescriptor(
|
||||||
|
index=0,
|
||||||
|
name="Track 1 [A] {Color=Red} $Mode=1",
|
||||||
comments="{Comment=This is some text in the comments}",
|
comments="{Comment=This is some text in the comments}",
|
||||||
user_delay_samples=0,
|
user_delay_samples=0,
|
||||||
plugins=[],
|
plugins=[],
|
||||||
|
|||||||
Reference in New Issue
Block a user