1
2
3
4
5
6
7
8
9
10
11
12from pyfbsdk import *
13from pyfbsdk_additions import *
14from sys import *
15import os.path
16import traceback
17
18global lFp
20
21
22
23def BrowseCallback(control, event):
24
25
26 lFp.Caption = "Select the audio track definition file:"
27 lFp.Style = FBFilePopupStyle.kFBFilePopupOpen
28 lFp.Filter = "*.txt"
29 if os.path.isdir(os.path.splitext(traceback.extract_stack()[-1][0])[0]):
30 lFp.Path = os.path.normpath(os.path.splitext(traceback.extract_stack()[-1][0])[0])
31 else:
32 lFp.Path = os.path.normpath(os.path.dirname(traceback.extract_stack()[-1][0]))
33 lRes = lFp.Execute()
34
35 if lRes:
36 eButt.Text = os.path.join(lFp.Path,lFp.FileName)
37
38def SetupCallback(control, event):
39
40 try:
41 f=open(os.path.join(lFp.Path,lFp.FileName), 'r')
42 shotInfoFile = f.readlines()
43 f.close()
44 lTrackAudio =
FBStoryTrack(FBStoryTrackType.kFBStoryTrackAudio)
45 shotCnt = len(shotInfoFile)
46 counter = 1
47 lastClipEnd = 0
48 for shotInfo in shotInfoFile:
49
50 shots = shotInfo.split()
51 shotName = shots[0]
52 shotStart = shots[1]
53 shotEnd = shots[2]
54 iShotStart =
int(shotStart)
55 iShotEnd =
int(shotEnd)
56 if counter < 10:
57 audioPath = os.path.join(lFp.Path,
"Audio_Clip_0" +
str(counter) +
".wav")
58 else:
59 audioPath = os.path.join(lFp.Path,
"Audio_Clip_" +
str(counter) +
".wav")
60
62 lClip = FBStoryClip (lAudio, lTrackAudio,
FBTime(0,0,0,iShotStart))
63 if lastClipEnd<iShotEnd: lastClipEnd=iShotEnd
64 counter = counter + 1
66
67 except IOError:
68 FBMessageBox(
"Cannot Continue",
"Unable to read the audio track definition file you selected or you have not selected one.",
"OK",
None,
None )
69 exit
70
71def CloseCallback(control, event):
72 FBDestroyTool(t)
73
74def PopulateLayout(mainLyt):
75
76
78 l.Caption = "Select the audio track definition file to use:"
79 l.Style = FBTextStyle.kFBTextStyleBold
80 l.WordWrap = True
81
82 x = FBAddRegionParam(0,FBAttachType.kFBAttachLeft,"")
83 y = FBAddRegionParam(5,FBAttachType.kFBAttachTop,"")
84 w = FBAddRegionParam(300,FBAttachType.kFBAttachNone,"")
85 h = FBAddRegionParam(20,FBAttachType.kFBAttachNone,"")
86
87 mainLyt.AddRegion("lab","lab", x, y, w, h)
88 mainLyt.SetControl("lab",l)
89
90
92 e.ReadOnly = True
93 e.Text = ""
94
95 x2 = FBAddRegionParam(5,FBAttachType.kFBAttachLeft,"")
96 y2 = FBAddRegionParam(5,FBAttachType.kFBAttachBottom,"lab")
97 w2 = FBAddRegionParam(220,FBAttachType.kFBAttachNone,"")
98 h2 = FBAddRegionParam(20,FBAttachType.kFBAttachNone,"")
99
100 mainLyt.AddRegion("path","path", x2, y2, w2, h2)
101 mainLyt.SetControl("path",e)
102
103
105 b2.Caption = "Browse..."
106 b2.Justify = FBTextJustify.kFBTextJustifyCenter
107
108 x3 = FBAddRegionParam(225,FBAttachType.kFBAttachLeft,"path")
109 y3 = FBAddRegionParam(5,FBAttachType.kFBAttachBottom,"lab")
110 w3 = FBAddRegionParam(57,FBAttachType.kFBAttachNone,"")
111 h3 = FBAddRegionParam(20,FBAttachType.kFBAttachNone,"")
112
113 mainLyt.AddRegion("but","but", x3, y3, w3, h3)
114 mainLyt.SetControl("but",b2)
115
116 global eButt
117 eButt = e
118 b2.OnClick.Add(BrowseCallback)
119
120
122 b3.Caption = "Setup Audio"
123 b3.Justify = FBTextJustify.kFBTextJustifyCenter
124
125 x4 = FBAddRegionParam(40,FBAttachType.kFBAttachLeft,"")
126 y4 = FBAddRegionParam(12,FBAttachType.kFBAttachBottom,"path")
127 w4 = FBAddRegionParam(100,FBAttachType.kFBAttachNone,"")
128 h4 = FBAddRegionParam(25,FBAttachType.kFBAttachNone,"")
129
130 mainLyt.AddRegion("audio","audio", x4, y4, w4, h4)
131 mainLyt.SetControl("audio",b3)
132 b3.OnClick.Add(SetupCallback)
133
134
136 b4.Caption = "Close"
137 b4.Justify = FBTextJustify.kFBTextJustifyCenter
138
139 x5 = FBAddRegionParam(20,FBAttachType.kFBAttachRight,"audio")
140 y5 = FBAddRegionParam(12,FBAttachType.kFBAttachBottom,"path")
141 w5 = FBAddRegionParam(100,FBAttachType.kFBAttachNone,"")
142 h5 = FBAddRegionParam(25,FBAttachType.kFBAttachNone,"")
143
144 mainLyt.AddRegion("close","close", x5, y5, w5, h5)
145 mainLyt.SetControl("close",b4)
146 b4.OnClick.Add(CloseCallback)
147
148def CreateTool():
149
150 global t
151 t = FBCreateUniqueTool("Audio Track Setup Tool")
152 t.StartSizeX = 300
153 t.StartSizeY = 123
154 PopulateLayout(t)
155 ShowTool(t)
156
157CreateTool()
Used to play audio clips and access their properties.
Definition: pyfbsdk_generated.h:1545
Text edit box.
Definition: pyfbsdk_generated.h:5998
Text label.
Definition: pyfbsdk_generated.h:9829
Player control.
Definition: pyfbsdk_generated.h:13745
Story Track class.
Definition: pyfbsdk_generated.h:18315
Time data structure.
Definition: pyfbsdk_generated.h:19596
Python built-in int class.
Definition: pyfbsdk.h:59
Python built-in string class.
Definition: pyfbsdk.h:77
int FBMessageBox(str pBoxTitle, str pMessage, str pButton1Str, str pButton2Str=None, str pButton3Str=None, int pDefaultButton=0, int pScrolledMessage=0)
Dialog popup box.