forked from iluvcapra/py-ptsl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
session_info.py
92 lines (74 loc) · 2.96 KB
/
session_info.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# session_info.py
#
# This example demonstrates various getter methods of the `ptsl.Engine
# class.
#
# ```sh
# $ python3 examples/session_info.py
# PTSL Version: 1
# Session Name: Test2
# Session Path: Macintosh HD:Users:jamie:Test2:Test2.ptx
# Session Sample Rate: 48000
# Session Audio Format: SAF_WAVE
# Session Bit Depth: Bit24
# Session Audio Interlaved: TRUE
# Session Timecode Rate: STCR_Fps2997
# Session Start Time: 01:58:00:00.00
# Session Length: 20:00:00:00
# Session feet+frames rate: SFFR_Fps23976
# Session Audio Rate Pull: SRP_None
# Session Video Rate Pull: SRP_None
# -------------------------------
# Transport State: TS_TransportStopped
# Transport Arm: SAFE
# Playback Modes: Normal
# Record Mode: RM_Loop
# ```
import sys
from ptsl import open_engine, CommandError
from ptsl.PTSL_pb2 import PT_NoOpenedSession
import ptsl.PTSL_pb2 as pt
with open_engine(company_name="py-ptsl",
application_name=sys.argv[0]) as engine:
try:
print("PTSL Version: %i" % engine.ptsl_version())
print("Session Name: %s" % engine.session_name())
print("Session Path: %s" % engine.session_path())
print("Session Sample Rate: %i" % engine.session_sample_rate())
print("Session Audio Format: %s" %
pt.SessionAudioFormat.Name(engine.session_audio_format()))
print("Session Bit Depth: %s" %
pt.BitDepth.Name(engine.session_bit_depth()))
print("Session Audio Interlaved: %s" %
("TRUE" if engine.session_interleaved_state() else "FALSE"))
tc = engine.session_timecode_rate()
print("Session Timecode Rate: %s" %
pt.SessionTimeCodeRate.Name(engine.session_timecode_rate()))
print("Session Start Time: %s" % engine.session_start_time())
print("Session Length: %s" % engine.session_length())
ff = engine.session_feet_frames_rate()
print("Session feet+frames rate: %s" %
pt.SessionFeetFramesRate.Name(engine.session_feet_frames_rate()))
print("Session Audio Rate Pull: %s" %
pt.SessionRatePull.Name(engine.session_audio_rate_pull()))
print("Session Video Rate Pull: %s" %
pt.SessionRatePull.Name(engine.session_video_rate_pull()))
print("-------------------------------")
print("Transport State: %s " % engine.transport_state())
print("Transport Arm: %s" %
("ARMED" if engine.transport_armed() else "SAFE"))
pbm = engine.playback_modes()
pbms = []
if pbm[0]:
pbms.append("Normal")
if pbm[1]:
pbms.append("Loop")
if pbm[2]:
pbms.append("Dynamic Transport")
print("Playback Modes: %s" % ", ".join(pbms))
print("Record Mode: %s" % engine.record_mode())
except CommandError as e:
if e.error_response.command_error_type == PT_NoOpenedSession:
print("No Opened Session, exiting!")
else:
print("Command Error, exiting")