SequenceMgr.js 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179
  1. /*
  2. SEQUENCE GROUPING MANAGEMENT MODULE
  3. this module builds a representation of a sequence in values using containers
  4. It allows to create groups of keys, a group being a cue and one key per layer.
  5. In a group, all keys sync their time on cue's time, only value can be modified
  6. The sequence with grouping can then be exported and reloaded.
  7. The module checks periodicaly if timeline sequence structure (cues, layers and keys) and
  8. module values structure are in sync. If out of sync, you may either rebuild values structure
  9. from sequence or rebuild sequence from values
  10. */
  11. var syncRatems = 100;
  12. var syncDelta = 0.;
  13. var doSync = false ;
  14. var inibValuesChanged = false ;
  15. var doSyncKeysCues = false ;
  16. var saveFile = script.addFileParameter("auto save sequence","");
  17. var saveRatems = 30;
  18. var saveDelta = 0.;
  19. var debug = true;
  20. var debugFile;
  21. var parametersPath = local.getChild("parameters") ;
  22. var sequence = '' ;
  23. var sequencePath = local.getChild("parameters").sequence ;
  24. var file ;
  25. var filePath = local.parameters.sequenceFile ;
  26. var newGroupLayers = local.values.newGroup.layers ;
  27. // var groups = local.getChild("values").groups ;
  28. var cues = local.getChild("values").keys.cues ;
  29. // var cuesList = []; //holds cues containers reference
  30. var layers = local.getChild("values").keys.layers ;
  31. // var layerList = {}; //holds layer container as object with reference and an array of keys containers references
  32. var rebuildValues = script.addTrigger("rebuild values", "adds a key at current cursor position" );
  33. var refreshKeys = script.addTrigger("refresh keys", "truc");
  34. var TrigprintKeys = script.addTrigger("printKeys","truc");
  35. var clearSeq = script.addTrigger("clear Sequence","truc");
  36. var UIposGet = script.addTrigger("get UIPos", "");
  37. var viewZoom = script.addFloatParameter("View Zoom", "", 0.5, 0., 1.); //part of sequence time to show
  38. var viewFollowCursor = script.addBoolParameter("follow Cursor", "", false);
  39. var followCursor = false ;
  40. var followZoom = 0.5 ;
  41. var followRatems = 1.;
  42. var followDelta = 0.;
  43. // var sequence_structure = { params: {},
  44. // groups:{},
  45. // keys:{
  46. // cues:{},
  47. // layers:{}
  48. // }
  49. // };
  50. //WAS tl_groups
  51. /*group0 : { inCue : {pan : "key", tilt : "key", zoom : "key", dim : "key", focus : "key"},
  52. outCue : {pan : "key", tilt : "key", zoom : "key", dim : "key", focus : "key"}
  53. }*/
  54. ///////////////////// SCRIPT FUNCTIONS //////////////////////////////
  55. function init() {
  56. script.log("LOADED SEQUENCE GROUPING MANAGEMENT MODULE ");
  57. //adapt update rate
  58. updateSyncRate();
  59. updateSynchronize();
  60. // script.log(root.sequences.truc.viewStartTime.get();)
  61. saveFile.set("sequence_autosave.json");
  62. saveFile.setAttribute("readonly", true);
  63. // importSequenceFile(saveFile);
  64. // var audioLayer = root.sequences.truc.layers.audio ;
  65. // var newClip = audioLayer.clips.addItem();
  66. // newClip.filePath.set("/home/titi/work/media/Sons/Mono/Aaaah.wav");
  67. // newClip.setName("testAudio");
  68. // newClip.startTime.set(12);
  69. // printMethodsAndProperties(root.sequences.truc);
  70. // script.log(local.getChild("values").groups.group0.cue.get());
  71. //test if a sequence is already choosen else refresh and unlock sequence enum
  72. sequence = local.getChild("parameters").sequence.getKey();
  73. // var sequenceIndex = local.getChild("parameters").sequence.get();
  74. // script.log(sequenceIndex + " " + sequence);
  75. if(sequence == ""){refreshSequenceEnum();}
  76. else{
  77. sequencePath.removeOptions();
  78. sequencePath.addOption(sequence,0);
  79. sequencePath.setAttribute("readonly", true);
  80. }
  81. sequence = local.getChild("parameters").sequence.getKey();
  82. seq_readZoomValue();
  83. }
  84. function scriptParameterChanged(param){
  85. if (param.is(TrigprintKeys) ){printKeys();}
  86. else if(param.is(viewZoom)) {
  87. script.log("view zoom changed");
  88. followZoom = param.get();
  89. }
  90. if (param.is(viewFollowCursor)){
  91. script.log("follow cursor " + (param.get() ? "ON" : "OFF"));
  92. followCursor = param.get();
  93. }
  94. else if(param.is(rebuildValues)){struct_updateValuesFromSeq();}
  95. else if (param.is(refreshKeys)){
  96. script.log("refreshKeys");
  97. refreshKeysList();
  98. }
  99. else {script.log("scriptparamchanged" + param.name);}
  100. }
  101. function update(deltaTime){
  102. if(sequence!=""){
  103. // script.log(doSync);
  104. if(doSync){
  105. syncDelta += deltaTime ;
  106. // script.log(doSync);
  107. if (syncDelta >= syncRatems){
  108. syncDelta = 0. ;
  109. var autosave = struct_updateValuesFromSeq();
  110. if(autosave){exportSequenceFile(saveFile);}
  111. }
  112. }
  113. // saveDelta += deltaTime ;
  114. // if (saveDelta >= saveRatems){
  115. // saveDelta = 0. ;
  116. // exportSequenceFile(saveFile);
  117. // script.log("sequence autosave");
  118. // }
  119. followDelta += deltaTime ;
  120. if(followCursor && (followDelta>followRatems)){
  121. followDelta = 0. ;
  122. seq_followCursor() ;
  123. }
  124. }
  125. else{script.log("no sequence selected");}
  126. }
  127. /////////////////////////// HELPERS /////////////////////////////////
  128. function printMethodsAndProperties(obj){
  129. script.log(" ");
  130. // var name = obj.getControlAddress() == undefined ? "object" : obj.getControlAddress();
  131. var name = "object";
  132. script.log(" METHODS OF " + name);
  133. var methods = util.getObjectMethods(obj);
  134. for(var i=0 ; i<methods.length ; i++){
  135. script.log(" "+ methods[i]);
  136. }
  137. script.log(" PARAMETERS OF " + name);
  138. var props = util.getObjectProperties(obj, true, false);
  139. for(var i=0 ; i<props.length ; i++){
  140. script.log(" "+ props[i]);
  141. }
  142. script.log(" OBJECTS OF " + name);
  143. var props = util.getObjectProperties(obj, false, true);
  144. for(var i=0 ; i<props.length ; i++){
  145. script.log(" "+ props[i]);
  146. }
  147. }
  148. function printKeys(){
  149. var seq = root.sequences.sequence.layers.mapping.automation.getItems() ;
  150. if(seq.length){
  151. for(var i=0; i<seq.length; i++){
  152. script.log (">> "+seq[i].name + " " + seq[i].position.get() + " " + seq[i].listSize.get() );
  153. }
  154. }
  155. else{script.log("nothing to print");}
  156. }
  157. /////////////////////// PARAMETERS FUNCTIONS ///////////////////////
  158. // Module callback
  159. function moduleParameterChanged(param){
  160. parametersPath = local.getChild("parameters") ;
  161. script.log("received module param :" + param.name);
  162. if (param.is(parametersPath.importExport.sequenceFile)) {}
  163. else if (param.is(parametersPath.importExport.importSequence)){importSequenceFile(parametersPath.importExport.sequenceFile);}
  164. else if (param.is(parametersPath.importExport.exportSequence)) {
  165. exportSequenceFile(parametersPath.importExport.sequenceFile);
  166. exportSequenceFile(saveFile);
  167. }
  168. else if (param.is(parametersPath.synchronize)){updateSynchronize();}
  169. else if (param.is(parametersPath.syncRate)){updateSyncRate();}
  170. else if (param.is(parametersPath.monitorKeysCues)){monitorKeysCues();}
  171. else if (param.is(parametersPath.clearSequence)){seq_clearSequence();}
  172. else if (param.is(parametersPath.reorderSequence)){seq_reorderSequence();}
  173. else if (param.is(parametersPath.changeSequence)){refreshSequenceEnum();}
  174. else if (param.is(parametersPath.sequence)){
  175. sequence = sequencePath.getKey();
  176. if(sequence!=""){
  177. script.log("watching "+ sequence);
  178. local.parameters.sequence.setAttribute("readonly",true);
  179. }
  180. }
  181. else{script.log("received module param :" + param.name);}
  182. }
  183. function updateSynchronize(){
  184. // var parametersPath = local.getChild("parameters") ;
  185. doSync = parametersPath.synchronize.get();
  186. script.log(doSync ? "sync ON" : "sync OFF" );
  187. }
  188. function updateSyncRate(){
  189. // var parametersPath = local.getChild("parameters") ;
  190. syncRatems = parametersPath.syncRate.get() / 1000.;
  191. script.log("new sync rate : " + syncRatems);
  192. // script.setUpdateRate(syncRatems);
  193. }
  194. function monitorKeysCues(){
  195. // var parametersPath = local.getChild("parameters") ;
  196. doSyncKeysCues = parametersPath.monitorKeysCues.get() ;
  197. script.log(doSyncKeysCues ? "syncKeys ON" : "syncKeys OFF" );
  198. // script.setUpdateRate(syncRatems);
  199. }
  200. //refresh Enum
  201. function refreshSequenceEnum(){
  202. script.log("refresh list of sequences");
  203. local.parameters.sequence.setAttribute("readonly",false);
  204. if(root.sequences.getItems().length){
  205. local.parameters.sequence.removeOptions();
  206. local.parameters.sequence.addOption("", 0);
  207. for(var i=0 ; i<root.sequences.getItems().length ; i++ ){
  208. local.parameters.sequence.addOption(root.sequences.getItems()[i].name,i+1);
  209. }
  210. }
  211. }
  212. function importSequenceFile(loadFile){
  213. doSync = false ;
  214. script.log("loading file "+loadFile.get());
  215. loadData = loadFile.readFile(true);
  216. //load parameters
  217. var parameters = local.getChild("parameters");
  218. parameters.syncRate.set(loadData.parameters['Sync Rate']);
  219. parameters.synchronize.set(loadData.parameters['Synchronize']);
  220. parameters.monitorKeysCues.set(loadData.parameters['monitorKeysCues']);
  221. sequence = loadData.parameters.Sequence;
  222. if(true){
  223. parameters.sequence.removeOptions();
  224. parameters.sequence.addOption(sequence,0);
  225. parameters.sequence.setAttribute("readonly", true);
  226. // script.log(parameters.synchronize.get());
  227. //
  228. //check if Sequence already exists in sequences manager, else create it
  229. var tl_sequence = root.sequences.getItemWithName(sequence) ;
  230. if(tl_sequence == undefined){
  231. tl_sequence = root.sequences.addItem();
  232. tl_sequence.setName(sequence);
  233. }
  234. script.log(tl_sequence.name);
  235. //recreate cues
  236. tl_sequence.cues.removeAll();
  237. var cuesList = util.getObjectProperties(loadData.values.keys['cues'], false, true);
  238. script.log("create cues : "+ cuesList.length);
  239. if(cuesList.length){
  240. for(var i=0; i<cuesList.length; i++){
  241. var cue = tl_sequence.cues.addItem();
  242. cue.setName(cuesList[i]);
  243. cue.time.set(loadData.values.keys.cues[cuesList[i]]);
  244. script.log("created cue "+ cuesList[i]);
  245. }
  246. }
  247. //recreate layers and keys
  248. tl_sequence.layers.removeAll();
  249. printMethodsAndProperties(loadData.values.keys['layers']);
  250. var layersList = util.getObjectProperties(loadData.values.keys['layers'], true, false);
  251. script.log("create layers : "+ layersList.length);
  252. if(layersList.length){
  253. for(var i=0; i<layersList.length; i++ ){
  254. var layerType = loadData.values.keys.layers[layersList[i]].type ;
  255. var layer = tl_sequence.layers.addItem(layerType);
  256. script.log("create layer : ("+ layerType+") "+layersList[i]);
  257. layer.setName(layersList[i]);
  258. var keysList = util.getObjectProperties(loadData.values.keys.layers[layersList[i]], true, false);
  259. script.log("create keys : "+ keysList.length);
  260. if(keysList.length){
  261. if (layerType != "Audio"){
  262. for(var j=0; j<keysList.length; j++){
  263. var key = layer.automation.addItem();
  264. key.setName(keysList[j]);
  265. key.value.set(loadData.values.keys.layers[layersList[i]][keysList[j]].value);
  266. key.position.set(loadData.values.keys.layers[layersList[i]][keysList[j]].time);
  267. }
  268. layer.automation.reorderItems();
  269. }
  270. else {
  271. for(var j=0; j<keysList.length; j++){
  272. var clip = layer.clips.addItem();
  273. clip.setName(keysList[j]);
  274. clip.filePath.set(loadData.values.keys.layers[layersList[i]][keysList[j]].filePath);
  275. clip.startTime.set(loadData.values.keys.layers[layersList[i]][keysList[j]].startTime);
  276. }
  277. }
  278. }
  279. }
  280. }
  281. //recreate groups
  282. var groupList = util.getObjectProperties(loadData.values.groups, true, false);
  283. if(groupList.length){
  284. for(var i=0; i<groupList.length; i++){
  285. var group = local.getChild("Values").groups.addContainer(groupList[i]);
  286. var groupLayers = util.getObjectProperties(loadData.values.groups[groupList[i]], true, false);
  287. var cue = group.addFloatParameter("cue", "", 0., 0.);
  288. group.setName(groupList[i]);
  289. cue.set(loadData.values.groups[groupList[i]].time);
  290. if(loadData.values.groups[groupList[i]].timeOut!=undefined){
  291. var cueOut = group.addFloatParameter("cueOut", "", 0., 0.);
  292. cueOut.set(loadData.values.groups[groupList[i]].timeOut);
  293. }
  294. var groupKeysList = util.getObjectProperties(loadData.values.groups[groupList[i]].groupKeys, true, false);
  295. if (groupKeysList.length){
  296. var keysContainer = group.addContainer("keys");
  297. keysContainer.setCollapsed(true);
  298. var keysContainerOut ;
  299. if(loadData.values.groups[groupList[i]].timeOut!=undefined){
  300. keysContainerOut = group.addContainer("keysOut");
  301. }
  302. for (var j=0; j<groupKeysList.length; j++){
  303. group.addFloatParameter(groupKeysList[j], "", 0., 0., 1.);
  304. keysContainer.addStringParameter(groupKeysList[j], "", loadData.values.groups[groupList[i]]['groupKeys'][groupKeysList[j]]['key']);
  305. if(loadData.values.groups[groupList[i]].timeOut!=undefined){
  306. keysContainerOut.addStringParameter(groupKeysList[j], "", loadData.values.groups[groupList[i]]['groupKeys'][groupKeysList[j]]['key']+"o");
  307. }
  308. }
  309. }
  310. }
  311. }
  312. // script.log(layersList[0]);
  313. // updateSynchronize() ;
  314. }
  315. doSync = true;
  316. }
  317. function exportSequenceFile(fileObj){
  318. script.log("exporting file");
  319. var exportData = {parameters:{}, values:{groups:{}, keys:{cues:{}, layers:{}}}};
  320. //collect parameters
  321. var parameters = local.getChild("parameters");
  322. exportData.parameters["Sequence"] = parameters.sequence.getKey();
  323. exportData.parameters["Synchronize"] = parameters.synchronize.get();
  324. exportData.parameters["Sync Rate"] = parameters.syncRate.get();
  325. exportData.parameters["monitorKeysCues"] = parameters.monitorKeysCues.get();
  326. //collect values
  327. var values = local.getChild("values");
  328. //groups
  329. var groups = values.groups;
  330. var groupsList=util.getObjectProperties(groups, true, false);
  331. if(groupsList.length){
  332. for(var i=0; i<groupsList.length; i++){
  333. var exportGroup = exportData.values.groups[groupsList[i]] = {cue:"", time:0., groupKeys:{}};
  334. var currentGroup = groups.getChild(groupsList[i]);
  335. exportGroup.cue = currentGroup.name;
  336. exportGroup.time = currentGroup.cue.get();
  337. var isInOut = currentGroup.getChild("keysOut") ;
  338. if(isInOut){
  339. exportGroup.cueOut = currentGroup.name+"o";
  340. exportGroup.timeOut = currentGroup.cueOut.get();
  341. }
  342. var currentGroupLayers = util.getObjectProperties(currentGroup.keys, true, false);
  343. if (currentGroupLayers.length){
  344. for(var j=0; j<currentGroupLayers.length; j++){
  345. // script.log(groupsList[i]+ " "+ currentGroupLayers[j]);
  346. exportGroup.groupKeys[currentGroupLayers[j]] = {key:"", value:0};
  347. exportGroup.groupKeys[currentGroupLayers[j]].value = currentGroup.getChild(currentGroupLayers[j]).get();
  348. exportGroup.groupKeys[currentGroupLayers[j]].key = currentGroup.keys.getChild(currentGroupLayers[j]).get();
  349. }
  350. }
  351. }
  352. }
  353. // var cues = values.keys.cues;
  354. // var cuesList=util.getObjectProperties(cues, true, false);
  355. // if(cuesList.length){
  356. // for(var i=0; i<cuesList.length; i++){
  357. // var exportCue = exportData.values.keys.cues[cuesList[i]] = {cue:"", time:0.};
  358. // exportCue.cue = cuesList[i];
  359. // exportCue.time = cues.getChild(cuesList[i]).time.get();
  360. // }
  361. // }
  362. // var layers = values.keys.layers;
  363. // var layersList=util.getObjectProperties(layers, true, false);
  364. // if(layersList.length){
  365. // for(var i=0; i<layersList.length; i++){
  366. // var exportLayer = exportData.values.keys.layers[layersList[i]] = {};
  367. // var currentLayer = layers.getChild(layersList[i]);
  368. // var currentLayersKeys = util.getObjectProperties(currentLayer, true, false);
  369. // exportLayer["type"] = values.keys.layerTypes.getChild(layersList[i]).get();
  370. // if (currentLayersKeys.length){
  371. // for(var j=0; j<currentLayersKeys.length; j++){
  372. // if (exportLayer["type"]!= "Audio"){
  373. // if(currentLayersKeys[j]!="type"){
  374. // // script.log(currentLayersKeys[j]);
  375. // // script.log(groupsList[i]+ " "+ currentGroupLayers[j]);
  376. // exportLayer[currentLayersKeys[j]] = {key:"", value:0., time:0.};
  377. // exportLayer[currentLayersKeys[j]].value = currentLayer.getChild(currentLayersKeys[j]).value.get();
  378. // exportLayer[currentLayersKeys[j]].key = currentLayer.getChild(currentLayersKeys[j]).name;
  379. // exportLayer[currentLayersKeys[j]].time = currentLayer.getChild(currentLayersKeys[j]).time.get();
  380. // }
  381. // }
  382. // else {
  383. // exportLayer[currentLayersKeys[j]] = {clip:"", filePath:0., startTime:0.};
  384. // exportLayer[currentLayersKeys[j]].filePath = currentLayer.getChild(currentLayersKeys[j]).filePath.get();
  385. // exportLayer[currentLayersKeys[j]].clip = currentLayer.getChild(currentLayersKeys[j]).name;
  386. // exportLayer[currentLayersKeys[j]].startTime = currentLayer.getChild(currentLayersKeys[j]).startTime.get();
  387. // }
  388. // }
  389. // }
  390. // }
  391. // }
  392. //export cues and layers from tl
  393. var tl_seq = root.sequences.getItemWithName(sequence);
  394. var tl_cues = tl_seq.cues.getItems();
  395. if (tl_cues.length){
  396. for(var i=0; i<tl_cues.length; i++){
  397. exportData.values.keys.cues[tl_cues[i].name] = tl_cues[i].time.get();
  398. }
  399. }
  400. var tl_layers = tl_seq.layers.getItems();
  401. if (tl_layers.length){
  402. for(var i=0; i<tl_layers.length; i++){
  403. exportData.values.keys.layers[tl_layers[i].name] = {type:tl_layers[i].getType()};
  404. if(tl_layers[i].getType()=="Mapping"){
  405. var keys = tl_layers[i].automation.getItems();
  406. if(keys.length){
  407. for(var j=0; j<keys.length; j++){
  408. exportData.values.keys.layers[tl_layers[i].name][keys[j].name] = {value: keys[j].value.get(), time:keys[j].position.get()};
  409. }
  410. }
  411. }
  412. else if(tl_layers[i].getType()=="Audio"){
  413. var keys = tl_layers[i].clips.getItems();
  414. if(keys.length){
  415. for(var j=0; j<keys.length; j++){
  416. exportData.values.keys.layers[tl_layers[i].name][keys[j].name] = {filePath: keys[j].filePath.get(), startTime:keys[j].startTime.get()};
  417. }
  418. }
  419. }
  420. }
  421. }
  422. // exportData.groups
  423. fileObj.writeFile(JSON.stringify(exportData), true);
  424. }
  425. /////////////////////// VALUES FUNCTIONS ///////////////////////
  426. /* Values hold all keys, presented in group containers
  427. a nogroup container shows keys that are not grouped
  428. */
  429. // Value callback
  430. function moduleValueChanged(value){
  431. if(!inibValuesChanged){
  432. doSync = false;
  433. //script.log(value.getParent().name);
  434. //here add actions for values that are also auto-updated, (groupKey values, times ets
  435. // they will prevent auto update while manipulated manually
  436. doSync = true;
  437. }
  438. if (value.is(local.values.newGroup.create)){createNewGroup();}
  439. if (value.is(local.values.newGroup.createInOut)){createNewGroup(1);}
  440. // script.log(value.getParent().name);
  441. // if(value.getParent().name = "cue"){script.log("changed");}
  442. // if (value.name == "addGroup"){createNewGroup();}
  443. }
  444. function struct_rebuildValues(){
  445. //build cues if needed
  446. var tl_cues = tl_seq.cues.getItems();
  447. cues = local.getChild("values").keys.cues ;
  448. var cuesList = util.getObjectProperties(cues, true, false);
  449. // script.log("cueList : " +cuesList.length);
  450. // script.log("tl List : " +tl_cues.length);
  451. if (cuesList.length != tl_cues.length){
  452. var delta = cuesList.length-tl_cues.length;
  453. var addRemove = delta > 0 ? false : true ; //0 to remove, 1 to add
  454. delta = Math.abs(delta);
  455. script.log("cues "+ delta + (addRemove ? " up" : " down"));
  456. for(var i=0; i<delta; i++){
  457. // script.log(i);
  458. if(addRemove){
  459. var newCue = cues.addContainer("newCue"+i);
  460. newCue.addFloatParameter("time", "position in time", 0., 0.);
  461. newCue.setCollapsed(true);
  462. }
  463. else {
  464. // script.log(util.getObjectProperties(cues, true, false)[0]);
  465. cues.removeContainer(util.getObjectProperties(cues, true, false)[i]);
  466. }
  467. // cuesList = ;
  468. }
  469. hasUpdated = true;
  470. }
  471. //update cues
  472. cues = local.getChild("values").keys.cues ;
  473. var cuesList = util.getObjectProperties(cues, true, false);
  474. if(tl_cues.length){
  475. for (var i=0; i<tl_cues.length; i++){
  476. var currentCue = cues.getChild(cuesList[i]);
  477. currentCue.setName(tl_cues[i].name);
  478. currentCue.time.set(tl_cues[i].time.get());
  479. }
  480. }
  481. //build layers if needed
  482. var layersChanged = false ;
  483. var tl_layers = tl_seq.layers.getItems();
  484. layers = local.getChild("values").keys.layers ;
  485. var layersList = util.getObjectProperties(layers, true, false);
  486. if (layersList.length != tl_layers.length){
  487. layersChanged = true ;
  488. var delta = layersList.length-tl_layers.length;
  489. var addRemove = delta > 0 ? false : true ; //0 to remove, 1 to add
  490. delta = Math.abs(delta);
  491. script.log("layers "+ delta + (addRemove ? " up" : " down"));
  492. for(var i=0; i<delta; i++){
  493. // script.log(i);
  494. if(addRemove){
  495. var newLayer = layers.addContainer("newLayer"+i);
  496. // newLayer.addFloatParameter("time", "position in time", 0., 0.);
  497. local.getChild("values").keys.layerTypes.addStringParameter("newLayer"+i, "", "");
  498. newLayer.setCollapsed(true);
  499. local.getChild("values").newGroup.layers.addFloatParameter("newLayer"+i, "value for this layer at group creation", 0., 0., 1.);
  500. // if (tl_layers[i].getType()!="Audio"){
  501. // local.getChild("values").newGroup.layers.addFloatParameter("newLayer"+i, "value for this layer at group creation", 0., 0., 1.);
  502. // }
  503. }
  504. else {
  505. // script.log(util.getObjectProperties(layers, true, false)[0]);
  506. layers.removeContainer(util.getObjectProperties(layers, true, false)[i]);
  507. local.getChild("values").newGroup.layers.removeParameter(util.getObjectProperties(layers, true, false)[i]);
  508. local.getChild("values").newGroup.layers.setCollapsed(true);
  509. local.getChild("values").newGroup.layers.setCollapsed(false);
  510. local.getChild("values").keys.layerTypes.removeParameter(util.getObjectProperties(layers, true, false)[i]);
  511. local.getChild("values").keys.layerTypes.setCollapsed(true);
  512. local.getChild("values").keys.layerTypes.setCollapsed(false);
  513. }
  514. // cuesList = ;
  515. }
  516. hasUpdated = true;
  517. }
  518. //update layers value if there was a change in structure
  519. if(layersChanged){
  520. layers = local.getChild("values").keys.layers ;
  521. var layerList = util.getObjectProperties(layers, true, false);
  522. layerTypes = local.getChild("values").keys.layerTypes ;
  523. var layerTypeList = util.getObjectProperties(layerTypes, true, false);
  524. var template = local.getChild("values").newGroup.layers;
  525. var layerTemplate = util.getObjectProperties(template, true, false);
  526. if(tl_layers.length){
  527. var layer_offset = 0 ;
  528. for (var i=0; i<tl_layers.length; i++){
  529. var currentLayer = layers.getChild(layerList[i]);
  530. // currentLayer.getChild("type").set(tl_layers[i].getType());
  531. currentLayer.setName(tl_layers[i].name);
  532. var currentLayerType = layerTypes.getChild(layerTypeList[i]);
  533. currentLayerType.setName(tl_layers[i].name);
  534. currentLayerType.set(tl_layers[i].getType());
  535. var currentTemplate = template.getChild(layerTemplate[i]) ;
  536. if (tl_layers[i].getType()=="Audio"){layer_offset+=1;}
  537. currentTemplate.setName(tl_layers[i+layer_offset].name);
  538. }
  539. }
  540. }
  541. //build keys if needed
  542. layers = local.getChild("values").keys.layers ;
  543. layersList = util.getObjectProperties(layers, true, false);
  544. if(layersList.length){
  545. for(var layerIndex=0; layerIndex<layersList.length; layerIndex++){
  546. // script.log(layersList[layerIndex]);
  547. var currentLayer = layers.getChild(layersList[layerIndex]);
  548. var keyList = util.getObjectProperties(currentLayer, true, false);
  549. var tl_lay = tl_seq.layers.getItemWithName(layersList[layerIndex]);
  550. var tl_keys;
  551. //test keys for automation layers
  552. if(tl_lay.automation!=undefined){
  553. tl_keys = tl_lay.automation.getItems();
  554. //rebuild key structure for currentLayer
  555. if (keyList.length != tl_keys.length){
  556. var delta = keyList.length-tl_keys.length;
  557. var addRemove = delta > 0 ? false : true ; //0 to remove, 1 to add
  558. delta = Math.abs(delta);
  559. script.log("keys "+ delta + (addRemove ? " up" : " down"));
  560. for(var i=0; i<delta; i++){
  561. // script.log(i);
  562. if(addRemove){
  563. var newKey = currentLayer.addContainer("newkey"+i);
  564. newKey.addFloatParameter("time", "position in time", 0., 0.);
  565. newKey.addFloatParameter("value", "vertical value", 0., 0.);
  566. newKey.setCollapsed(true);
  567. }
  568. else {
  569. // script.log(util.getObjectProperties(currentLayer, true, false)[0]);
  570. currentLayer.removeContainer(util.getObjectProperties(currentLayer, true, false)[i]);
  571. }
  572. }
  573. hasUpdated = true;
  574. }
  575. }
  576. //test clips for audio layer
  577. var tl_clips ;
  578. if(tl_lay.clips!=undefined){
  579. tl_clips = tl_lay.clips.getItems();
  580. //rebuild key structure for currentLayer, "keyList" holds clips
  581. if (keyList.length != tl_clips.length){
  582. var delta = keyList.length-tl_clips.length;
  583. var addRemove = delta > 0 ? false : true ; //0 to remove, 1 to add
  584. delta = Math.abs(delta);
  585. script.log("clips "+ delta + (addRemove ? " up" : " down"));
  586. for(var i=0; i<delta; i++){
  587. // script.log(i);
  588. if(addRemove){
  589. var newClip = currentLayer.addContainer("newclip"+i);
  590. newClip.addFileParameter("File Path", "sound file");
  591. newClip.addFloatParameter("start Time", "", 0., 0.);
  592. newClip.setCollapsed(true);
  593. }
  594. else {
  595. // script.log(util.getObjectProperties(currentLayer, true, false)[0]);
  596. currentLayer.removeContainer(util.getObjectProperties(currentLayer, true, false)[i]);
  597. }
  598. }
  599. hasUpdated = true;
  600. }
  601. }
  602. currentLayer = layers.getChild(layersList[layerIndex]);
  603. keyList = util.getObjectProperties(currentLayer, true, false);
  604. //update values for currentLayer
  605. if(tl_keys.length){
  606. for(var i=0; i<tl_keys.length; i++){
  607. var currentKey = currentLayer.getChild(keyList[i]);
  608. currentKey.setName(tl_keys[i].name);
  609. currentKey.time.set(tl_keys[i].position.get());
  610. currentKey.value.set(tl_keys[i].value.get());
  611. }
  612. }
  613. if(tl_clips.length){
  614. for(var i=0; i<tl_clips.length; i++){
  615. var currentKey = currentLayer.getChild(keyList[i]);
  616. currentKey.setName(tl_clips[i].name);
  617. currentKey.filePath.set(tl_clips[i].filePath.get());
  618. currentKey.startTime.set(tl_clips[i].startTime.get());
  619. }
  620. }
  621. }
  622. }
  623. }
  624. function struct_rebuildGroupLayers(){
  625. var tl_layers = tl_seq.layers.getItems();
  626. layers = local.getChild("values").newGroup.layers ;
  627. var layersList = util.getObjectProperties(layers, true, false);
  628. if (layersList.length != tl_layers.length){
  629. var delta = layersList.length-tl_layers.length;
  630. var addRemove = delta > 0 ? false : true ; //0 to remove, 1 to add
  631. delta = Math.abs(delta);
  632. script.log("Group layers "+ delta + (addRemove ? " up" : " down"));
  633. for(var i=0; i<delta; i++){
  634. // script.log(i);
  635. if(addRemove){
  636. local.getChild("values").newGroup.layers.addFloatParameter("newLayer"+i, "value for this layer at group creation", 0., 0., 1.);
  637. }
  638. else {
  639. local.getChild("values").newGroup.layers.removeParameter(util.getObjectProperties(layers, true, false)[i]);
  640. local.getChild("values").newGroup.layers.setCollapsed(true);
  641. local.getChild("values").newGroup.layers.setCollapsed(false);
  642. }
  643. // cuesList = ;
  644. }
  645. }
  646. var template = local.getChild("values").newGroup.layers;
  647. var layerTemplate = util.getObjectProperties(template, true, false);
  648. if(tl_layers.length){
  649. for (var i=0; i<tl_layers.length; i++){
  650. var currentTemplate = template.getChild(layerTemplate[i]) ;
  651. currentTemplate.setName(tl_layers[i].name);
  652. }
  653. }
  654. }
  655. //rebuild values.keys structure from sequence
  656. function struct_updateValuesFromSeq(){
  657. inibValuesChanged = true;
  658. var hasUpdated = false ;
  659. var tl_seq = root.sequences.getItemWithName(sequence);
  660. if(tl_seq.name!="undefined"){
  661. //Sync values structure
  662. if(doSyncKeysCues) {struct_rebuildValues();}
  663. else{struct_rebuildGroupLayers();}
  664. //Groups management
  665. tl_seq = root.sequences.getItemWithName(sequence);
  666. var groups = local.getChild("values").groups ;
  667. var groupList = util.getObjectProperties(groups, true, false);
  668. // printMethodsAndProperties(tl_seq.cues.getItemWithName("group0"));
  669. if(groupList.length){
  670. for (var i = 0; i<groupList.length; i++){
  671. //check if cue exist, else remove group
  672. // script.log(groupList[i]);
  673. //v1, remove cue doesn't remove group keys
  674. // var groupCue = tl_seq.cues.getItemWithName(groupList[i]);
  675. // if(groupCue.name==undefined){
  676. // script.log("cue " + groupList[i] + "not found, removing group (keys survive this)");
  677. // groups.removeContainer(groupList[i]);
  678. // hasUpdated = true;
  679. // break;
  680. // }
  681. //check if group has out
  682. var isInOut = groups.getChild(groupList[i]).getChild("keysOut") ;
  683. //v2, remove cue removes group keys
  684. var groupCue = tl_seq.cues.getItemWithName(groupList[i]);
  685. if(groupCue.name==undefined){
  686. script.log("cue " + groupList[i] + "not found, removing keys and group");
  687. if(isInOut){tl_seq.cues.removeItem(groupList[i]+"o");}
  688. var groupToRemove = groups.getChild(groupList[i]);
  689. var groupToRemoveKeyslist = util.getObjectProperties(groupToRemove.keys, true, false);
  690. for(var removeKeyIndex = 0; removeKeyIndex< groupToRemoveKeyslist.length; removeKeyIndex++) {
  691. var tl_removeLayer = tl_seq.layers.getItemWithName( groupToRemoveKeyslist[removeKeyIndex]) ;
  692. var tl_removeKey = tl_removeLayer.automation.getItemWithName(groupToRemove.keys.getChild( groupToRemoveKeyslist[removeKeyIndex]).get());
  693. // script.log(tl_removeKey.name);
  694. tl_removeLayer.automation.removeItem(tl_removeKey);
  695. var tl_removeKeyOut ;
  696. if(isInOut) {
  697. tl_removeKeyOut = tl_removeLayer.automation.getItemWithName(groupToRemove.keys.getChild( groupToRemoveKeyslist[removeKeyIndex]).get()+"o");
  698. tl_removeLayer.automation.removeItem(tl_removeKeyOut);
  699. }
  700. }
  701. groups.removeContainer(groupList[i]);
  702. hasUpdated = true;
  703. break;
  704. }
  705. //else check at key level
  706. else {
  707. groups = local.getChild("values").groups ;
  708. groupList = util.getObjectProperties(groups, true, false);
  709. var currentGroup = groups.getChild(groupList[i]);
  710. var currentGroupLayers = util.getObjectProperties (currentGroup.keys, true, false);
  711. //update cue time
  712. var groupTime = groupCue.time.get();
  713. currentGroup.cue.set(groupTime);
  714. var groupCueOut;
  715. var groupTimeOut ;
  716. if(isInOut){
  717. groupCueOut = tl_seq.cues.getItemWithName(groupList[i]+"o");
  718. groupTimeOut = groupCueOut.time.get();
  719. currentGroup.cueOut.set(groupTimeOut);
  720. }
  721. if (currentGroupLayers.length){
  722. // script.log(currentGroupLayers.length);
  723. for(var j=0; j<currentGroupLayers.length; j++){
  724. // script.log("in loop" + j);
  725. groups = local.getChild("values").groups ;
  726. groupList = util.getObjectProperties(groups, true, false);
  727. currentGroup = groups.getChild(groupList[i]);
  728. currentGroupLayers = util.getObjectProperties (currentGroup.keys, true, false);
  729. var tl_layer = tl_seq.layers.getItemWithName(currentGroupLayers[j]);
  730. var keyName = currentGroup.keys.getChild(tl_layer.name).get();
  731. // script.log(tl_layer.name + " " +tl_layer.automation.getItemWithName(keyName).name);
  732. //if key dosn't exist anymore, remove it from group
  733. // if(tl_layer.automation.getItemWithName(keyName).name == undefined){
  734. // groups = local.getChild("values").groups ;
  735. // groupList = util.getObjectProperties(groups, true, false);
  736. // currentGroup = groups.getChild(groupList[i]);
  737. // currentGroupLayers = util.getObjectProperties (currentGroup.keys, true, false);
  738. // tl_layer = tl_seq.layers.getItemWithName(currentGroupLayers[j]);
  739. // keyName = currentGroup.keys.getChild(tl_layer.name).get();
  740. // script.log("should remove" + currentGroup.name + " " + currentGroupLayers[j]);
  741. // currentGroup.keys.removeParameter(currentGroupLayers[j]);
  742. // currentGroup.removeParameter(currentGroupLayers[j]);
  743. // currentGroup.setCollapsed(true);
  744. // currentGroup.setCollapsed(false);
  745. // hasUpdated = true;
  746. // }
  747. //if key exists, update value from tl and update time from group cue
  748. if(tl_layer.automation.getItemWithName(keyName).name != undefined){
  749. //apply groupTime
  750. var tl_key = tl_layer.automation.getItemWithName(keyName);
  751. tl_key.position.set(groupTime);
  752. //get tl value
  753. var keyValue = tl_key.value.get();
  754. var currentKey = currentGroup.getChild(tl_layer.name);
  755. // script.log(tl_layer.name + " " +keyName+" " + keyValue);
  756. // script.log(currentKey.name + " " +keyName+" " + keyValue);
  757. currentKey.set(keyValue);
  758. // script.log(currentKey.get());
  759. if(isInOut){
  760. var tl_keyOut = tl_layer.automation.getItemWithName(keyName+"o");
  761. tl_keyOut.position.set(groupTimeOut);
  762. //set keyOut value to keyIn value
  763. tl_keyOut.value.set(keyValue);
  764. }
  765. }
  766. }
  767. }
  768. // //if cue doesn't exist, remove whole group
  769. // if(tl_layers.length){
  770. // for (var j=0; j<tl_layers.length; j++){
  771. // if(!tl_layers[j].automation.getItemWithName(groupList[i])){
  772. // script.log("key " + groupList[i] + "not found, removing group (keys survive this)");
  773. // groups.removeContainer(groupList[i]);}
  774. // hasUpdated = true;
  775. // }
  776. // }
  777. //update group values
  778. }
  779. }
  780. }
  781. inibValuesChanged = false;
  782. return hasUpdated;
  783. }
  784. }
  785. // function rebuildValuesStructure() {
  786. // script.log("updating values structure");
  787. // //empty current structure
  788. // // local.values.removeAll();
  789. // local.getChild("Values").removeContainer("newGroup");
  790. // local.getChild("Values").removeContainer("groups");
  791. // local.getChild("Values").removeContainer("ungrouped");
  792. // //rebuild containers
  793. // var ng_cont = local.values.addContainer("New group");
  794. // var g_cont = local.values.addContainer("groups");
  795. // var ug_cont = local.values.addContainer("ungrouped");
  796. // // rebuild new group
  797. // ng_cont.addTrigger("add group", "adds a new group at cursor time with below values");
  798. // ng_cont.addFloatParameter("group time", "time position where the group will be created ", 0., 0.);
  799. // var layer_cont = ng_cont.addContainer("layers values");
  800. // var layers = util.getObjectProperties(sequence_structure.keys.layers) ;
  801. // for (var i=0; i<layers.length; i++){
  802. // //add a float value in each layer for group creation
  803. // layer_cont.addFloatParameter(layers[i], "", 0., 0., 1.);
  804. // ug_cont.addContainer(layers[i]);
  805. // }
  806. // //rebuild keys grouped/ungrouped
  807. // //first create group containers in groups
  808. // // //then create layer containers in ungrouped
  809. // // var layer_cont = ug_cont.addContainer("layers values");
  810. // }
  811. /////////////////////// TIMELINE FUNCTIONS ///////////////////////
  812. function seq_clearSequence(){
  813. var seq = root.sequences.getItemWithName(sequence) ;
  814. script.log("clearing all keys and cues of sequence : "+seq.name);
  815. seq.cues.removeAll();
  816. var layers = seq.layers.getItems();
  817. if(layers.length){
  818. for (var i = 0; i<layers.length; i++){
  819. if(layers[i].automation){layers[i].automation.removeAll();}
  820. if(layers[i].clips){layers[i].clips.removeAll();}
  821. }
  822. }
  823. //clear all groups
  824. var groups = local.getChild("values").groups;
  825. var groupsList = util.getObjectProperties(groups, true, false);
  826. if (groupsList.length){
  827. for(var i=0; i<groupsList.length; i++){
  828. groups.removeContainer(groupsList[i]);
  829. }
  830. }
  831. }
  832. function seq_reorderSequence(){
  833. var seq = root.sequences.getItemWithName(sequence) ;
  834. script.log("reordering sequence : "+seq.name);
  835. var layers = seq.layers.getItems();
  836. if(layers.length){
  837. for (var i = 0; i<layers.length; i++){
  838. if(layers[i].automation){layers[i].automation.reorderItems();}
  839. if(layers[i].clips){layers[i].clips.reorderItems();}
  840. }
  841. }
  842. }
  843. //use Values structure to rebuild the sequence
  844. function seq_buildSeqFromValues(){}
  845. //use file to rebuild sequence
  846. function seq_buildSeqFromFile(){}
  847. function seq_MoveCurrentTime(deltaSeconds){
  848. var tl_seq = root.sequences.getItemWithName(sequence);
  849. var currentTime = tl_seq.currentTime.get();
  850. tl_seq.currentTime.set(currentTime + deltaSeconds);
  851. }
  852. function createNewGroup(isInOut){
  853. doSync = false ;
  854. script.log("create new group");
  855. //create a cue and a key in each layer at cursor position in selected sequence
  856. var groups = local.getChild("values").groups;
  857. var groupsList = util.getObjectProperties(groups, true, false);
  858. // var index = groupsList.length == undefined ? 0 : groupsList.length;
  859. var currentGroup;
  860. var tl_seq = root.sequences.getItemWithName(sequence);
  861. var tl_layers = tl_seq.layers.getItems();
  862. script.log(groupList.length);
  863. //Get current sequence time position and create cue at this position, with group name
  864. var currentTime = tl_seq.currentTime.get() ;
  865. // var currentTime = local.values.newGroup.groupTime.get();
  866. // script.log(currentTime);
  867. var newCue = tl_seq.cues.addItem();
  868. newCue.time.set(currentTime);
  869. //test for holes in the sequence to rename the cue
  870. for (var i=0; i<=groupsList.length+1; i++){
  871. if(tl_seq.cues.getChild(i)==undefined){
  872. newCue.setName(i);
  873. currentGroup = groups.addContainer(i);
  874. currentGroup.setCollapsed(true);
  875. script.log("create new group: "+i);
  876. break;
  877. }
  878. }
  879. currentGroup.addFloatParameter("cue", "cue of the group", currentTime, 0.);
  880. var keysContainer = currentGroup.addContainer("keys");
  881. var keysOutContainer = 0 ;
  882. if (isInOut){
  883. var newCueOut = tl_seq.cues.addItem();
  884. newCueOut.time.set(currentTime+5);
  885. newCueOut.setName(currentGroup.name+"o");
  886. currentGroup.addFloatParameter("cueOut", "cue out of the group", currentTime + 5., 0.);
  887. keysOutContainer = currentGroup.addContainer("keysOut");
  888. keysOutContainer.setCollapsed(true);
  889. }
  890. keysContainer.setCollapsed(true);
  891. tl_seq = root.sequences.getItemWithName(sequence);
  892. tl_layers = tl_seq.layers.getItems();
  893. // var struc_layers = util.getObjectProperties(sequence_structure.keys.layers);
  894. if(tl_layers.length){
  895. for(var i=0;i<tl_layers.length; i++ ){
  896. if(tl_layers[i].automation!=undefined){//only for mapping layers
  897. // script.log(sequence_structure.keys.layers[layers[i].name]);
  898. var newKey = tl_layers[i].automation.addItem();
  899. newKey.position.set(currentTime);
  900. newKey.setName(currentGroup.name);
  901. // script.log(currentGroup.name); //local.getChild("values").newGroup.layers.getChild().name
  902. newKey.value.set(local.getChild("values").newGroup.layers.getChild(tl_layers[i].name).get());
  903. // newKey.value.set(Math.random());
  904. keysContainer.addStringParameter(tl_layers[i].name, "",currentGroup.name );
  905. currentGroup.addFloatParameter(tl_layers[i].name,tl_layers[i].name+" value" , currentGroup.name, 0., 1.);
  906. // newKey.addStringParameter("group", "key is part of this group","mongroupe");
  907. if (isInOut){
  908. var newKeyOut = tl_layers[i].automation.addItem();
  909. newKeyOut.position.set(currentTime+5.);
  910. newKeyOut.setName(currentGroup.name+"o");
  911. newKeyOut.value.set(local.getChild("values").newGroup.layers.getChild(tl_layers[i].name).get());
  912. // newKey.value.set(Math.random());
  913. keysOutContainer.addStringParameter(tl_layers[i].name, "",currentGroup.name+"o" );
  914. }
  915. tl_layers[i].automation.reorderItems();
  916. }
  917. }
  918. }
  919. doSync = true ;
  920. // seq = seq.getItems();
  921. }
  922. function seq_followCursor(){
  923. var tl_seq = root.sequences.getItemWithName(sequence);
  924. var tl_cursor = tl_seq.currentTime.get();
  925. var tl_totalTime = tl_seq.totalTime.get() ;
  926. var tl_startTime = tl_seq.viewStartTime.get();
  927. var tl_endTime = tl_seq.viewEndTime.get();
  928. //first check current viewTime and modify followZoom accordingly
  929. followZoom = (tl_startTime - tl_endTime) / tl_totalTime;
  930. // if(viewZoom.get()!=followZoom && tl_startTime && (tl_endTime != tl_totalTime) ) {viewZoom.set(followZoom);script.log(viewZoom);}
  931. //then update view position
  932. followZoom = viewZoom.get();
  933. var viewTime = followZoom * tl_totalTime ;
  934. var startTime = tl_cursor - viewTime/2. ;
  935. var endTime = tl_cursor + viewTime/2. ;
  936. tl_seq.viewStartTime.set(startTime);
  937. tl_seq.viewEndTime.set(endTime);
  938. }
  939. function seq_readZoomValue(){
  940. var tl_seq = root.sequences.getItemWithName(sequence);
  941. if(tl_seq != undefined){
  942. var tl_totalTime = tl_seq.totalTime.get() ;
  943. var tl_startTime = tl_seq.viewStartTime.get();
  944. var tl_endTime = tl_seq.viewEndTime.get();
  945. followZoom = (tl_startTime - tl_endTime) / tl_totalTime;
  946. return followZoom ;
  947. }
  948. }