/* SEQUENCE GROUPING MANAGEMENT MODULE this module builds a representation of a sequence in values using containers It allows to create groups of keys, a group being a cue and one key per layer. In a group, all keys sync their time on cue's time, only value can be modified The sequence with grouping can then be exported and reloaded. The module checks periodicaly if timeline sequence structure (cues, layers and keys) and module values structure are in sync. If out of sync, you may either rebuild values structure from sequence or rebuild sequence from values */ var syncRatems = 100; var syncDelta = 0.; var doSync = false ; var inibValuesChanged = false ; var doSyncKeysCues = false ; var saveFile = script.addFileParameter("auto save sequence",""); var saveRatems = 30; var saveDelta = 0.; var debug = true; var debugFile; var parametersPath = local.getChild("parameters") ; var sequence = '' ; var sequencePath = local.getChild("parameters").sequence ; var file ; var filePath = local.parameters.sequenceFile ; var newGroupLayers = local.values.newGroup.layers ; // var groups = local.getChild("values").groups ; var cues = local.getChild("values").keys.cues ; // var cuesList = []; //holds cues containers reference var layers = local.getChild("values").keys.layers ; // var layerList = {}; //holds layer container as object with reference and an array of keys containers references var rebuildValues = script.addTrigger("rebuild values", "adds a key at current cursor position" ); var refreshKeys = script.addTrigger("refresh keys", "truc"); var TrigprintKeys = script.addTrigger("printKeys","truc"); var clearSeq = script.addTrigger("clear Sequence","truc"); var UIposGet = script.addTrigger("get UIPos", ""); var viewZoom = script.addFloatParameter("View Zoom", "", 0.5, 0., 1.); //part of sequence time to show var viewFollowCursor = script.addBoolParameter("follow Cursor", "", false); var followCursor = false ; var followZoom = 0.5 ; var followRatems = 1.; var followDelta = 0.; // var sequence_structure = { params: {}, // groups:{}, // keys:{ // cues:{}, // layers:{} // } // }; //WAS tl_groups /*group0 : { inCue : {pan : "key", tilt : "key", zoom : "key", dim : "key", focus : "key"}, outCue : {pan : "key", tilt : "key", zoom : "key", dim : "key", focus : "key"} }*/ ///////////////////// SCRIPT FUNCTIONS ////////////////////////////// function init() { script.log("LOADED SEQUENCE GROUPING MANAGEMENT MODULE "); //adapt update rate updateSyncRate(); updateSynchronize(); // script.log(root.sequences.truc.viewStartTime.get();) saveFile.set("sequence_autosave.json"); saveFile.setAttribute("readonly", true); // importSequenceFile(saveFile); // var audioLayer = root.sequences.truc.layers.audio ; // var newClip = audioLayer.clips.addItem(); // newClip.filePath.set("/home/titi/work/media/Sons/Mono/Aaaah.wav"); // newClip.setName("testAudio"); // newClip.startTime.set(12); // printMethodsAndProperties(root.sequences.truc); // script.log(local.getChild("values").groups.group0.cue.get()); //test if a sequence is already choosen else refresh and unlock sequence enum sequence = local.getChild("parameters").sequence.getKey(); // var sequenceIndex = local.getChild("parameters").sequence.get(); // script.log(sequenceIndex + " " + sequence); if(sequence == ""){refreshSequenceEnum();} else{ sequencePath.removeOptions(); sequencePath.addOption(sequence,0); sequencePath.setAttribute("readonly", true); } sequence = local.getChild("parameters").sequence.getKey(); seq_readZoomValue(); } function scriptParameterChanged(param){ if (param.is(TrigprintKeys) ){printKeys();} else if(param.is(viewZoom)) { script.log("view zoom changed"); followZoom = param.get(); } if (param.is(viewFollowCursor)){ script.log("follow cursor " + (param.get() ? "ON" : "OFF")); followCursor = param.get(); } else if(param.is(rebuildValues)){struct_updateValuesFromSeq();} else if (param.is(refreshKeys)){ script.log("refreshKeys"); refreshKeysList(); } else {script.log("scriptparamchanged" + param.name);} } function update(deltaTime){ if(sequence!=""){ // script.log(doSync); if(doSync){ syncDelta += deltaTime ; // script.log(doSync); if (syncDelta >= syncRatems){ syncDelta = 0. ; var autosave = struct_updateValuesFromSeq(); if(autosave){exportSequenceFile(saveFile);} } } // saveDelta += deltaTime ; // if (saveDelta >= saveRatems){ // saveDelta = 0. ; // exportSequenceFile(saveFile); // script.log("sequence autosave"); // } followDelta += deltaTime ; if(followCursor && (followDelta>followRatems)){ followDelta = 0. ; seq_followCursor() ; } } else{script.log("no sequence selected");} } /////////////////////////// HELPERS ///////////////////////////////// function printMethodsAndProperties(obj){ script.log(" "); // var name = obj.getControlAddress() == undefined ? "object" : obj.getControlAddress(); var name = "object"; script.log(" METHODS OF " + name); var methods = util.getObjectMethods(obj); for(var i=0 ; i> "+seq[i].name + " " + seq[i].position.get() + " " + seq[i].listSize.get() ); } } else{script.log("nothing to print");} } /////////////////////// PARAMETERS FUNCTIONS /////////////////////// // Module callback function moduleParameterChanged(param){ parametersPath = local.getChild("parameters") ; script.log("received module param :" + param.name); if (param.is(parametersPath.importExport.sequenceFile)) {} else if (param.is(parametersPath.importExport.importSequence)){importSequenceFile(parametersPath.importExport.sequenceFile);} else if (param.is(parametersPath.importExport.exportSequence)) { exportSequenceFile(parametersPath.importExport.sequenceFile); exportSequenceFile(saveFile); } else if (param.is(parametersPath.synchronize)){updateSynchronize();} else if (param.is(parametersPath.syncRate)){updateSyncRate();} else if (param.is(parametersPath.monitorKeysCues)){monitorKeysCues();} else if (param.is(parametersPath.clearSequence)){seq_clearSequence();} else if (param.is(parametersPath.reorderSequence)){seq_reorderSequence();} else if (param.is(parametersPath.changeSequence)){refreshSequenceEnum();} else if (param.is(parametersPath.sequence)){ sequence = sequencePath.getKey(); if(sequence!=""){ script.log("watching "+ sequence); local.parameters.sequence.setAttribute("readonly",true); } } else{script.log("received module param :" + param.name);} } function updateSynchronize(){ // var parametersPath = local.getChild("parameters") ; doSync = parametersPath.synchronize.get(); script.log(doSync ? "sync ON" : "sync OFF" ); } function updateSyncRate(){ // var parametersPath = local.getChild("parameters") ; syncRatems = parametersPath.syncRate.get() / 1000.; script.log("new sync rate : " + syncRatems); // script.setUpdateRate(syncRatems); } function monitorKeysCues(){ // var parametersPath = local.getChild("parameters") ; doSyncKeysCues = parametersPath.monitorKeysCues.get() ; script.log(doSyncKeysCues ? "syncKeys ON" : "syncKeys OFF" ); // script.setUpdateRate(syncRatems); } //refresh Enum function refreshSequenceEnum(){ script.log("refresh list of sequences"); local.parameters.sequence.setAttribute("readonly",false); if(root.sequences.getItems().length){ local.parameters.sequence.removeOptions(); local.parameters.sequence.addOption("", 0); for(var i=0 ; i 0 ? false : true ; //0 to remove, 1 to add delta = Math.abs(delta); script.log("cues "+ delta + (addRemove ? " up" : " down")); for(var i=0; i 0 ? false : true ; //0 to remove, 1 to add delta = Math.abs(delta); script.log("layers "+ delta + (addRemove ? " up" : " down")); for(var i=0; i 0 ? false : true ; //0 to remove, 1 to add delta = Math.abs(delta); script.log("keys "+ delta + (addRemove ? " up" : " down")); for(var i=0; i 0 ? false : true ; //0 to remove, 1 to add delta = Math.abs(delta); script.log("clips "+ delta + (addRemove ? " up" : " down")); for(var i=0; i 0 ? false : true ; //0 to remove, 1 to add delta = Math.abs(delta); script.log("Group layers "+ delta + (addRemove ? " up" : " down")); for(var i=0; i