Skip to content

Commit

Permalink
added create_new_tracks and set_timeline_selection
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenMachete committed Jan 23, 2024
1 parent 56f6465 commit d80e9e3
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 24 deletions.
65 changes: 41 additions & 24 deletions ptsl/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
PasteSpecialOptions, TrackOffsetOptions, TrackListInvertibleFilter, \
ExportFileType, ResolveDuplicateNamesBy, ExportFormat, \
MemoryLocationReference, MemoryLocationProperties, \
TimeProperties, CL_ClipLocation
TimeProperties, CL_ClipLocation, \
TrackFormat, TrackType, TrackTimebase


@contextmanager
Expand Down Expand Up @@ -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,

Check warning on line 233 in ptsl/engine.py

View check run for this annotation

Codecov / codecov/patch

ptsl/engine.py#L233

Added line #L233 was not covered by tests
location_options=2,
location_value=timecode
)
audio_data = pt.AudioData(file_list=file_list,

Check warning on line 237 in ptsl/engine.py

View check run for this annotation

Codecov / codecov/patch

ptsl/engine.py#L237

Added line #L237 was not covered by tests
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)

Check warning on line 245 in ptsl/engine.py

View check run for this annotation

Codecov / codecov/patch

ptsl/engine.py#L244-L245

Added lines #L244 - L245 were not covered by tests

Expand Down Expand Up @@ -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)

Check warning on line 805 in ptsl/engine.py

View check run for this annotation

Codecov / codecov/patch

ptsl/engine.py#L804-L805

Added lines #L804 - L805 were not covered by tests

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,

Check warning on line 817 in ptsl/engine.py

View check run for this annotation

Codecov / codecov/patch

ptsl/engine.py#L817

Added line #L817 was not covered by tests
track_name=track_name,
track_format=track_format,
track_type=track_type,
track_timebase=track_timebase
)
self.client.run(op)

Check warning on line 823 in ptsl/engine.py

View check run for this annotation

Codecov / codecov/patch

ptsl/engine.py#L823

Added line #L823 was not covered by tests

def cut(self, special: Optional['AutomationDataOptions'] = None):
"""
Execute an Edit > Cut.
Expand Down
2 changes: 2 additions & 0 deletions ptsl/ops/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 7 additions & 0 deletions ptsl/ops/create_new_tracks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from ptsl.ops import Operation


class CreateNewTracks(Operation):
pass


5 changes: 5 additions & 0 deletions ptsl/ops/set_timeline_selection.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from ptsl.ops import Operation


class SetTimelineSelection(Operation):
pass

0 comments on commit d80e9e3

Please sign in to comment.