From d80e9e334460ab96e66dda2e0bc76963aa21bed0 Mon Sep 17 00:00:00 2001 From: StephenMachete Date: Tue, 23 Jan 2024 07:27:20 +0100 Subject: [PATCH] added create_new_tracks and set_timeline_selection --- ptsl/engine.py | 65 +++++++++++++++++++----------- ptsl/ops/__init__.py | 2 + ptsl/ops/create_new_tracks.py | 7 ++++ ptsl/ops/set_timeline_selection.py | 5 +++ 4 files changed, 55 insertions(+), 24 deletions(-) create mode 100644 ptsl/ops/create_new_tracks.py create mode 100644 ptsl/ops/set_timeline_selection.py diff --git a/ptsl/engine.py b/ptsl/engine.py index cd4da44..ae22dc2 100644 --- a/ptsl/engine.py +++ b/ptsl/engine.py @@ -26,7 +26,8 @@ PasteSpecialOptions, TrackOffsetOptions, TrackListInvertibleFilter, \ ExportFileType, ResolveDuplicateNamesBy, ExportFormat, \ MemoryLocationReference, MemoryLocationProperties, \ - TimeProperties, CL_ClipLocation + TimeProperties, CL_ClipLocation, \ + TrackFormat, TrackType, TrackTimebase @contextmanager @@ -215,40 +216,31 @@ def import_data(self, Import session data into the currently-open session. """ return ImportSessionDataBuilder(self, session_path) - + def import_audio(self, - file_list: List[str], - destination_path: str=None, - audio_operations: int=None, - audio_destination: int=None, - audio_location: int=None, - timecode: str=None - ): + file_list: List[str], + destination_path: str=None, + audio_operations: int=None, + audio_destination: int=None, + audio_location: int=None, + timecode: str=None + ): """ Import audio data into the currently-open session. - Throws "command_error_message: location_data ; command_error_type: PT_UnknownError", - when no location_data(timecode) is provided, but still works regardless of audio_location setting. + location_data needs to be provided regardless if empty. Just a basic implementation for audio data import TC based only. """ - if timecode is not None: - spot_data = pt.SpotLocationData(location_type=0, - location_options=2, - location_value=timecode - ) - audio_data = pt.AudioData(file_list=file_list, + spot_data = pt.SpotLocationData(location_type=0, + location_options=2, + location_value=timecode + ) + audio_data = pt.AudioData(file_list=file_list, destination_path=destination_path, audio_operations=audio_operations, audio_destination=audio_destination, audio_location=audio_location, location_data=spot_data ) - else: - audio_data = pt.AudioData(file_list=file_list, - destination_path=destination_path, - audio_operations=audio_operations, - audio_destination=audio_destination, - audio_location=audio_location - ) op = ops.Import(import_type=1, audio_data=audio_data) self.client.run(op) @@ -805,6 +797,31 @@ def set_session_video_rate_pull(self, pull_rate: 'SessionRatePull'): op = ops.SetSessionVideoRatePullSettings(video_rate_pull=pull_rate) self.client.run(op) + def simple_set_timeline_selection(self, in_time: str): + """ + Set Selection at Timecode + """ + op = ops.SetTimelineSelection(in_time=in_time) + self.client.run(op) + + def create_new_tracks(self, + number_of_tracks: int = None, + track_name: str = None, + track_format: TrackFormat = None, + track_type: 'TrackType' = None, + track_timebase: TrackTimebase = None + ): + """ + Create new Tracks + """ + op = ops.CreateNewTracks(number_of_tracks=number_of_tracks, + track_name=track_name, + track_format=track_format, + track_type=track_type, + track_timebase=track_timebase + ) + self.client.run(op) + def cut(self, special: Optional['AutomationDataOptions'] = None): """ Execute an Edit > Cut. diff --git a/ptsl/ops/__init__.py b/ptsl/ops/__init__.py index 41c9147..810e141 100644 --- a/ptsl/ops/__init__.py +++ b/ptsl/ops/__init__.py @@ -73,6 +73,8 @@ from .set_session_time_code_rate import SetSessionTimeCodeRate from .set_session_video_rate_pull_settings import \ SetSessionVideoRatePullSettings +from .set_timeline_selection import SetTimelineSelection +from .create_new_tracks import CreateNewTracks # Pro Tools 2023.3 diff --git a/ptsl/ops/create_new_tracks.py b/ptsl/ops/create_new_tracks.py new file mode 100644 index 0000000..718e65b --- /dev/null +++ b/ptsl/ops/create_new_tracks.py @@ -0,0 +1,7 @@ +from ptsl.ops import Operation + + +class CreateNewTracks(Operation): + pass + + diff --git a/ptsl/ops/set_timeline_selection.py b/ptsl/ops/set_timeline_selection.py new file mode 100644 index 0000000..cabd626 --- /dev/null +++ b/ptsl/ops/set_timeline_selection.py @@ -0,0 +1,5 @@ +from ptsl.ops import Operation + + +class SetTimelineSelection(Operation): + pass \ No newline at end of file